All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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__
 
def apply
 
- Public Member Functions inherited from RemoveMathFromGDML.GDMLexpressionRemover
def __init__
 
def initROOT
 
def pass_floats
 
def purify_native
 
def purify_ROOT
 

Static Public Member Functions

def findStrings
 
- Static Public Member Functions inherited from RemoveMathFromGDML.GDMLexpressionRemover
def sanitize
 

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.

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

Member Function Documentation

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

Definition at line 192 of file RemoveMathFromGDML.py.

193  def apply(self, token, iLine = None):
194  """Purifies the token"""
195  elements = []
196  for prefix, s in self.findStrings(token):
197  element = prefix if prefix is not None else ""
198  if s is not None:
199  purified = self.purify(s)
200  if s != purified:
201  if iLine is not None:
202  logging.debug(
203  "Evaluated '%s' into '%s' on line %d",
204  s, purified, iLine + 1
205  )
206  if self.options.WarnZero and (float(purified) == 0.):
207  logging.warn("On line %d: expression '%s' evaluated to 0",
208  iLine + 1, s)
209  else:
210  logging.debug("Evaluated '%s' into '%s'", s, purified)
211  if self.options.WarnZero and (float(purified) == 0.):
212  logging.warn("Expression '%s' evaluated to 0", s)
213  # if purified
214  element += '"' + str(purified) + '"'
215  # if s
216  elements.append(element)
217  # for
return "".join(elements)
S join(S const &sep, Coll const &s)
Returns a concatenation of strings in s separated by sep.
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.

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

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