comments and shop types

This commit is contained in:
j.mei7
2022-03-22 20:02:33 +01:00
parent 4c647c8d73
commit 868f9eba0f
9 changed files with 101 additions and 62 deletions

21
managers.py Normal file
View File

@@ -0,0 +1,21 @@
from operator import itemgetter
class ShopManager:
def __init__(self, _osm):
self.osm = _osm
def getCountsOfTypes(self):
countDict = []
def isInDict(type):
for a in countDict:
if a['type'] == type:
return True
return False
if self.osm.shopList:
for shop in self.osm.shopList:
if not isInDict(shop.type):
countDict.append({'type': shop.type, 'count': sum(a.type == shop.type for a in self.osm.shopList)})
return sorted(countDict, key=itemgetter('count'), reverse=True)