Remove .absolute_path thanks to fspath.

This commit is contained in:
voussoir 2021-12-02 19:34:28 -08:00
parent e9e1f5930c
commit 8c9588497c
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
9 changed files with 12 additions and 12 deletions

View file

@ -115,7 +115,7 @@ def loop(pairs, dry=False):
line = f'{old.absolute_path}\n{new.absolute_path}\n'
safeprint.safeprint(line)
else:
os.rename(old.absolute_path, new.absolute_path)
os.rename(old, new)
def brename_argparse(args):
return brename(

View file

@ -9,10 +9,10 @@ def main(argv):
for path in pathclass.glob_many(pipeable.go(argv, skip_blank=True)):
if path.is_file:
pipeable.stdout(path.absolute_path)
os.remove(path.absolute_path)
os.remove(path)
elif path.is_dir:
pipeable.stdout(path.absolute_path)
shutil.rmtree(path.absolute_path)
shutil.rmtree(path)
return 0
if __name__ == '__main__':

View file

@ -21,5 +21,5 @@ for path in pathclass.glob_many(argv):
newname = str(randname).rjust(12, '0') + path.dot_extension
randname += 1
newname = path.parent.with_child(newname)
os.rename(path.absolute_path, newname.absolute_path)
os.rename(path, newname)
print('%s -> %s' % (path.absolute_path, newname.basename))

View file

@ -16,5 +16,5 @@ for path in pathclass.glob_many(argv):
newname = [random.choice(string.ascii_lowercase) for x in range(9)]
newname = ''.join(newname) + path.dot_extension
newname = path.parent.with_child(newname)
os.rename(path.absolute_path, newname.absolute_path)
os.rename(path, newname)
print('%s -> %s' % (path.absolute_path, newname.basename))

View file

@ -16,5 +16,5 @@ for path in pathclass.glob_many(argv):
newname = [random.choice(string.digits) for x in range(12)]
newname = ''.join(newname) + path.dot_extension
newname = path.parent.with_child(newname)
os.rename(path.absolute_path, newname.absolute_path)
os.rename(path, newname)
print('%s -> %s' % (path.absolute_path, newname.basename))

View file

@ -38,7 +38,7 @@ def filepull(pull_from='.', autoyes=False):
if autoyes or interactive.getpermission(f'Move {len(files)} files?'):
for f in files:
local = os.path.join('.', f.basename)
os.rename(f.absolute_path, local)
os.rename(f, local)
def filepull_argparse(args):
filepull(pull_from=args.pull_from, autoyes=args.autoyes)

View file

@ -24,7 +24,7 @@ def inputrename_argparse(args):
if this:
new_name = file.basename.replace(args.keyword, this)
new_name = file.parent.with_child(new_name)
os.rename(file.absolute_path, new_name.absolute_path)
os.rename(file, new_name)
prev = this
return 0

View file

@ -7,7 +7,7 @@ from voussoirkit import pipeable
def main(argv):
for path in pathclass.glob_many(pipeable.go(argv, skip_blank=True)):
pipeable.stdout(path.absolute_path)
send2trash.send2trash(path.absolute_path)
send2trash.send2trash(path)
return 0
if __name__ == '__main__':

View file

@ -43,14 +43,14 @@ def sole_lift_argparse(args):
# to lift don't have name conflicts with the child dir itself.
# Consider .\abc\abc where the grandchild can't be moved.
temp_dir = directory.with_child(passwordy.urandom_hex(32))
os.rename(child.absolute_path, temp_dir.absolute_path)
os.rename(child, temp_dir)
for grandchild in temp_dir.listdir():
shutil.move(grandchild.absolute_path, directory.absolute_path)
shutil.move(grandchild, directory)
if temp_dir.listdir():
raise Exception()
os.rmdir(temp_dir.absolute_path)
os.rmdir(temp_dir)
queue.append(directory.parent)
return 0