Skip to content

Commit

Permalink
add return for first if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
dipinknair committed Oct 22, 2024
1 parent fbe2129 commit 79d5d33
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/ansys/mechanical/core/embedding/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,23 @@ def save_as(self, path: str, overwrite: bool = False):
if not os.path.exists(path):
self.DataModel.Project.SaveAs(path)
return
else:
if not overwrite:
raise Exception(
f"File already exists in {path}, Use ``overwrite`` flag to "
"replace the existing file."
)

file_name = os.path.basename(path)
file_dir = os.path.dirname(path)
associated_dir = os.path.join(file_dir, os.path.splitext(file_name)[0] + "_Mech_Files")

# Remove existing files and associated folder
os.remove(path)
if os.path.exists(associated_dir):
shutil.rmtree(associated_dir)
# Save the new file
self.DataModel.Project.SaveAs(path)

if not overwrite:
raise Exception(
f"File already exists in {path}, Use ``overwrite`` flag to "
"replace the existing file."
)

file_name = os.path.basename(path)
file_dir = os.path.dirname(path)
associated_dir = os.path.join(file_dir, os.path.splitext(file_name)[0] + "_Mech_Files")

# Remove existing files and associated folder
os.remove(path)
if os.path.exists(associated_dir):
shutil.rmtree(associated_dir)
# Save the new file
self.DataModel.Project.SaveAs(path)

def launch_gui(self, delete_tmp_on_close: bool = True, dry_run: bool = False):
"""Launch the GUI."""
Expand Down

0 comments on commit 79d5d33

Please sign in to comment.