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

Add check for file existence #143

Merged
merged 10 commits into from
Apr 5, 2023
Merged

Add check for file existence #143

merged 10 commits into from
Apr 5, 2023

Conversation

BSchilperoort
Copy link
Member

@BSchilperoort BSchilperoort commented Mar 28, 2023

This PR adds a simple check for if any of the filenames that will be created already exist. The user will be prompted if they do, and will be asked if they want to overwrite the files or not.

If they do not want to overwrite the files, a FileExistsError is thrown.

Closes #49, #76

Issue #49 mentions checking the file size, but this is not trivial, and would probably be more complex than is required here.

Additionally, I noticed that the config existence checker was not being run when making an era5cli request. I added this in and fixed the tests.

@BSchilperoort BSchilperoort marked this pull request as ready for review March 28, 2023 12:20
@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Merging #143 (43a2218) into main (634d323) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #143   +/-   ##
=======================================
  Coverage   99.65%   99.66%           
=======================================
  Files          14       14           
  Lines         579      592   +13     
=======================================
+ Hits          577      590   +13     
  Misses          2        2           

@BSchilperoort BSchilperoort linked an issue Mar 28, 2023 that may be closed by this pull request
@BSchilperoort BSchilperoort changed the title Add check for file existance Add check for file existence Mar 28, 2023
Copy link
Collaborator

@Peter9192 Peter9192 left a comment

Choose a reason for hiding this comment

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

Okay

if answer.lower() in ["n", "no", "nope"]:
raise FileExistsError(
"\n One or more files already exist in this folder."
"\n Please remove them, or change to a different folder to continue"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This begs for a skip-existing flag...

Copy link
Member Author

Choose a reason for hiding this comment

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

I have implemented --overwrite.

@BSchilperoort BSchilperoort merged commit e6c85c4 into main Apr 5, 2023
@BSchilperoort BSchilperoort deleted the fileexists_check branch April 5, 2023 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants