Public Member Functions | Static Public Member Functions | List of all members
RemoveMathFromGDML.GDMLpurifier Class Reference
Inheritance diagram for RemoveMathFromGDML.GDMLpurifier:
RemoveMathFromGDML.GDMLexpressionRemover

Public Member Functions

def __init__ (self, args, kargs)
 
def apply (self, token, iLine=None)
 
- Public Member Functions inherited from RemoveMathFromGDML.GDMLexpressionRemover
def __init__ (self, options=None)
 
def initROOT (self)
 
def pass_floats (self, expression)
 
def purify_native (self, expression)
 
def purify_ROOT (self, expression)
 

Static Public Member Functions

def findStrings (token)
 
- Static Public Member Functions inherited from RemoveMathFromGDML.GDMLexpressionRemover
def sanitize (s)
 

Additional Inherited Members

- Public Attributes inherited from RemoveMathFromGDML.GDMLexpressionRemover
 constants
 
 environment
 
 options
 
 formula
 
 purify
 
 ROOT
 

Detailed Description

Definition at line 144 of file RemoveMathFromGDML.py.

Constructor & Destructor Documentation

def RemoveMathFromGDML.GDMLpurifier.__init__ (   self,
  args,
  kargs 
)

Definition at line 145 of file RemoveMathFromGDML.py.

145  def __init__(self, *args, **kargs):
146  GDMLexpressionRemover.__init__(self, *args, **kargs)
147 

Member Function Documentation

def RemoveMathFromGDML.GDMLpurifier.apply (   self,
  token,
  iLine = None 
)
Purifies the token

Definition at line 192 of file RemoveMathFromGDML.py.

192  def apply(self, token, iLine = None):
193  """Purifies the token"""
194  elements = []
195  for prefix, s in self.findStrings(token):
196  element = prefix if prefix is not None else ""
197  if s is not None:
198  purified = self.purify(s)
199  if s != purified:
200  if iLine is not None:
201  logging.debug(
202  "Evaluated '%s' into '%s' on line %d",
203  s, purified, iLine + 1
204  )
205  if self.options.WarnZero and (float(purified) == 0.):
206  logging.warn("On line %d: expression '%s' evaluated to 0",
207  iLine + 1, s)
208  else:
209  logging.debug("Evaluated '%s' into '%s'", s, purified)
210  if self.options.WarnZero and (float(purified) == 0.):
211  logging.warn("Expression '%s' evaluated to 0", s)
212  # if purified
213  element += '"' + str(purified) + '"'
214  # if s
215  elements.append(element)
216  # for
217  return "".join(elements)
def apply(self, token, iLine=None)
static QCString str
def RemoveMathFromGDML.GDMLpurifier.findStrings (   token)
static
Returns a list of pairs: (prefix, double quoted string)

One of them may be None if no such element is present

Definition at line 149 of file RemoveMathFromGDML.py.

149  def findStrings(token):
150  """Returns a list of pairs: (prefix, double quoted string)
151 
152  One of them may be None if no such element is present
153  """
154  mode = 'p' # 'p': prefix; 'w': word; 'e': equal sign
155  tokens = []
156  iC = 0
157  prefix = ""
158  word = None
159  for c in token:
160  if c == '=':
161  if mode == 'p': # (p) => (e) on '='
162  mode = 'e'
163  continue
164  # if
165  elif c == '"':
166  if mode == 'e': # (e) => (w) on '"'
167  prefix += "="
168  word = ""
169  mode = 'w'
170  continue
171  elif mode == 'w': # (w) => (p) on '"'
172  tokens.append((prefix, word))
173  prefix = ""
174  word = None
175  mode = 'p'
176  continue
177  else: # (p) => (p) on '"'
178  pass
179  # if ... else
180  else:
181  if mode == 'e': # (e) => (p) on anything but '"'
182  mode = 'p'
183  # if ... else
184  if mode == 'p': prefix += c
185  elif mode == 'w': word += c
186  # while
187  if prefix or (word is not None):
188  tokens.append((prefix, word))
189  return tokens

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