All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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__
 
def __str__
 
def __call__
 
def Describe
 
- Public Member Functions inherited from SerialSubstitution.SubstitutionClass
def __init__
 
def SetOptions
 
def __str__
 
def __call__
 
def describe
 

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 
85  def __init__(self, match, replacement, exceptions = []):
86  SubstitutionClass.__init__(self)
87  self.regex = re.compile(match)
88  self.repl = replacement
self.exceptions = list(map(re.compile, exceptions))
list
Definition: file_to_url.sh:28

Member Function Documentation

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

Definition at line 93 of file SerialSubstitution.py.

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

Definition at line 91 of file SerialSubstitution.py.

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

Definition at line 98 of file SerialSubstitution.py.

98 
99  def Describe(self):
100  return "%r -> %r (regex)" % (self.regex.pattern, self.repl)
101 
102 # class RegExSubstitutionClass
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: