mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Merge pull request #431 from pawelhulek/adds_districts_to_ecoharmonogram
adds districts to ecoharmogram
This commit is contained in:
@@ -51,10 +51,12 @@ class Ecoharmonogram:
|
||||
return town_data
|
||||
|
||||
@staticmethod
|
||||
def print_possible_sides(town_input, street_input, house_number_input):
|
||||
def print_possible_sides(town_input, district_input, street_input, house_number_input):
|
||||
town_data = Ecoharmonogram.fetch_town()
|
||||
matching_towns = filter(lambda x: town_input.lower() in x.get('name').lower(), town_data.get('towns'))
|
||||
town = list(matching_towns)[0]
|
||||
matching_towns_district = filter(lambda x: district_input.lower() in x.get('district').lower(), matching_towns)
|
||||
|
||||
town = list(matching_towns_district)[0]
|
||||
|
||||
schedule_periods_data = Ecoharmonogram.fetch_scheduled_periods(town)
|
||||
schedule_periods = schedule_periods_data.get("schedulePeriods")
|
||||
@@ -66,4 +68,4 @@ class Ecoharmonogram:
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
Ecoharmonogram.print_possible_sides(sys.argv[1], sys.argv[2] or "", sys.argv[3] or "")
|
||||
Ecoharmonogram.print_possible_sides(sys.argv[1], sys.argv[2] or "", sys.argv[3] or "", sys.argv[4] or "")
|
||||
|
||||
@@ -9,23 +9,29 @@ TEST_CASES = {
|
||||
"Simple test case": {"town": "Krzeszowice", "street": "Wyki", "house_number": ""},
|
||||
"Sides multi test case": {"town": "Częstochowa", "street": "Boczna", "additional_sides_matcher": "wie"},
|
||||
"Sides test case": {"town": "Częstochowa", "street": "Azaliowa", "house_number": "1",
|
||||
"additional_sides_matcher": "jedn"}
|
||||
"additional_sides_matcher": "jedn"},
|
||||
"Sides multi test case with district": {"town": "Borkowo", "district": "Pruszcz Gdański", "street": "Sadowa",
|
||||
"additional_sides_matcher": "Wielorodzinna - powyżej 7 lokali"},
|
||||
}
|
||||
TITLE = "ecoharmonogram.pl"
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, town, street="", house_number="", additional_sides_matcher=""):
|
||||
def __init__(self, town, district="", street="", house_number="", additional_sides_matcher=""):
|
||||
self.town_input = town
|
||||
self.street_input = street
|
||||
self.house_number_input = house_number
|
||||
self.district_input = district
|
||||
self.additional_sides_matcher_input = additional_sides_matcher
|
||||
|
||||
def fetch(self):
|
||||
|
||||
town_data = Ecoharmonogram.fetch_town()
|
||||
matching_towns = filter(lambda x: self.town_input.lower() in x.get('name').lower(), town_data.get('towns'))
|
||||
town = list(matching_towns)[0]
|
||||
matching_towns_district = filter(lambda x: self.district_input.lower() in x.get('district').lower(),
|
||||
matching_towns)
|
||||
|
||||
town = list(matching_towns_district)[0]
|
||||
|
||||
schedule_periods_data = Ecoharmonogram.fetch_scheduled_periods(town)
|
||||
schedule_periods = schedule_periods_data.get("schedulePeriods")
|
||||
|
||||
@@ -13,6 +13,7 @@ waste_collection_schedule:
|
||||
args:
|
||||
town: town
|
||||
street: street
|
||||
district: district
|
||||
house_number: house_number
|
||||
additional_sides_matcher: additional matching parameter
|
||||
```
|
||||
@@ -25,11 +26,12 @@ waste_collection_schedule:
|
||||
- name: ecoharmonogram_pl
|
||||
args:
|
||||
town: Krzeszowice
|
||||
district: Krzeszowice
|
||||
street: Wyki
|
||||
additional_sides_matcher: Nieruchomości wielolokalowe
|
||||
```
|
||||
|
||||
Worth to mention that street and house_number are optional parameters if your city doesn't require one.
|
||||
Worth to mention that district, street, house_number and additional_sides_matcher are optional parameters if your city doesn't require one.
|
||||
|
||||
## Keep in mind
|
||||
|
||||
@@ -39,17 +41,17 @@ Also, together with garbage collection schedule you may see also payment reminde
|
||||
## How to check additional matchers
|
||||
|
||||
If your community is providing schedules for separate side types - like house/company/flats you will need to find
|
||||
additinal matching parameter:
|
||||
additional matching parameter:
|
||||
to do that you should execute the following script:
|
||||
|
||||
```bash
|
||||
python3 ./custom_components/waste_collection_schedule/waste_collection_schedule/service/EcoHarmonogramPL.py town_name street_name house_number
|
||||
python3 ./custom_components/waste_collection_schedule/waste_collection_schedule/service/EcoHarmonogramPL.py town_name district street_name house_number
|
||||
```
|
||||
|
||||
for example:
|
||||
|
||||
```bash
|
||||
python3 ./custom_components/waste_collection_schedule/waste_collection_schedule/service/EcoHarmonogramPL.py Częstochowa Boczna 1
|
||||
python3 ./custom_components/waste_collection_schedule/waste_collection_schedule/service/EcoHarmonogramPL.py Częstochowa Częstochowa Boczna 1
|
||||
```
|
||||
|
||||
This should print you following types of additional match:
|
||||
|
||||
Reference in New Issue
Block a user