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

Public Member Functions

def __init__ (self, match, message, 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

 pattern
 
 regex
 
 msg
 
 exceptions
 
- Public Attributes inherited from SerialSubstitution.SubstitutionClass
 options
 

Detailed Description

Definition at line 148 of file SerialSubstitution.py.

Constructor & Destructor Documentation

def SerialSubstitution.WarningClass.__init__ (   self,
  match,
  message,
  exceptions = [] 
)

Definition at line 149 of file SerialSubstitution.py.

149  def __init__(self, match, message, exceptions = []):
150  SubstitutionClass.__init__(self)
151  if hasattr(match, 'search'):
152  self.pattern = match.pattern
153  self.regex = match
154  else:
155  self.pattern = match
156  self.regex = re.compile(match)
157  self.msg = message
158  self.exceptions = list(map(re.compile, exceptions))
def __init__(self, match, message, exceptions=[])

Member Function Documentation

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

Definition at line 163 of file SerialSubstitution.py.

163  def __call__(self, s, context = None):
164  for pattern in self.exceptions:
165  if pattern.search(s) is not None: return s
166  match = self.regex.search(s)
167  if match is not None:
168  msg = match.expand(self.msg)
169  if context is None:
170  logging.warning(
171  "From line '%s': %s", s,
172  Colorize(msg, 'warning', self.options)
173  )
174  else:
175  logging.warning(
176  "From %s: %s\n => %s",
177  context.Location(), Colorize(msg, 'warning', self.options), s
178  )
179  # if ... else
180  logging.debug("(pattern: %r on %r)", self.regex.pattern, s)
181  # if
182  return s
def __call__(self, s, context=None)
def Colorize(msg, category, options)
Library code.
def SerialSubstitution.WarningClass.__str__ (   self)

Definition at line 161 of file SerialSubstitution.py.

161  def __str__(self): return self.pattern
162 
def SerialSubstitution.WarningClass.Describe (   self)

Definition at line 185 of file SerialSubstitution.py.

185  def Describe(self):
186  return "%r -> %r (warning)" % (self.pattern, self.msg)
187 
188 # class WarningClass
189 
190 
191 
192 

Member Data Documentation

SerialSubstitution.WarningClass.exceptions

Definition at line 158 of file SerialSubstitution.py.

SerialSubstitution.WarningClass.msg

Definition at line 157 of file SerialSubstitution.py.

SerialSubstitution.WarningClass.pattern

Definition at line 152 of file SerialSubstitution.py.

SerialSubstitution.WarningClass.regex

Definition at line 153 of file SerialSubstitution.py.


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