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

fix: filter for most recent files #163

Conversation

DeltaDaniel
Copy link
Contributor

No description provided.

src/migmose/parsing.py Outdated Show resolved Hide resolved
Comment on lines 94 to 98
key=lambda path: (
int(path.stem.split("_")[-1]), # "gültig von" date
int(path.stem.split("_")[-2]), # "gültig bis" date
_extract_document_version(path.stem.split("_")[-3]), # version number
),
Copy link
Contributor

Choose a reason for hiding this comment

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

du könntet diesesn gemeinsamen part auch auslagern in eine kleine private function?

def _get_sorting_key(path:??)->tuple[int,int,str]:#??
   return  int(path.stem.split("_")[-1]),  # "gültig von" date
                    int(path.stem.split("_")[-2]),  # "gültig bis" date
                    _extract_document_version(path.stem.split("_")[-3]),

dann müsste man es nicht duplizieren und könnte es außerdem in einem docstring erklären ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

src/migmose/parsing.py Outdated Show resolved Hide resolved
DeltaDaniel and others added 4 commits October 7, 2024 18:06
Co-authored-by: konstantin <konstantin.klein@hochfrequenz.de>
Co-authored-by: konstantin <konstantin.klein@hochfrequenz.de>
Copy link
Contributor

@hf-kklein hf-kklein left a comment

Choose a reason for hiding this comment

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

Danke!

matches = _pattern.search(document_str)
if matches:
document_version = matches.group(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Du könntest auch die capturing groups im pattern direkt benennen.

https://docs.python.org/3/library/re.html#re.Match.groupdict

Dann hängt das assignment hier nicht implizit an der Reihenfolge, sondern ist direkt im pattern schon benannt. Named groups sind ein einfacher Weg um Regex lesbarer zu machen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +196 to +197
gueltig_von_date = int(parts[-1])
gueltig_bis_date = int(parts[-2])
Copy link
Contributor

Choose a reason for hiding this comment

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

Es ist mir eine private Funktion aber ich bin darüber gestolpert, dass es Date heißt obwohl da ein int ist. Der Type hint stimmt, und wenn man weiß wie der Dateiname aussieht, dann ist auch klar was passiert. Wenn man das zum ersten Mal sieht könnte vllt ein Beispiel Dateiname oder Pfad im Docstring nicht schaden.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DeltaDaniel DeltaDaniel enabled auto-merge (squash) October 8, 2024 06:45
@DeltaDaniel DeltaDaniel merged commit 51f4f6d into main Oct 8, 2024
14 checks passed
@DeltaDaniel DeltaDaniel deleted the 160-error-processing-file-list-max-iterable-argument-is-empty branch October 8, 2024 06:46
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.

Error processing file list: max() iterable argument is empty
2 participants