Commit d4ebf768 authored by Michael Murtaugh's avatar Michael Murtaugh
Browse files

cleanup

parent 8749c227
......@@ -515,14 +515,14 @@ def main():
from . import template
template.add_subparser(subparsers)
from . import jsonaddkeyvalue
jsonaddkeyvalue.add_subparser(subparsers)
# from . import jsonaddkeyvalue
# jsonaddkeyvalue.add_subparser(subparsers)
from . import jsonmerge
jsonmerge.add_subparser(subparsers)
# from . import jsonmerge
# jsonmerge.add_subparser(subparsers)
from . import jsoncountkeys
jsoncountkeys.add_subparser(subparsers)
# from . import jsoncountkeys
# jsoncountkeys.add_subparser(subparsers)
from . import smake
smake.add_subparser(subparsers)
......
#!/usr/bin/env python3
import sys, subprocess, os
from ftfy import fix_text
def main (args):
for base, dirs, files in os.walk(args.path):
dirs[:] = [x for x in dirs if not x.startswith(".")]
for f in files:
fp = os.path.join(base, f)
try:
fb = fp.encode("utf-8")
except UnicodeEncodeError as e:
fp_new = fix_text(fp)
if args.rename:
os.rename(fp, fp_new)
print (f"RENAMED {fp_new}")
else:
print (f"BAD {fp_new}")
# print (f)
def add_subparser (subparsers):
p = subparsers.add_parser('fixfilenames', help='Detect & optionally rename problematic utf-8 filenames (remove surrogates)')
p.add_argument('--rename', action="store_true", default=False)
p.add_argument('path', nargs="?", default=".")
p.set_defaults(func=main)
if __name__ == "__main__":
from argparse import ArgumentParser
p = argparse.ArgumentParser("")
subparsers = p.add_subparsers(help="subcommands")
add_subparser(subparsers)
main(p.parse_args(args=(["fixfilenames"] + sys.argv[1:])))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment