fix remove (again)
This commit is contained in:
parent
fadb481c0f
commit
3b971bfda6
@ -43,24 +43,9 @@ def download(path, file):
|
|||||||
|
|
||||||
|
|
||||||
def remove(path, file):
|
def remove(path, file):
|
||||||
print(f"Removing {path}/{file}")
|
if os.path.isfile(os.path.join(path, file)):
|
||||||
# os.remove(os.path.join(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
|
|
||||||
|
|
||||||
|
|
||||||
req_titles = requests.get(
|
req_titles = requests.get(
|
||||||
@ -82,21 +67,16 @@ updates = drive_list("nsz/updates")
|
|||||||
print("Updates OK")
|
print("Updates OK")
|
||||||
|
|
||||||
|
|
||||||
for base in os.listdir("nsz/base"):
|
def get_title_shortid(name):
|
||||||
if os.path.isfile(os.path.join("nsz/base", base)):
|
re_id = re.search(r"\[([0-9A-F]*)\]", name)
|
||||||
full_id = get_title_fullid(base)
|
|
||||||
short_id = get_title_shortid(base)
|
|
||||||
|
|
||||||
if not short_id:
|
if not re_id:
|
||||||
remove("nsz/base", base)
|
return
|
||||||
|
|
||||||
for dlc in os.listdir("nsz/dlc"):
|
id = re_id.group(1)
|
||||||
if extract_shortid(full_id) in dlc:
|
|
||||||
remove("nsz/dlc", dlc)
|
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:
|
try:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
@ -107,18 +87,23 @@ try:
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
for base in bases:
|
for base in bases:
|
||||||
id = get_title_shortid(base)
|
id = get_title_shortid(base)
|
||||||
|
|
||||||
if not id:
|
if id:
|
||||||
continue
|
download("nsz/base", base)
|
||||||
|
else:
|
||||||
download("nsz/base", base)
|
remove("nsz/base", base)
|
||||||
|
|
||||||
for dlc in dlcs:
|
for dlc in dlcs:
|
||||||
if id in dlc:
|
if id in dlc:
|
||||||
download("nsz/dlc", dlc)
|
download("nsz/dlc", dlc)
|
||||||
|
else:
|
||||||
|
remove("nsz/dlc", dlc)
|
||||||
|
|
||||||
for update in updates:
|
for update in updates:
|
||||||
if id in update:
|
if id in update:
|
||||||
download("nsz/updates", update)
|
download("nsz/updates", update)
|
||||||
|
else:
|
||||||
|
remove("nsz/updates", update)
|
||||||
|
Loading…
Reference in New Issue
Block a user