fix: folders ending in /

This commit is contained in:
zx
2024-09-13 18:27:45 -04:00
parent 52b3b11a1a
commit 55b2ec9d07

View File

@@ -39,15 +39,19 @@ def validate_inputs(args: Namespace) -> Optional[str]:
sys.exit(0) sys.exit(0)
if args.f is not None: if args.f is not None:
# dictionary ensures unique names new: dict[str, str] = {} # dictionary ensures unique names
args.f = {os.path.basename(f): os.path.realpath(f) for f in args.f}
nonexistent = [f for f in args.f.values() if not os.path.exists(f)]
if len(nonexistent) != 0: for f in list(args.f):
print("[!] please ensure the following file(s) exist:") if f[-1] == "/": # yeah this is stupid
for ne in nonexistent: f = f[:-1]
print(f"[?] - {ne}")
sys.exit(1) if not os.path.exists(f):
sys.exit(f"[!] \"{f}\" does not exist")
new[os.path.basename(f)] = os.path.realpath(f)
# i would've modified args.f directly, but it causes type-hinting error :(
args.f = new
if ( if (
args.m is not None args.m is not None