All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions | Variables
SerialSubstitution Namespace Reference

Classes

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

Functions

def ANSIcode
 
def Colorize
 Library code. More...
 
def AddProcessor
 
def LoggingSetup
 
def RunSubstitutor
 

Variables

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

Function Documentation

def SerialSubstitution.AddProcessor (   processor)

Definition at line 489 of file SerialSubstitution.py.

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

Definition at line 19 of file SerialSubstitution.py.

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

Library code.

Definition at line 33 of file SerialSubstitution.py.

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

Definition at line 493 of file SerialSubstitution.py.

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

Definition at line 503 of file SerialSubstitution.py.

504 def RunSubstitutor():
505  import argparse
506 
507  parser = argparse.ArgumentParser(description=__doc__)
508 
509  parser.add_argument("InputDirs", nargs="*", action="store",
510  help="input directories [current]")
511 
512  parser.add_argument('--doit', dest="DoIt", action='store_true',
513  help="perform the substitutions [%(default)s]")
514 
515  parser.add_argument('--verbose', '-v', dest="DoVerbose", action='store_true',
516  help="shows all the changes on screen [%(default)s]")
517  parser.add_argument('--debug', dest="DoDebug", action='store_true',
518  help="enables debug messages on screen")
519  parser.add_argument('--color', '-U', dest="UseColor", action='store_true',
520  help="enables coloured output [%(default)s]")
521 
522  parser.add_argument('--list', dest="DoList", action='store_true',
523  help="just prints the hard-coded substitutions for each processor")
524  parser.add_argument('--only', dest="SelectedProcessors", action='append',
525  help="executes only the processors with the specified name (see --list)")
526  parser.add_argument('--version', action='version',
527  version='%(prog)s ' + __version__)
528 
529  arguments = parser.parse_args()
530 
531  # set up the logging system
532  LoggingSetup(logging.DEBUG if arguments.DoDebug else logging.INFO)
533 
534  if arguments.DoVerbose: arguments.LogMsg = logging.info
535  else: arguments.LogMsg = logging.debug
536 
537  Processors = ProcessorsList.Global # use the global list
538 
539  Processors.SetOptions(arguments)
540  Processors.SetColors(
541  old=ANSIRed, new=ANSIGreen, source=ANSIWhite, line_no=ANSIMagenta,
542  warning=ANSIYellow
543  )
544  if arguments.SelectedProcessors:
545  Processors.SelectProcessors(arguments.SelectedProcessors)
546 
547  if arguments.DoList:
548  logging.info("\n".join(Processors.Describe()))
549  sys.exit(0)
550  # if
551 
552 
553  if not arguments.InputDirs: arguments.InputDirs = [ '.' ]
554 
555  for InputPath in arguments.InputDirs:
556  Processors.ProcessDir(InputPath)
557 
558  return 0
559 # RunSubstitutor()
560 
S join(S const &sep, Coll const &s)
Returns a concatenation of strings in s separated by sep.

Variable Documentation

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

Definition at line 10 of file SerialSubstitution.py.

string SerialSubstitution.__version__ = '2.0'

Definition at line 11 of file SerialSubstitution.py.

tuple SerialSubstitution.ANSIBlue = ANSIcode("34")

Definition at line 24 of file SerialSubstitution.py.

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

Definition at line 25 of file SerialSubstitution.py.

tuple SerialSubstitution.ANSIGreen = ANSIcode("32")

Definition at line 23 of file SerialSubstitution.py.

tuple SerialSubstitution.ANSIMagenta = ANSIcode("35")

Definition at line 26 of file SerialSubstitution.py.

tuple SerialSubstitution.ANSIRed = ANSIcode("31")

Definition at line 22 of file SerialSubstitution.py.

tuple SerialSubstitution.ANSIReset = ANSIcode("0")

Definition at line 21 of file SerialSubstitution.py.

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

Definition at line 28 of file SerialSubstitution.py.

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

Definition at line 27 of file SerialSubstitution.py.

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

Test.

Definition at line 567 of file SerialSubstitution.py.