Skip to content

Commit

Permalink
Update method naming and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-sheese committed Jan 15, 2024
1 parent 1dad746 commit 4256d90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/kohlrahbi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


# pylint:disable=anomalous-backslash-in-string
def get_valid_pruefis(
def get_pruefi_to_file_map(
pruefi_to_file_mapping: dict[str, str | None], all_known_pruefis: Optional[list[str]] = None
) -> dict[str, str | None]:
"""
Expand Down Expand Up @@ -237,7 +237,7 @@ def validate_pruefis(pruefi_to_file_mapping: dict[str, str | None]) -> dict[str,
"""
Validate the pruefi_to_file_mapping parameter.
"""
valid_pruefi_to_file_mappings = get_valid_pruefis(pruefi_to_file_mapping)
valid_pruefi_to_file_mappings = get_pruefi_to_file_map(pruefi_to_file_mapping)
if not valid_pruefi_to_file_mappings:
click.secho("⚠️ There are no valid pruefidentifkatoren.", fg="red")
raise click.Abort()
Expand Down Expand Up @@ -319,7 +319,7 @@ def process_ahb_table(

def scrape_pruefis(
pruefi_to_file_mapping: dict[str, str | None],
input_path: Path,
basic_input_path: Path,
output_path: Path,
file_type: Literal["flatahb", "csv", "xlsx", "conditions"],
) -> None:
Expand All @@ -336,13 +336,13 @@ def scrape_pruefis(
for pruefi, filename in valid_pruefi_to_file_mappings.items():
try:
logger.info("start looking for pruefi '%s'", pruefi)
old_path = input_path
input_path = basic_input_path # To prevent multiple adding of filenames
# that would happen if filenames are added but never removed
if filename is not None:
input_path = input_path.joinpath(
Path(filename)
) # To add the name of the file containing the pruefi, if known
process_pruefi(pruefi, input_path, output_path, file_type, path_to_document_mapping, collected_conditions)
input_path = old_path # Otherwise the path grows when multiple pruefis are processed
# sorry for the pokemon catch
except Exception as e: # pylint: disable=broad-except
logger.exception("Error processing pruefi '%s': %s", pruefi, str(e))
Expand Down Expand Up @@ -417,12 +417,12 @@ def main(
click.secho(f"I created a new directory at {output_path}", fg="yellow")
pruefi_to_file_mapping: dict[str, str | None] = {
key: None for key in pruefis
} # A mapping of a prufi (key) to the name (+ path) of the file containing the prufi
} # A mapping of a pruefi (key) to the name (+ path) of the file containing the prufi
match flavour:
case "pruefi":
scrape_pruefis(
pruefi_to_file_mapping=pruefi_to_file_mapping,
input_path=input_path,
basic_input_path=input_path,
output_path=output_path,
file_type=file_type,
)
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_input_checks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest # type:ignore[import]

from kohlrahbi import get_valid_pruefis
from kohlrahbi import get_pruefi_to_file_map


@pytest.mark.parametrize(
Expand Down Expand Up @@ -231,5 +231,5 @@
def test_get_only_valid_pruefis(
input_pruefis: dict[str, str | None], expected_pruefis: dict[str, str], known_pruefis: list[str] | None
):
valid_pruefis = get_valid_pruefis(pruefi_to_file_mapping=input_pruefis, all_known_pruefis=known_pruefis)
valid_pruefis = get_pruefi_to_file_map(pruefi_to_file_mapping=input_pruefis, all_known_pruefis=known_pruefis)
assert valid_pruefis == expected_pruefis

0 comments on commit 4256d90

Please sign in to comment.