Skip to content

Commit

Permalink
Include inst path in copy destination (Issue #203)
Browse files Browse the repository at this point in the history
Modify the get_dest_dir() method to insert the "inst/<name>" part of the source path in the destination path, if it exists.

Take advantage of the fact that os.path.join inserts directory separators only for non-empty segments. By initializing inst_path and overlays to "", this avoids multiple branches and should have been done previously.
  • Loading branch information
csatt committed Apr 9, 2023
1 parent 5581749 commit 562ecb8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions python3/IV_Swinger2_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3759,12 +3759,17 @@ def get_dest_dir(self, src_dir):
"""Method to derive the destination directory name from the source
directory name
"""
inst_path = ""
overlays = ""
src_dir_parts = os.path.normpath(src_dir).split(os.path.sep)
if ("inst" in src_dir_parts and
src_dir_parts[src_dir_parts.index("inst") - 1] == APP_NAME):
inst_name = src_dir_parts[src_dir_parts.index("inst") + 1]
inst_path = os.path.join("inst", inst_name)
if os.path.basename(os.path.dirname(src_dir)) == "overlays":
dest_dir = os.path.join(self.copy_dest, APP_NAME,
"overlays", os.path.basename(src_dir))
else:
dest_dir = os.path.join(self.copy_dest, APP_NAME,
os.path.basename(src_dir))
overlays = "overlays"
dest_dir = os.path.join(self.copy_dest, APP_NAME, inst_path,
overlays, os.path.basename(src_dir))
return dest_dir

# -------------------------------------------------------------------------
Expand Down

0 comments on commit 562ecb8

Please sign in to comment.