You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1 +1 @@-gzip compressed data, was "VisioNomicon-0.1.1.tar", last modified: Tue Jan 2 20:36:47 2024, max compression+gzip compressed data, was "VisioNomicon-0.1.2.tar", last modified: Fri Jan 5 23:55:56 2024, max compression
@@ -19,34 +19,34 @@
if args.files is not None:
new_filepaths: list[str] = generate_mapping(args)
# have new and old, put them together into a json and save
save_mapping(args, new_filepaths)
# if executing or undoing
- if args.undo is not None or args.execute is not None:- arg = args.execute if args.execute is not None else args.undo- mapping_fp = get_mapping_name(arg)-- og_filepaths: list[str] = []- new_filepaths: list[str] = []-- with open(mapping_fp) as f:- data = json.load(f)- og_filepaths += list(data.keys())- new_filepaths += list(data.values())-- from_fps = og_filepaths if args.execute is not None else new_filepaths- to_fps = new_filepaths if args.execute is not None else og_filepaths-- for i in range(len(from_fps)):- _, filename = os.path.split(to_fps[i])- print("Renaming {} to {}".format(from_fps[i], '.../' + filename))- os.rename(from_fps[i], to_fps[i])-+ if args.undo or args.execute:+ rel_mapping_fp = args.execute if args.execute else args.undo+ rename_from_mapping(rel_mapping_fp, args.undo is not None)++def rename_from_mapping(rel_mapping_fp: str, undo: bool = False):+ mapping_fp = get_mapping_name(rel_mapping_fp)+ og_filepaths: list[str] = []+ new_filepaths: list[str] = []++ with open(mapping_fp) as f:+ data = json.load(f)+ og_filepaths += list(data.keys())+ new_filepaths += list(data.values())++ from_fps, to_fps = (new_filepaths, og_filepaths) if undo else (og_filepaths, new_filepaths)++ for i in range(len(from_fps)):+ _, filename = os.path.split(to_fps[i])+ print("Renaming {} to {}".format(from_fps[i], '.../' + filename))+ os.rename(from_fps[i], to_fps[i])
def get_mapping_name(cli_fp: str):
if cli_fp != NO_VAL:
return cli_fp
else:
# Join the directory with the file pattern
file_pattern = os.path.join(DATA_DIR, '*.json')
@@ -64,15 +64,15 @@
# data ready to dump, need to get mapping filename
mapping_filename = generate_mapping_name(args)
with open(mapping_filename, 'w') as file:
json.dump(data, file, indent=4)
def generate_mapping_name(args) -> str:
- return args.output if args.output else DATA_DIR + datetime.now().strftime("mapping-%Y-%m-%d-%H-%M-%S.json")+ return args.output if args.output != NO_VAL else DATA_DIR + datetime.now().strftime("mapping-%Y-%m-%d-%H-%M-%S.json")
def generate_mapping(args) -> list[str]:
og_filepaths: list[str] = args.files
new_filepaths: list[str] = copy.deepcopy(og_filepaths)
for i in range(len(new_filepaths)):
slicepoint = new_filepaths[i].rindex("/") + 1