diff --git a/scripts/main.py b/scripts/main.py index 06d01a4..ea8fcb4 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -1,4 +1,5 @@ # %% +import datetime import os import xml.etree.ElementTree as ET @@ -55,3 +56,65 @@ def get_file_url(url: str) -> str: with open(filepath, "wb") as file: file.write(response.content) + +#%% +# Separate the English and German file URLs based on the filename +english_file_urls = [url for url in file_urls if "_EN_" in os.path.basename(url)] +german_file_urls = [url for url in file_urls if "_EN_" not in os.path.basename(url)] + +# Create a simple index.html file with links to the downloaded PDFs +with open("index.html", "w") as file: + file.write(""" + + + + RKI Abwasser Reports Mirror + + +
+

RKI Abwasser Reports Mirror

+

This website serves as a mirror for the Robert Koch Institute (RKI) wastewater reports, allowing direct access to the latest reports without requiring file downloads. You can browse the available English and German reports below.

+

The original reports are available at https://edoc.rki.de/handle/176904/11665.

+ +
+

English Reports

+
+ """) + + for url in english_file_urls: + filename = os.path.basename(url) + file.write(f'{filename}
') + + file.write(""" +
+
+
+

German Reports

+
+ """) + + for url in german_file_urls: + filename = os.path.basename(url) + file.write(f'{filename}
') + + file.write(f""" +
+
+

Created by Cornelius Roemer
+ Source code available on GitHub
+ Last updated: {datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%dT%H:%M:%S %Z")}

+
+ + + """) +# %% diff --git a/scripts/ruff.toml b/scripts/ruff.toml new file mode 100644 index 0000000..32b7721 --- /dev/null +++ b/scripts/ruff.toml @@ -0,0 +1,90 @@ +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 88 +indent-width = 4 + +# Assume Python 3.8 +target-version = "py312" + +[lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", +] +ignore = ["E501"] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic"