def city(label): 'cf. https://github.com/laurentb/weboob/blob/master/modules/leboncoin/browser.py#L113' c = City() c.name = label if 'toute la ville' in label: c.id = label.split(' ')[0] + ' ' else: c.id = label.replace('(', '').replace(')', '') return c
def iter_cities(self): cities_list = self.doc if isinstance(self.doc, dict): cities_list = self.doc.values() for city in cities_list: city_obj = City() city_obj.id = city city_obj.name = city yield city_obj