-
-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for Komorniki and Kostrzyn commune in Poland (zys_harmonogram_pl) - fix for loop and add auto NAME_MAP #3832
base: master
Are you sure you want to change the base?
Conversation
Update readme for zys_harmonogram
…e defusedxml library. Improved request.get to use params arguments.
Add NAME_MAP by th tags
…collection_schedule # Conflicts: # README.md
_LOGGER.debug( | ||
f"fetch failed for source {TITLE}: trying different API_URL ..." | ||
) | ||
return self.get_data(API_URL.format("")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requires two format arguments only one given
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this :)
if item["value"] == self._city: | ||
city_id = item["id"] | ||
if city_id == 0: | ||
raise Exception("city not found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could raise here, for street and for number SourceArgumentNotFoundWithSuggestions
(from waste_collection_schedule.exceptions import SourceArgumentNotFoundWithSuggestions)
With raise SourceArgumentNotFoundWithSuggestions("city", self._city, [c["value"] for c in cities] )
This way you'll get a more detailed error message and for GUI configuration you'll see a drop-down of all available cities/streets/house_numbers if it fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your suggestion, I will improve the code when I have some free time :)
import datetime | ||
import json | ||
import logging | ||
import defusedxml.ElementTree as XMLDEFUSE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a dependency of this module and adding addtional dependencies should only be done when really neccesary. You could use BeatuifulSoup with "xml" parsing, It should probably work pretty much the same:
from bs4 import BeautifulSoup
[...]
tree = BeautifulSoup(table, "xml")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced XMLDEFUSE to BeautifulSoup
The test case only works when fixing the format issue. |
Replace XMLDEFUSE to BeautifulSoup
Hello,
i fixed for loop and added auto NAME_MAP with uff-8 fix for this source.