Implement --check option
This commit is contained in:
parent
cac52effa8
commit
0d696114b2
19
cli.py
19
cli.py
@ -35,6 +35,11 @@ if __name__ == '__main__':
|
|||||||
'--funky', '-f', action='store_true',
|
'--funky', '-f', action='store_true',
|
||||||
help='List filenames with special characters'
|
help='List filenames with special characters'
|
||||||
)
|
)
|
||||||
|
mgroup.add_argument(
|
||||||
|
'--check', '-c', action='store_true',
|
||||||
|
help='Check whether a name is normalised or not'
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'files', type=str, nargs='+',
|
'files', type=str, nargs='+',
|
||||||
help='File(s) to normalise the name of (relative or absolute path).'
|
help='File(s) to normalise the name of (relative or absolute path).'
|
||||||
@ -59,14 +64,24 @@ if __name__ == '__main__':
|
|||||||
whitelist = whitelist.difference(set(args.disallow))
|
whitelist = whitelist.difference(set(args.disallow))
|
||||||
|
|
||||||
# define operations
|
# define operations
|
||||||
listchanges = lambda a, b: print('{}{} --> {}'.format(a, ' '*(60-len(a)), b))
|
def listchanges(before, after):
|
||||||
listfunky = lambda a, b: print(a)
|
print(f'{after}{" "*(60-len(after))} --> {before}')
|
||||||
|
|
||||||
|
def listfunky(before, _):
|
||||||
|
print(before)
|
||||||
|
|
||||||
|
def checkname(before, after):
|
||||||
|
if before != after:
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
operation = rename
|
operation = rename
|
||||||
if args.dryrun:
|
if args.dryrun:
|
||||||
operation = listchanges
|
operation = listchanges
|
||||||
elif args.funky:
|
elif args.funky:
|
||||||
operation = listfunky
|
operation = listfunky
|
||||||
|
elif args.check:
|
||||||
|
operation = checkname
|
||||||
|
|
||||||
# do what needs to be done
|
# do what needs to be done
|
||||||
Normalisename(operation, args.separator, whitelist)(args.files)
|
Normalisename(operation, args.separator, whitelist)(args.files)
|
||||||
|
Loading…
Reference in New Issue
Block a user