Skip to content

Commit e137ffb

Browse files
Add requirements, fix bug w/ existing folder in destination
1 parent 9de0d79 commit e137ffb

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
DAZFix/__pycache__
22
__pycache__
33

4+
# Virtual Environment
5+
.dazfix
6+
47
# PyInstaller files
58
/build
69
/dist

DAZFix/LibraryFix.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class HaltException(Exception): pass
2525

2626

2727
def move_to_new_home(dupe_dirs_folder, dest_full_path, root):
28-
print(f'Moving objects into {dest_full_path}')
28+
log_to_ui(f'Moving objects into {dest_full_path}')
2929
for item in dupe_dirs_folder:
3030
dupe_folder_path = os.path.join(root, item)
3131

@@ -36,16 +36,35 @@ def move_to_new_home(dupe_dirs_folder, dest_full_path, root):
3636

3737
# Move the files into the chosen directory
3838
# subfolder_alone = os.path.basename(os.path.normpath(dupe_folder_path))
39+
# log_to_ui(f'Getting all objects within: {dupe_folder_path}')
3940
objects_within_folder = os.listdir(dupe_folder_path)
4041

4142
for obj in objects_within_folder:
4243
source = os.path.join(dupe_folder_path, obj)
4344
destination = os.path.join(dest_full_path, obj)
44-
print(f'Moving {obj} => {destination}');
45-
shutil.move(source, destination)
46-
45+
46+
# If we're moving a folder, shutil will put the folder inside the "destination" if it does not exist.
47+
# However, if the destination folder already has that folder, it puts it INSIDE that folder, creating something like
48+
# TheFolder/Characters/Characters....FML
49+
if os.path.isdir(destination):
50+
if os.path.isdir(source):
51+
for file in os.listdir(source):
52+
src = os.path.join(source, file)
53+
dest = os.path.join(destination, file)
54+
log_to_ui(f'Moving {src} => {destination}')
55+
56+
if os.path.isdir(source):
57+
shutil.move(src, dest)
58+
else:
59+
shutil.copy2(src, dest)
60+
61+
else:
62+
log_to_ui(f'Moving {obj} => {destination}')
63+
shutil.move(source, destination)
64+
4765
# Now that all the files are moved out, delete the directory
48-
os.rmdir(dupe_folder_path)
66+
if os.path.isdir(dupe_folder_path):
67+
shutil.rmtree(dupe_folder_path)
4968

5069
def make_archive(source, destination):
5170
base = os.path.basename(destination)
@@ -143,7 +162,7 @@ def fix_libraries(backup_first, backup_zip_path, daz_default_library_path, daz_u
143162
chosen_subdirectory = dupe_dirs_in_default_folder[0]
144163
chosen_full_path = os.path.join(root, chosen_subdirectory)
145164
else:
146-
log_to_ui('\nThere is no folder with this name in the default DAZ library')
165+
log_to_ui(f'\nThere is no folder with this name in the default DAZ library: {os.path.join(root, dupe)}')
147166
# If there are multiple folders in the user's library, but none in the DAZ default library, we need to pick, but can't use the name in the DAZ default directory
148167
# First, here, create a dictionary that stores the subfolder name & the number of ojbects in it
149168
dupe_subdirectories = dict()

daz_linux_casefix.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from PyQt6 import uic
33
import qdarktheme
44

5+
56
import sys
67
import os
78
import pickle
@@ -137,7 +138,7 @@ def fix_directories(self):
137138
except Exception as argument:
138139
msg_box = QMessageBox(self)
139140
msg_box.setWindowTitle("ERROR: Fixing Libararies")
140-
msg_box.setText(argument)
141+
msg_box.setText(str(argument))
141142
msg_box.show()
142143
return
143144

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PyQt6
2+
pyqtdarktheme

0 commit comments

Comments
 (0)