-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: filter for most recent files #163
Conversation
src/migmose/parsing.py
Outdated
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 | ||
), |
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.
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 ;)
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.
Co-authored-by: konstantin <konstantin.klein@hochfrequenz.de>
Co-authored-by: konstantin <konstantin.klein@hochfrequenz.de>
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.
Danke!
matches = _pattern.search(document_str) | ||
if matches: | ||
document_version = matches.group(1) |
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.
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
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.
gueltig_von_date = int(parts[-1]) | ||
gueltig_bis_date = int(parts[-2]) |
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.
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.
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.
No description provided.