-
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
Checking if there are more than one MIG docx files for a message_format #37
Conversation
src/migmose/parsing.py
Outdated
@@ -37,6 +39,42 @@ def find_file_to_format(message_formats: list[EdifactFormat], input_dir: Path) - | |||
raise click.Abort() | |||
|
|||
|
|||
def get_latest_file(file_list): |
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.
Kannst du hier Type hints adden?
Tests to find multiple docx files with the same message_format. | ||
""" | ||
message_formats = [EdifactFormat.IFTSTA] | ||
input_dir = Path("unittests/test_data/") |
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.
I am surprised that this path is working :D
Co-authored-by: kevin <68426071+hf-krechan@users.noreply.github.com>
Co-authored-by: kevin <68426071+hf-krechan@users.noreply.github.com>
latest_date: datetime | None = None | ||
|
||
for file_path in file_list: | ||
date, path = extract_date(file_path) |
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.
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.
lgtm
match = re.search(r"(\d{8})\.docx$", file_path.name) | ||
if match: | ||
# Return the date as a datetime object for comparison and the path for use | ||
return datetime.strptime(match.group(1), "%Y%m%d"), file_path |
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.
das datetime hat keine zeitzone 😶 aber es ist egal, weil alle keine zeitzone haben :)
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.
LGTM. Danke! :-)
it takes latest file based on timestamp in .DOCX filename