Public Member Functions | Public Attributes | List of all members
SerialSubstitution.RegExSubstitutionClass Class Reference
Inheritance diagram for SerialSubstitution.RegExSubstitutionClass:
SerialSubstitution.SubstitutionClass

Public Member Functions

def __init__ (self, match, replacement, exceptions=[])
 
def __str__ (self)
 
def __call__ (self, s, context=None)
 
def Describe (self)
 
- Public Member Functions inherited from SerialSubstitution.SubstitutionClass
def __init__ (self)
 
def SetOptions (self, options)
 
def __str__ (self)
 
def __call__ (self, s, context=None)
 
def describe (self)
 

Public Attributes

 regex
 
 repl
 
 exceptions
 
- Public Attributes inherited from SerialSubstitution.SubstitutionClass
 options
 

Detailed Description

Definition at line 83 of file SerialSubstitution.py.

Constructor & Destructor Documentation

def SerialSubstitution.RegExSubstitutionClass.__init__ (   self,
  match,
  replacement,
  exceptions = [] 
)

Definition at line 84 of file SerialSubstitution.py.

84  def __init__(self, match, replacement, exceptions = []):
85  SubstitutionClass.__init__(self)
86  self.regex = re.compile(match)
87  self.repl = replacement
88  self.exceptions = list(map(re.compile, exceptions))
def __init__(self, match, replacement, exceptions=[])

Member Function Documentation

def SerialSubstitution.RegExSubstitutionClass.__call__ (   self,
  s,
  context = None 
)

Definition at line 93 of file SerialSubstitution.py.

93  def __call__(self, s, context = None):
94  for pattern in self.exceptions:
95  if pattern.search(s) is not None: return s
96  return self.regex.sub(self.repl, s)
97 
def SerialSubstitution.RegExSubstitutionClass.__str__ (   self)

Definition at line 91 of file SerialSubstitution.py.

91  def __str__(self): return self.regex.pattern
92 
def SerialSubstitution.RegExSubstitutionClass.Describe (   self)

Definition at line 98 of file SerialSubstitution.py.

98  def Describe(self):
99  return "%r -> %r (regex)" % (self.regex.pattern, self.repl)
100 
101 # class RegExSubstitutionClass
102 
103 

Member Data Documentation

SerialSubstitution.RegExSubstitutionClass.exceptions

Definition at line 88 of file SerialSubstitution.py.

SerialSubstitution.RegExSubstitutionClass.regex

Definition at line 86 of file SerialSubstitution.py.

SerialSubstitution.RegExSubstitutionClass.repl

Definition at line 87 of file SerialSubstitution.py.


The documentation for this class was generated from the following file: