Classes | Functions | Variables
SerialSubstitution Namespace Reference

Classes

class  ContextClass
 
class  LineNoContextClass
 
class  ProcessorClass
 
class  ProcessorsList
 
class  RegExDeleteLineClass
 
class  RegExSubstitutionClass
 
class  ReplacementClass
 
class  SubstitutionClass
 
class  WarningClass
 

Functions

def ANSIcode (content)
 
def Colorize (msg, category, options)
 Library code. More...
 
def AddProcessor (processor)
 
def LoggingSetup (LoggingLevel=logging.INFO)
 
def RunSubstitutor ()
 

Variables

string __doc__ = "Performs hard-coded substitutions on all files in a directory."
 
string __version__ = '2.0'
 
 ANSIReset = ANSIcode("0")
 
 ANSIRed = ANSIcode("31")
 
 ANSIGreen = ANSIcode("32")
 
 ANSIBlue = ANSIcode("34")
 
 ANSIBrightBlue = ANSIcode("1;34")
 
 ANSIMagenta = ANSIcode("35")
 
 ANSIYellow = ANSIcode("1;33")
 
 ANSIWhite = ANSIcode("1;37")
 
 subst = AddProcessor(ProcessorClass("subst"))
 Test. More...
 

Function Documentation

def SerialSubstitution.AddProcessor (   processor)

Definition at line 489 of file SerialSubstitution.py.

489 def AddProcessor(processor):
490  return ProcessorsList.Global.AddProcessor(processor)
491 
492 
def AddProcessor(processor)
def SerialSubstitution.ANSIcode (   content)

Definition at line 19 of file SerialSubstitution.py.

19 def ANSIcode(content): return "\x1B[" + content + "m"
20 
def SerialSubstitution.Colorize (   msg,
  category,
  options 
)

Library code.

Definition at line 33 of file SerialSubstitution.py.

33 def Colorize(msg, category, options):
34  if not options or not options.UseColor: return str(msg)
35  return options.Colors.get(category, "") + str(msg) + ANSIReset
36 # Colorize()
37 
38 
def Colorize(msg, category, options)
Library code.
static QCString str
def SerialSubstitution.LoggingSetup (   LoggingLevel = logging.INFO)

Definition at line 493 of file SerialSubstitution.py.

493 def LoggingSetup(LoggingLevel = logging.INFO):
494 
495  logging.basicConfig(
496  level=LoggingLevel,
497  format="%(levelname)s: %(message)s"
498  )
499 
500 # def LoggingSetup()
501 
def LoggingSetup(LoggingLevel=logging.INFO)
def SerialSubstitution.RunSubstitutor ( )

Definition at line 503 of file SerialSubstitution.py.

504  import argparse
505 
506  parser = argparse.ArgumentParser(description=__doc__)
507 
508  parser.add_argument("InputDirs", nargs="*", action="store",
509  help="input directories [current]")
510 
511  parser.add_argument('--doit', dest="DoIt", action='store_true',
512  help="perform the substitutions [%(default)s]")
513 
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]")
520 
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__)
527 
528  arguments = parser.parse_args()
529 
530  # set up the logging system
531  LoggingSetup(logging.DEBUG if arguments.DoDebug else logging.INFO)
532 
533  if arguments.DoVerbose: arguments.LogMsg = logging.info
534  else: arguments.LogMsg = logging.debug
535 
536  Processors = ProcessorsList.Global # use the global list
537 
538  Processors.SetOptions(arguments)
539  Processors.SetColors(
540  old=ANSIRed, new=ANSIGreen, source=ANSIWhite, line_no=ANSIMagenta,
541  warning=ANSIYellow
542  )
543  if arguments.SelectedProcessors:
544  Processors.SelectProcessors(arguments.SelectedProcessors)
545 
546  if arguments.DoList:
547  logging.info("\n".join(Processors.Describe()))
548  sys.exit(0)
549  # if
550 
551 
552  if not arguments.InputDirs: arguments.InputDirs = [ '.' ]
553 
554  for InputPath in arguments.InputDirs:
555  Processors.ProcessDir(InputPath)
556 
557  return 0
558 # RunSubstitutor()
559 
560 
def LoggingSetup(LoggingLevel=logging.INFO)

Variable Documentation

string SerialSubstitution.__doc__ = "Performs hard-coded substitutions on all files in a directory."
private

Definition at line 10 of file SerialSubstitution.py.

string SerialSubstitution.__version__ = '2.0'
private

Definition at line 11 of file SerialSubstitution.py.

SerialSubstitution.ANSIBlue = ANSIcode("34")

Definition at line 24 of file SerialSubstitution.py.

SerialSubstitution.ANSIBrightBlue = ANSIcode("1;34")

Definition at line 25 of file SerialSubstitution.py.

SerialSubstitution.ANSIGreen = ANSIcode("32")

Definition at line 23 of file SerialSubstitution.py.

SerialSubstitution.ANSIMagenta = ANSIcode("35")

Definition at line 26 of file SerialSubstitution.py.

SerialSubstitution.ANSIRed = ANSIcode("31")

Definition at line 22 of file SerialSubstitution.py.

SerialSubstitution.ANSIReset = ANSIcode("0")

Definition at line 21 of file SerialSubstitution.py.

SerialSubstitution.ANSIWhite = ANSIcode("1;37")

Definition at line 28 of file SerialSubstitution.py.

SerialSubstitution.ANSIYellow = ANSIcode("1;33")

Definition at line 27 of file SerialSubstitution.py.

SerialSubstitution.subst = AddProcessor(ProcessorClass("subst"))

Test.

Definition at line 567 of file SerialSubstitution.py.