help='Add more messages (repeatable).') parser.add_argument("--version", action='version', version=__version__, help='Display version information, then exit.') parser.add_argument('files', type=str, nargs=argparse.REMAINDER, help='Path(s) to input file(s)') args0 = parser.parse_args() lg.setVerbose(args0.verbose) return (args0) args = processOptions() if (len(args.files) == 0): lg.error("No files specified....") sys.exit() for f in (args.files): lg.bumpStat("totalFiles") recs = doOneFile(f) lg.bumpStat("totalRecords", amount=recs) if (not args.quiet): lg.vMsg(0, "Done.") lg.showStats()
########################################################################### # Main # args = processOptions() lg = ALogger(1) if (args.all): args.backups = args.hidden = True if (not args.color): args.color = ("USE_COLOR" in os.environ and sys.stderr.isatty()) lg.setColors(args.color) if (not (args.size or args.time or args.md5 or args.diff)): lg.vMsg(0, "No file comparisons specified (--size --time --md5 --diff)") if ("COLUMNS" in os.environ): wid = os.environ["COLUMNS"] else: wid = 80 totalRecords = 0 totalFiles = 0 if ("COLUMNS" in os.environ): wid = int(os.environ["COLUMNS"]) else: lg.vMsg(0, "Can't find environment variable COLUMNS -- export it?") wid = 80 if (len(args.dirs) != 2 or not os.path.isdir(args.dirs[0]) or not os.path.isdir(args.dirs[1])):
B<bold> and C<command> and E<bull> and F<filename> and I<italic> and L<link> and S<no-break> and X<index entry> and Z<No I<POD> in here>. =cut """ ########################################################################### # args = processOptions() if (args.test): tfile = "/tmp/pod2mdSample.pod" with codecs.open(tfile, "wb", encoding="utf-8") as tf: tf.write(sample) lg.vMsg(0, "Test data written to %s." % (tfile)) args.files.insert(0, tfile) if (args.extractTo): xfh = codecs.open(args.extractTo, "wb", encoding=args.oencoding) if (len(args.files) == 0): lg.error("No files specified....") doOneFile("[STDIN]", sys.stdin) else: pw = PowerWalk.PowerWalk(args.files, open=True, close=True, encoding=args.oencoding) pw.setOption("recursive", False) for path0, fh0, typ in pw.traverse():
if (args.oformat == 'xml'): buf = serialize2xml(pyObject0, istring=args.istring) elif (args.oformat == 'json'): buf = json.dumps(pyObject0, sort_keys=args.sortkeys, indent=len(args.istring)) elif (args.oformat == 'report'): buf = lg.formatRec(pyObject0) else: lg.vMsg(-1, "Unknown --oformat value '%s'." % (args.oformat)) print(buf) return ########################################################################### # args = processOptions() if (len(args.files) == 0): lg.vMsg(0, "json2xml.py: No files specified....") doOneFile(None) else: pw = PowerWalk(args.files, open=False, close=False, encoding=args.iencoding) pw.setOptionsFromArgparse(args) for path0, fh0, what0 in pw.traverse(): if (what0 != PWType.LEAF): continue doOneFile(path0)