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

feat: Add overwrite option for App.save_as() #951

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

dipinknair
Copy link
Collaborator

@dipinknair dipinknair commented Oct 17, 2024

  • copies current file to temp location
  • save new file
  • delete temp file

Incase fails retrieve file from temp location

Closes #900

@dipinknair dipinknair marked this pull request as ready for review October 17, 2024 18:42
@dipinknair dipinknair requested a review from a team as a code owner October 17, 2024 18:42
@github-actions github-actions bot added the bug Something isn't working label Oct 17, 2024
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 17, 2024
Whether the file should be overwritten if it already exists (default is False).
"""
if not os.path.exists(path):
self.DataModel.Project.SaveAs(path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

return after this so we don't need to have any indent below


try:
# Move existing file to temp location
shutil.move(path, temp_file_path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@dipinknair why don't we just delete the files in path and save_as to it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In case if it fails to do a save_as, we should not be losing the existing saved files right ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with it. The user said to overwrite, I suppose they must not care too much about losing the files they ask to overwrite

# Move existing file to temp location
shutil.move(path, temp_file_path)
# Save as new file
self.DataModel.Project.SaveAs(path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

remember that the outcome of a save is both a mechdb and an accompanying folder. We need to overwrite the accompanying folder too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. I will update accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add overwrite option to save_as()
3 participants