Skip to content

Commit

Permalink
add comments to openfiles function
Browse files Browse the repository at this point in the history
  • Loading branch information
generic-github-user committed Jul 23, 2022
1 parent b8c3818 commit 7457912
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ap/ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,20 @@ def openfiles(files):
dirname = f'/home/alex/Desktop/ap-temp-{time.time()}'
# be careful
fcopy = copy.deepcopy(files)
# If two or more files have the same name, rename (copies of) them with a
# numeric suffix
for f in fcopy:
if sum(f.name == g.name for g in fcopy) > 1:
# we're operating over references so we can modify the cloned nodes
# directly
for i, h in enumerate(list(filter(lambda x: f.name == x.name, fcopy))):
suffix = f'-{i+1}'
#a, b =
h.name = str(Path(h.name).stem+suffix+h.ext)
# h.path += suffix

Path(dirname).mkdir()
# Generate the symlinks and open the folder
for f in fcopy:
Path(os.path.join(dirname, f.name)).symlink_to(f.path)
os.system(f'xdg-open {dirname}')
Expand Down

0 comments on commit 7457912

Please sign in to comment.