Skip to content

Commit 14cb9ec

Browse files
authored
Update games_mods_cleaner.py
1 parent 2c7d913 commit 14cb9ec

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

games_mods_cleaner.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,22 @@ def remove_directory(directory):
3434

3535
def create_backup(path):
3636
path = str(Path(path).resolve())
37-
backup_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), BACKUP_DIR)
37+
executable_dir = os.path.dirname(os.path.abspath(__file__))
38+
backup_dir = os.path.join(executable_dir, BACKUP_DIR)
3839
os.makedirs(backup_dir, exist_ok=True)
3940
backup_file_path = os.path.join(backup_dir, f'{os.path.basename(path)}_Backup.json')
41+
print(f"Saving backup to: {backup_file_path}") # Debug line
4042
with open(backup_file_path, 'w') as f:
4143
json.dump(get_file_tree(path), f)
4244

4345
def restore_vanilla(path):
4446
path = str(Path(path).resolve())
45-
backup_file_path = os.path.join(BACKUP_DIR, f'{os.path.basename(path)}_Backup.json')
47+
executable_dir = os.path.dirname(os.path.abspath(__file__))
48+
backup_file_path = os.path.join(executable_dir, BACKUP_DIR, f'{os.path.basename(path)}_Backup.json')
49+
print(f"Loading backup from: {backup_file_path}") # Debug line
4650

4751
if not os.path.exists(backup_file_path):
48-
messagebox.showerror('Error', 'No se encontró el archivo de copia de seguridad para esta ruta')
52+
messagebox.showerror('Error', 'No backup file found for this path')
4953
return
5054

5155
with open(backup_file_path, 'r') as f:
@@ -66,20 +70,20 @@ def restore_vanilla(path):
6670

6771
if not missing_files and not missing_folders:
6872
if not new_files and not new_folders:
69-
messagebox.showinfo("Sin Cambios", "No hay cambios en la lista de archivos.")
73+
messagebox.showinfo("No Changes", "There are no changes to the list of files.")
7074
elif new_files:
71-
if messagebox.askyesno("Archivos No Listados", f"Encontró {len(new_files)} archivos no listados. ¿Eliminar estos archivos?"):
75+
if messagebox.askyesno("Unlisted Files", f"Found {len(new_files)} unlisted files. Delete them?"):
7276
for file in new_files:
7377
try:
7478
os.remove(os.path.join(path, file))
7579
except OSError as e:
76-
print(f"Error al eliminar el archivo {file}: {e}")
80+
print(f"Error removing file {file}: {e}")
7781

7882
if missing_files:
79-
messagebox.showwarning("Archivos Faltantes", "Faltan los siguientes archivos:\n" + "\n".join(missing_files))
83+
messagebox.showwarning("Missing Files", "The following files are missing:\n" + "\n".join(missing_files))
8084

8185
if new_folders:
82-
if messagebox.askyesno("Nuevas Carpetas", f"Encontró {len(new_folders)} nuevas carpetas. ¿Eliminar estas carpetas?"):
86+
if messagebox.askyesno("New Folders", f"Found {len(new_folders)} new folders. Delete them?"):
8387
for folder in new_folders:
8488
remove_directory(os.path.join(path, folder))
8589

@@ -160,11 +164,11 @@ def configure_theme(self):
160164
def configure_texts(self):
161165
if self.language == '0409': # English (US)
162166
self.texts = {
163-
"create_backup": "List Files",
164-
"restore_backup": "Delate Mods",
167+
"create_backup": "Create Backup",
168+
"restore_backup": "Restore Backup",
165169
"error_path": "Path does not exist.",
166-
"backup_created": "The list file has been created in the backups folder.",
167-
"error_no_backup": "No list file found for this path",
170+
"backup_created": "The backup file has been created in the backups folder.",
171+
"error_no_backup": "No backup file found for this path",
168172
"no_changes": "There are no changes to the list of files.",
169173
"unlisted_files": "Found {} unlisted files. Delete them?",
170174
"missing_files": "The following files are missing:\n",
@@ -174,11 +178,11 @@ def configure_texts(self):
174178
}
175179
else: # Default to Spanish
176180
self.texts = {
177-
"create_backup": "Crear Lista",
178-
"restore_backup": "Borrar Mods",
181+
"create_backup": "Crear Backup",
182+
"restore_backup": "Restaurar Backup",
179183
"error_path": "El path no existe.",
180184
"backup_created": "El archivo de copia de seguridad ha sido creado en la carpeta de backups.",
181-
"error_no_backup": "No se encontró archivo de lista seguridad para este path",
185+
"error_no_backup": "No se encontró archivo de copia de seguridad para este path",
182186
"no_changes": "No hay cambios en la lista de archivos.",
183187
"unlisted_files": "Encontró {} archivos no listados. ¿Quieres borrarlos?",
184188
"missing_files": "Los siguientes archivos faltan:\n",

0 commit comments

Comments
 (0)