/[gnue]/gnue-common/src/datasources/GConditions.py
ViewVC logotype

Diff of /gnue-common/src/datasources/GConditions.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by jcater, Mon Feb 17 07:32:48 2003 UTC revision 1.25 by jcater, Thu Jul 10 23:15:26 2003 UTC
# Line 199  def getXMLelements(updates={}): Line 199  def getXMLelements(updates={}):
199           'Attributes': {           'Attributes': {
200              'value':     {              'value':     {
201                 'Required': 1,                 'Required': 1,
202                   'Typecast': GTypecast.text },
203                'type':     {
204                 'Typecast': GTypecast.text } },                 'Typecast': GTypecast.text } },
205           'ParentTags':  ('eq','ne','lt','le','gt','ge','add','sub','mul',           'ParentTags':  ('eq','ne','lt','le','gt','ge','add','sub','mul',
206                           'div','like','notlike','between','notbetween') },                           'div','like','notlike','between','notbetween') },
# Line 372  def buildTreeFromPrefix(term): Line 374  def buildTreeFromPrefix(term):
374    # set start level for stack to zero    # set start level for stack to zero
375    level=0    level=0
376    for i in term:    for i in term:
377            
378      # convert type into an object      # convert type into an object
379      if conditionElements.has_key(i[0]):      if conditionElements.has_key(i[0]):
380        e=conditionElements[i[0]][2](parent[level])        e=conditionElements[i[0]][2](parent[level])
381        level=level+1        level=level+1
382        # get parameter count        # get parameter count
383        paramcount[level]=conditionElements[i[0]][0]        paramcount[level]=conditionElements[i[0]][0]
384        parent[level]=e        parent[level]=e
385      elif i[0]=="field":            elif i[0]=="field":
386        e=GCField(parent[level], i[1])        e=GCField(parent[level], i[1])
387        paramcount[level]=paramcount[level]-1        paramcount[level]=paramcount[level]-1
388        if paramcount[level]==0:        if paramcount[level]==0:
# Line 389  def buildTreeFromPrefix(term): Line 391  def buildTreeFromPrefix(term):
391        e=GCConst(parent[level], i[1])        e=GCConst(parent[level], i[1])
392        paramcount.update({level:(paramcount[level]-1)})        paramcount.update({level:(paramcount[level]-1)})
393        if paramcount[level]==0:        if paramcount[level]==0:
394          level=level-1              level=level-1
395  #    print "NAME: %s  VALUE: %s  LEVEL: %s PCOUNT: %s" % \  #    print "NAME: %s  VALUE: %s  LEVEL: %s PCOUNT: %s" % \
396  #          (i[0],i[1],level,paramcount[level])  #          (i[0],i[1],level,paramcount[level])
397        
398    return parent[0];    return parent[0];
399    
400    
# Line 441  def buildPrefixFromTree(conditionTree): Line 443  def buildPrefixFromTree(conditionTree):
443          result = result + \          result = result + \
444                   buildPrefixFromTree(conditionTree._children[i])                   buildPrefixFromTree(conditionTree._children[i])
445    
446        #          #
447        #  check for integrity of condition        #  check for integrity of condition
448        #        #
449        if len(conditionTree._children) < conditionElements[otype][0]:        if len(conditionTree._children) < conditionElements[otype][0]:
450          tmsg = _('Condition element "%s" expects at least %s arguments; found %s') % \          tmsg = _('Condition element "%s" expects at least %s arguments; found %s') % \
451                   (otype, conditionElements[otype][0], len(conditionTree._children))                   (otype, conditionElements[otype][0], len(conditionTree._children))
452          raise GConditions.ConditionError, tmsg          raise GConditions.ConditionError, tmsg
453    
454        if len(conditionTree._children) > conditionElements[otype][1]:        if len(conditionTree._children) > conditionElements[otype][1]:
455          tmsg = _('Condition element "%s" expects at most %s arguments; found %s') % \          tmsg = _('Condition element "%s" expects at most %s arguments; found %s') % \
456                  (otype, conditionElements[otype][1], len(conditionTree._children))                  (otype, conditionElements[otype][1], len(conditionTree._children))
457          raise GConditions.ConditionError, tmsg          raise GConditions.ConditionError, tmsg
458    
459    

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26