-
Notifications
You must be signed in to change notification settings - Fork 1.6k
everything works but tests doesnt pass #1763
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,35 @@ | ||
| # write your code here | ||
| import sys | ||
| import os | ||
| import datetime | ||
|
|
||
|
|
||
| data = sys.argv | ||
|
|
||
|
|
||
| def write_file(filepath: str) -> None: | ||
| with open(filepath, "a") as file: | ||
| file.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When appending to an existing file, a blank line separator should be added between the new timestamp and existing content. The requirements show: blank line before |
||
| + "\n") | ||
| while True: | ||
| text = input("Enter content line:") | ||
| if text == "stop": | ||
| break | ||
| file.write(text + "\n") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Task requirement violation: Line numbering is missing. The content should be numbered starting from 1 (format: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line numbering is missing. Requirements specify content lines should be numbered starting from 1 with format |
||
|
|
||
|
|
||
| if "-d" in data: | ||
| analyzed_data = [] | ||
| for item in data: | ||
| if item == "-f": | ||
| break | ||
| analyzed_data.append(item) | ||
| if "-f" in data: | ||
| path = os.path.join(*analyzed_data[2:]) | ||
| os.makedirs(path) | ||
| current_filepath = os.path.join(path, data[-1] + ".txt") | ||
| write_file(str(current_filepath)) | ||
| else: | ||
| os.makedirs(os.path.join(*analyzed_data[2:]), exist_ok=True) | ||
|
|
||
| if "-f" in data and "-d" not in data: | ||
| write_file(data[-1] + ".txt") | ||
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.
Code structure issue: The
write_file()function should handle appending to existing files separately from creating new files. Consider passing additional parameters or checking file existence before deciding write mode.