quality of life arreglets
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
SOURCE_FOLDER = "/home/sergio/roms/batocera_arrm_scrapped"
|
||||
DEST_FOLDER = "/home/sergio/roms/es-de_from_batocera"
|
||||
|
||||
GET_VIDEOS = False
|
||||
|
||||
SYSTEMS = ["ngp", "ngpc"]
|
||||
|
||||
CREATE_SYM_LINKS = True
|
||||
+25
-14
@@ -1,16 +1,20 @@
|
||||
from systems_definitions import get_system_name, filter_translatable_systems
|
||||
from media_definitions import media_table, get_media_name
|
||||
from config import SOURCE_FOLDER, DEST_FOLDER, GET_VIDEOS, SYSTEMS, CREATE_SYM_LINKS
|
||||
import os
|
||||
import shutil
|
||||
import pprint
|
||||
|
||||
SOURCE_FOLDER = "/home/sergio/roms/batocera_arrm_scrapped"
|
||||
DEST_FOLDER = "/home/sergio/roms/es-de_from_batocera"
|
||||
|
||||
def list_directories(path):
|
||||
"""Devuelve una lista de directorios en la ruta especificada."""
|
||||
# Lista los nombres en la ruta y verifica cuáles son directorios
|
||||
directories = [name for name in os.listdir(path) if os.path.isdir(os.path.join(path, name))]
|
||||
"""
|
||||
Devuelve una lista de directorios en la ruta especificada
|
||||
que se encuentren en la lista SYSTEMS.
|
||||
"""
|
||||
# Lista los nombres en la ruta, verifica si son directorios, y si están en SYSTEMS
|
||||
directories = [
|
||||
name for name in os.listdir(path)
|
||||
if os.path.isdir(os.path.join(path, name)) and name in SYSTEMS
|
||||
]
|
||||
return directories
|
||||
|
||||
|
||||
@@ -103,13 +107,16 @@ def create_file_list():
|
||||
|
||||
def copy_file(source_path, dest_path):
|
||||
"""
|
||||
Copia un archivo desde la ruta source_path a dest_path, creando directorios si es necesario.
|
||||
Copia un archivo desde source_path a dest_path, o crea un enlace simbólico
|
||||
según el valor de CREATE_SYM_LINKS.
|
||||
Si el archivo de destino ya existe, no hace nada.
|
||||
Si el archivo tiene una extensión no permitida, no lo copia.
|
||||
Si el archivo tiene una extensión no permitida, no lo copia ni lo enlaza.
|
||||
Si el archivo es un .xml, se usa un método especial para copiarlo.
|
||||
"""
|
||||
# Lista de extensiones no permitidas
|
||||
forbidden_extensions = [".mp4"]
|
||||
forbidden_extensions = []
|
||||
if not GET_VIDEOS:
|
||||
forbidden_extensions.append(".mp4")
|
||||
|
||||
if not source_path or not dest_path:
|
||||
print(f"Source o destino inválido: {source_path}, {dest_path}. Saltando...")
|
||||
@@ -134,17 +141,21 @@ def copy_file(source_path, dest_path):
|
||||
|
||||
# Verificar si el archivo de destino ya existe
|
||||
if os.path.exists(dest_path):
|
||||
print(f"El archivo ya existe: {dest_path}. No se realiza la copia.")
|
||||
print(f"El archivo ya existe: {dest_path}. No se realiza la operación.")
|
||||
return
|
||||
|
||||
# Copiar el archivo
|
||||
# Comportamiento según CREATE_SYM_LINKS
|
||||
try:
|
||||
shutil.copy2(source_path, dest_path) # Usa copy2 para preservar metadata
|
||||
print(f"Copiado: {source_path} -> {dest_path}")
|
||||
if CREATE_SYM_LINKS:
|
||||
os.symlink(source_path, dest_path) # Crear el enlace simbólico
|
||||
print(f"Enlace simbólico creado: {source_path} -> {dest_path}")
|
||||
else:
|
||||
shutil.copy2(source_path, dest_path) # Copiar el archivo
|
||||
print(f"Copiado: {source_path} -> {dest_path}")
|
||||
except FileNotFoundError:
|
||||
print(f"Archivo fuente no encontrado: {source_path}. Saltando...")
|
||||
except Exception as e:
|
||||
print(f"Error al copiar {source_path} a {dest_path}: {e}")
|
||||
print(f"Error al realizar la operación con {source_path} a {dest_path}: {e}")
|
||||
|
||||
|
||||
def copy_xml_file(source_path, dest_path):
|
||||
|
||||
+22
-12
@@ -1,33 +1,53 @@
|
||||
# Diccionario de sistemas definido globalmente
|
||||
systems_table = {
|
||||
"amiga1200": "amiga",
|
||||
"amstradcpc": "amstradcpc",
|
||||
"atari2600": "atari2600",
|
||||
"atari5200": "atari5200",
|
||||
"atari7800": "atari7800",
|
||||
"atarist": "atarist",
|
||||
"c64": "c64",
|
||||
"colecovision": "colecovision",
|
||||
"dreamcast": "dreamcast",
|
||||
"fbneo": "fbneo",
|
||||
"fds": "fds",
|
||||
"gamegear": "gamegear",
|
||||
"gb": "gb",
|
||||
"gba": "gba",
|
||||
"gbc": "gbc",
|
||||
"intellivision": "intellivision",
|
||||
"jaguar": "atarijaguar",
|
||||
"lynx": "atarilynx",
|
||||
"mastersystem": "mastersystem",
|
||||
"megadrive": "megadrive",
|
||||
"msx1": "msx1",
|
||||
"msx2": "msx2",
|
||||
"neogeo": "neogeo",
|
||||
"neogeocd": "neogeocd",
|
||||
"nes": "nes",
|
||||
"ngp": "ngp",
|
||||
"ngpc": "ngpc",
|
||||
"o2em": "oddysey2",
|
||||
"pcengine": "pcengine",
|
||||
"pcenginecd": "pcenginecd",
|
||||
"pico8": "pico8",
|
||||
"ps2": "ps2",
|
||||
"psp": "psp",
|
||||
"psx": "psx",
|
||||
"satellaview": "satellaview",
|
||||
"saturn": "saturn",
|
||||
"sega32x": "sega32x",
|
||||
"segacd": "segacd",
|
||||
"sg1000": "sg-1000",
|
||||
"snes": "snes",
|
||||
"supergrafx": "supergrafx",
|
||||
"virtualboy": "virtualboy",
|
||||
"wswan": "wonderswan",
|
||||
"wswanc": "wonderswancolor"
|
||||
"wswanc": "wonderswancolor",
|
||||
"zxspectrum": "zxspectrum"
|
||||
}
|
||||
|
||||
|
||||
# Método para obtener la equivalencia del nombre de un sistema
|
||||
def get_system_name(system_name):
|
||||
"""Obtiene la equivalencia del nombre de un sistema."""
|
||||
@@ -36,14 +56,4 @@ def get_system_name(system_name):
|
||||
# Método para filtrar los sistemas con traducción disponible
|
||||
def filter_translatable_systems(system_names):
|
||||
"""Filtra y devuelve los sistemas que tienen traducción disponible."""
|
||||
return [name for name in system_names if name in systems_table]
|
||||
|
||||
# Ejemplo de uso
|
||||
# input_systems = ["dreamcast", "gamegear", "invalid_system", "psx", "nonexistent"]
|
||||
# translatable = filter_translatable_systems(input_systems)
|
||||
# print(f"Sistemas traducibles: {translatable}")
|
||||
|
||||
# Ejemplo de traducción de un sistema
|
||||
# name_to_translate = "lynx"
|
||||
# translated_name = get_system_name(name_to_translate)
|
||||
# print(f"Nombre traducido: {translated_name}")
|
||||
return [name for name in system_names if name in systems_table]
|
||||
Reference in New Issue
Block a user