mirror of
https://github.com/DerTyp7/local-analyzer-python.git
synced 2025-10-29 12:32:10 +01:00
22 lines
662 B
Python
22 lines
662 B
Python
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)
|