Skip to content
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

Add support for Kleszczewo and Kostrzyn commune in Poland #2238

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sematuszewski
Copy link

Add support for Kleszczewo and Kostrzyn commune in Poland

Comment on lines +110 to +121
for row_index, row in enumerate(tree.findall(".//tr")):
if row_index > 0:
for cell_index, cell in enumerate(row.findall(".//td")):
if cell_index > 0 and isinstance(cell.text, str):
for day in cell.text.split(","):
entries.append(
Collection(
datetime.date(year, row_index - 1, int(day)),
NAME_MAP[cell_index],
ICON_MAP[cell_index],
)
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd highly prefer to prevent this deep nesting by inverting your if condition and continue (if row_index == 0): continue

Is Hard-coding the index to names map a good idea? Wouldn't it be better to just read the name from the th's of the first row?

@5ila5
Copy link
Collaborator

5ila5 commented Jul 11, 2024

bandit: /home/silas/Documents/coding/python/hacs_waste_collection_schedule/custom_components/waste_collection_schedule/waste_collection_schedule/source/zys_harmonogram_pl.py:114: B314[bandit]: MEDIUM: Using xml.etree.ElementTree.fromstring to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree.fromstring with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called It's probably not the biggest problem, as it comes from a somewhat trusted source, but I think it's a better idea to use BeatuifulSoup

…e defusedxml library.

Improved request.get to use params arguments.
@sematuszewski
Copy link
Author

bandit: /home/silas/Documents/coding/python/hacs_waste_collection_schedule/custom_components/waste_collection_schedule/waste_collection_schedule/source/zys_harmonogram_pl.py:114: B314[bandit]: MEDIUM: Using xml.etree.ElementTree.fromstring to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree.fromstring with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called It's probably not the biggest problem, as it comes from a somewhat trusted source, but I think it's a better idea to use BeatuifulSoup

You're right, I changed the library to defusedxml.ElementTree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants