fix remove (again)
dl / lint (push) Successful in 2m4s Details
dl / docker (push) Successful in 4m3s Details

This commit is contained in:
Michel Roux 2023-10-03 18:11:40 +02:00
parent fadb481c0f
commit 3b971bfda6
1 changed files with 19 additions and 34 deletions

View File

@ -43,24 +43,9 @@ def download(path, file):
def remove(path, file):
print(f"Removing {path}/{file}")
# os.remove(os.path.join(path, file))
def get_title_fullid(name):
re_id = re.search(r"\[([0-9A-F]*)\]", name)
return re_id.group(1) if re_id else None
def extract_shortid(full_id):
return full_id[0:-4]
def get_title_shortid(name):
full_id = get_title_fullid(name)
return extract_shortid(full_id) if full_id in titles else None
if os.path.isfile(os.path.join(path, file)):
print(f"Removing {path}/{file}")
os.remove(os.path.join(path, file))
req_titles = requests.get(
@ -82,21 +67,16 @@ updates = drive_list("nsz/updates")
print("Updates OK")
for base in os.listdir("nsz/base"):
if os.path.isfile(os.path.join("nsz/base", base)):
full_id = get_title_fullid(base)
short_id = get_title_shortid(base)
def get_title_shortid(name):
re_id = re.search(r"\[([0-9A-F]*)\]", name)
if not short_id:
remove("nsz/base", base)
if not re_id:
return
for dlc in os.listdir("nsz/dlc"):
if extract_shortid(full_id) in dlc:
remove("nsz/dlc", dlc)
id = re_id.group(1)
return id[0:-4] if id in titles else None
for update in os.listdir("nsz/updates"):
if extract_shortid(full_id) in update:
remove("nsz/updates", update)
try:
subprocess.run(
@ -107,18 +87,23 @@ try:
except subprocess.CalledProcessError:
pass
for base in bases:
id = get_title_shortid(base)
if not id:
continue
download("nsz/base", base)
if id:
download("nsz/base", base)
else:
remove("nsz/base", base)
for dlc in dlcs:
if id in dlc:
download("nsz/dlc", dlc)
else:
remove("nsz/dlc", dlc)
for update in updates:
if id in update:
download("nsz/updates", update)
else:
remove("nsz/updates", update)