506 parser = argparse.ArgumentParser(description=__doc__)
508 parser.add_argument(
"InputDirs", nargs=
"*", action=
"store",
509 help=
"input directories [current]")
511 parser.add_argument(
'--doit', dest=
"DoIt", action=
'store_true',
512 help=
"perform the substitutions [%(default)s]")
514 parser.add_argument(
'--verbose',
'-v', dest=
"DoVerbose", action=
'store_true',
515 help=
"shows all the changes on screen [%(default)s]")
516 parser.add_argument(
'--debug', dest=
"DoDebug", action=
'store_true',
517 help=
"enables debug messages on screen")
518 parser.add_argument(
'--color',
'-U', dest=
"UseColor", action=
'store_true',
519 help=
"enables coloured output [%(default)s]")
521 parser.add_argument(
'--list', dest=
"DoList", action=
'store_true',
522 help=
"just prints the hard-coded substitutions for each processor")
523 parser.add_argument(
'--only', dest=
"SelectedProcessors", action=
'append',
524 help=
"executes only the processors with the specified name (see --list)")
525 parser.add_argument(
'--version', action=
'version',
526 version=
'%(prog)s ' + __version__)
528 arguments = parser.parse_args()
531 LoggingSetup(logging.DEBUG
if arguments.DoDebug
else logging.INFO)
533 if arguments.DoVerbose: arguments.LogMsg = logging.info
534 else: arguments.LogMsg = logging.debug
536 Processors = ProcessorsList.Global
538 Processors.SetOptions(arguments)
539 Processors.SetColors(
540 old=ANSIRed, new=ANSIGreen, source=ANSIWhite, line_no=ANSIMagenta,
543 if arguments.SelectedProcessors:
544 Processors.SelectProcessors(arguments.SelectedProcessors)
547 logging.info(
"\n".join(Processors.Describe()))
552 if not arguments.InputDirs: arguments.InputDirs = [
'.' ]
554 for InputPath
in arguments.InputDirs:
555 Processors.ProcessDir(InputPath)
def LoggingSetup(LoggingLevel=logging.INFO)