# HG changeset patch # User David Barts # Date 1577420672 28800 # Node ID d5198c7ec54dddeb19c1411f6a9d997d5b773fdc # Parent 7a83e82e65a6062edd68bdf2971a68778e3f8ccb Add --uncurl option. diff -r 7a83e82e65a6 -r d5198c7ec54d curlyq --- a/curlyq Thu Dec 26 20:04:04 2019 -0800 +++ b/curlyq Thu Dec 26 20:24:32 2019 -0800 @@ -57,13 +57,20 @@ curler.feed() output_fp.write(ws.getvalue()) +def do_uncurl(): + global input_fp, output_fp + with Workspace(input_fp.read()) as ws: + uncurl(ws) + output_fp.write(ws.getvalue()) + # M a i n P r o g r a m # Parse arguments -parser = argparse.ArgumentParser(description='Source code character checker.', prog=MYNAME) +parser = argparse.ArgumentParser(description='Make straight quotes curly.', prog=MYNAME) group = parser.add_mutually_exclusive_group() group.add_argument("--flowed", action="store_true", help="Input is flowed text.") group.add_argument("--html", action="store_true", help="Input is HTML.") +group.add_argument("--uncurl", action="store_true", help="Uncurl quotes instead of curling them.") parser.add_argument("--force", action="store_true", help="Force all quotes to straight ones first.") parser.add_argument("--icoding", default="UTF-8", help="Input encoding.") parser.add_argument("--inplace", action="store_true", help="Edit file in-place.") @@ -92,7 +99,7 @@ if args.input and (not args.output) and args.inplace: args.output = args.input args.input += "~" - os.rename(args.input, args.output) + os.rename(args.output, args.input) if args.input: input_fp = open(args.input, "r", encoding=args.icoding) else: @@ -110,5 +117,7 @@ flowed() elif args.html: html() +elif args.uncurl: + do_uncurl() else: normal()