|
def | __init__ (self, name) |
|
def | SetOptions (self, options) |
|
def | SetColors (self, colors) |
|
def | Color (self, msg, category) |
|
def | RecordPattern (self, pattern) |
|
def | AddFilePattern (self, pattern) |
|
def | AddFileNamePattern (self, name_pattern) |
|
def | AddFileType (self, suffixes) |
|
def | AddRegExPattern (self, pattern, repl, exceptions=[]) |
|
def | AddRegExRemoveLine (self, pattern, exceptions=[]) |
|
def | AddSimplePattern (self, pattern, repl, exceptions=[]) |
|
def | AddWord (self, word, repl, exceptions=[]) |
|
def | AddWarningPattern (self, pattern, msg, exceptions=[]) |
|
def | AddPattern (self, pattern, repl, exceptions=[]) |
|
def | MatchFile (self, FilePath) |
|
def | SubstituteLine (self, line, context=None) |
|
def | ProcessFile (self, FilePath) |
|
def | ProcessFiles (self, files) |
|
def | ProcessDir (self, DirPath) |
|
def | __str__ (self) |
|
def | Describe (self) |
|
Definition at line 193 of file SerialSubstitution.py.
def SerialSubstitution.ProcessorClass.__init__ |
( |
|
self, |
|
|
|
name |
|
) |
| |
Supported keyword arguments: "options"
Definition at line 194 of file SerialSubstitution.py.
195 """Supported keyword arguments: "options"
def SerialSubstitution.ProcessorClass.__str__ |
( |
|
self | ) |
|
def SerialSubstitution.ProcessorClass.AddFileNamePattern |
( |
|
self, |
|
|
|
name_pattern |
|
) |
| |
Definition at line 229 of file SerialSubstitution.py.
def AddFileNamePattern(self, name_pattern)
def AddFilePattern(self, pattern)
def SerialSubstitution.ProcessorClass.AddFilePattern |
( |
|
self, |
|
|
|
pattern |
|
) |
| |
Definition at line 222 of file SerialSubstitution.py.
223 if not pattern.endswith(
'$'): pattern +=
"$" 224 match = re.compile(pattern)
225 self.file_filters.append(match)
def AddFilePattern(self, pattern)
def SerialSubstitution.ProcessorClass.AddFileType |
( |
|
self, |
|
|
|
suffixes |
|
) |
| |
Definition at line 232 of file SerialSubstitution.py.
def AddFileType(self, suffixes)
def AddFileNamePattern(self, name_pattern)
def SerialSubstitution.ProcessorClass.AddPattern |
( |
|
self, |
|
|
|
pattern, |
|
|
|
repl, |
|
|
|
exceptions = [] |
|
) |
| |
Definition at line 261 of file SerialSubstitution.py.
def AddPattern(self, pattern, repl, exceptions=[])
def AddRegExPattern(self, pattern, repl, exceptions=[])
def SerialSubstitution.ProcessorClass.AddRegExPattern |
( |
|
self, |
|
|
|
pattern, |
|
|
|
repl, |
|
|
|
exceptions = [] |
|
) |
| |
Definition at line 238 of file SerialSubstitution.py.
def RecordPattern(self, pattern)
def AddRegExPattern(self, pattern, repl, exceptions=[])
def SerialSubstitution.ProcessorClass.AddRegExRemoveLine |
( |
|
self, |
|
|
|
pattern, |
|
|
|
exceptions = [] |
|
) |
| |
Definition at line 243 of file SerialSubstitution.py.
def AddRegExRemoveLine(self, pattern, exceptions=[])
def RecordPattern(self, pattern)
def SerialSubstitution.ProcessorClass.AddSimplePattern |
( |
|
self, |
|
|
|
pattern, |
|
|
|
repl, |
|
|
|
exceptions = [] |
|
) |
| |
Definition at line 248 of file SerialSubstitution.py.
def AddSimplePattern(self, pattern, repl, exceptions=[])
def RecordPattern(self, pattern)
def SerialSubstitution.ProcessorClass.AddWarningPattern |
( |
|
self, |
|
|
|
pattern, |
|
|
|
msg, |
|
|
|
exceptions = [] |
|
) |
| |
Definition at line 256 of file SerialSubstitution.py.
def AddWarningPattern(self, pattern, msg, exceptions=[])
def RecordPattern(self, pattern)
def SerialSubstitution.ProcessorClass.AddWord |
( |
|
self, |
|
|
|
word, |
|
|
|
repl, |
|
|
|
exceptions = [] |
|
) |
| |
Definition at line 253 of file SerialSubstitution.py.
253 def AddWord(self, word, repl, exceptions = []):
def AddWord(self, word, repl, exceptions=[])
def AddRegExPattern(self, pattern, repl, exceptions=[])
def SerialSubstitution.ProcessorClass.Color |
( |
|
self, |
|
|
|
msg, |
|
|
|
category |
|
) |
| |
def SerialSubstitution.ProcessorClass.CreateTempFile |
( |
|
FilePath | ) |
|
|
static |
Definition at line 419 of file SerialSubstitution.py.
420 TempPath = os.path.join(
421 tempfile.gettempdir(),
422 tempfile.gettempprefix() +
"-" + os.path.basename(FilePath) +
".tmp" 424 TempFile =
open(TempPath,
'w')
int open(const char *, int)
Opens a file descriptor.
def CreateTempFile(FilePath)
def SerialSubstitution.ProcessorClass.Describe |
( |
|
self | ) |
|
Definition at line 404 of file SerialSubstitution.py.
406 "Processor '%s' applies %d substitutions" % (self, len(self.
patterns))
409 try: output.append(
" " + subst.Describe())
410 except AttributeError:
411 output.append(
" " +
str(subst))
413 output.append(
" " + repr(subst))
def SerialSubstitution.ProcessorClass.MatchFile |
( |
|
self, |
|
|
|
FilePath |
|
) |
| |
Definition at line 265 of file SerialSubstitution.py.
268 if pattern.match(FilePath)
is None:
continue
def MatchFile(self, FilePath)
def SerialSubstitution.ProcessorClass.ProcessDir |
( |
|
self, |
|
|
|
DirPath |
|
) |
| |
Returns the number of files processor actually acted on
Definition at line 369 of file SerialSubstitution.py.
370 """Returns the number of files processor actually acted on""" 372 if os.path.isdir(DirPath):
373 for dirpath, dirnames, filenames
in os.walk(DirPath):
375 = [ os.path.join(dirpath, filename)
for filename
in filenames ]
378 logging.debug(
" processor '%s' changed %d files in '%s'",
379 self.
name, nChanged, dirpath
385 ApplyChangesMsg =
"changed" if self.options.DoIt
else "would change" 386 logging.info(
"Processor '%s' %s %d files in '%s'",
387 self.
name, ApplyChangesMsg, nActions, DirPath
392 ApplyChangesMsg =
"changed" if self.options.DoIt
else "would change" 393 logging.info(
"Processor '%s' %s file '%s'",
394 self.
name, ApplyChangesMsg, DirPath
def ProcessFile(self, FilePath)
def ProcessDir(self, DirPath)
def ProcessFiles(self, files)
def SerialSubstitution.ProcessorClass.ProcessFile |
( |
|
self, |
|
|
|
FilePath |
|
) |
| |
Returns whether substitutions were performed
Definition at line 309 of file SerialSubstitution.py.
310 """Returns whether substitutions were performed""" def ProcessFile(self, FilePath)
def SerialSubstitution.ProcessorClass.ProcessFiles |
( |
|
self, |
|
|
|
files |
|
) |
| |
Definition at line 361 of file SerialSubstitution.py.
363 for FilePath
in files:
def ProcessFile(self, FilePath)
def ProcessFiles(self, files)
def SerialSubstitution.ProcessorClass.RecordPattern |
( |
|
self, |
|
|
|
pattern |
|
) |
| |
Definition at line 216 of file SerialSubstitution.py.
217 pattern.SetOptions(self.
options)
218 self.patterns.append(pattern)
def RecordPattern(self, pattern)
def SerialSubstitution.ProcessorClass.SetColors |
( |
|
self, |
|
|
|
colors |
|
) |
| |
Definition at line 209 of file SerialSubstitution.py.
210 try: self.options.Colors.update(colors)
211 except AttributeError: self.options.Colors = colors
def SetColors(self, colors)
def SerialSubstitution.ProcessorClass.SetOptions |
( |
|
self, |
|
|
|
options |
|
) |
| |
def SerialSubstitution.ProcessorClass.SubstituteLine |
( |
|
self, |
|
|
|
line, |
|
|
|
context = None |
|
) |
| |
Returns the very same string if the new line is the same as the old one
or a list of lines to replace line with
Definition at line 275 of file SerialSubstitution.py.
276 """Returns the very same string if the new line is the same as the old one 277 or a list of lines to replace line with 279 if line
is None:
return line
282 new_line =
subst(line, context)
283 if new_line
is line:
continue 285 msg =
" pattern '%s' matched" % subst
286 if context
is not None: msg +=
" at %s" % context
288 if isinstance(new_line, str):
289 msg +=
"\n OLD| " + self.
Color(line.rstrip(
'\n'),
'old')
290 msg +=
"\n NEW| %s" % self.
Color(new_line.rstrip(
'\n'),
'new')
292 msg +=
"\n DEL| %s" % self.
Color(line.rstrip(
'\n'),
'old')
294 msg +=
"\n OLD| " + self.
Color(line.rstrip(
'\n'),
'old')
296 msg +=
"\n NEW| %s" % self.
Color(l.rstrip(
'\n'),
'new')
298 self.options.LogMsg(msg)
302 if not isinstance(new_line, str):
return new_line
def SubstituteLine(self, line, context=None)
def Color(self, msg, category)
list SerialSubstitution.ProcessorClass.Content = [] |
|
static |
SerialSubstitution.ProcessorClass.file_filters |
SerialSubstitution.ProcessorClass.name |
int SerialSubstitution.ProcessorClass.nChanges = 0 |
|
static |
SerialSubstitution.ProcessorClass.new_line = self.SubstituteLine(line, context) |
|
static |
SerialSubstitution.ProcessorClass.options |
SerialSubstitution.ProcessorClass.patterns |
SerialSubstitution.ProcessorClass.SourceFile = open(FilePath, 'r') |
|
static |
The documentation for this class was generated from the following file: