Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise ParseException(instring, loc, "Missing one or more required elements (%s)" % missing)
resultlist = []
for e in matchOrder:
loc, results = e.parse(instring, loc, doActions)
resultlist.append(results)
finalResults = ParseResults([])
for r in resultlist:
dups = {}
for k in r.keys():
if k in finalResults.keys():
tmp = ParseResults(finalResults[k])
tmp += ParseResults(r[k])
dups[k] = tmp
finalResults += ParseResults(r)
for k, v in dups.items():
finalResults[k] = v
return loc, finalResults
raise
else:
if callPreParse:
loc = self.preParse(instring, loc)
tokensStart = loc
if self.mayIndexError or loc >= len(instring):
try:
loc, tokens = self.parseImpl(instring, loc, doActions)
except IndexError:
raise ParseException(instring, len(instring), self.errmsg, self)
else:
loc, tokens = self.parseImpl(instring, loc, doActions)
tokens = self.postParse(instring, loc, tokens)
retTokens = ParseResults(tokens, self.resultsName, asList=self.saveAsList, modal=self.modalResults)
if self.parseAction and doActions:
if debugging:
try:
tokens = self.parseAction(instring, tokensStart, retTokens)
if tokens is not None:
if isinstance(tokens, tuple):
tokens = tokens[1]
retTokens = ParseResults(tokens,
self.resultsName,
asList=self.saveAsList and isinstance(tokens, (ParseResults, list)),
modal=self.modalResults)
except ParseException, err:
#~ print "Exception raised in user parse action:", err
if (self.debugActions[2]):
self.debugActions[2](instring, tokensStart, self, err)
raise
tokens = tokens[1]
retTokens = ParseResults(tokens,
self.resultsName,
asList=self.saveAsList and isinstance(tokens, (ParseResults, list)),
modal=self.modalResults)
except ParseException, err:
#~ print "Exception raised in user parse action:", err
if (self.debugActions[2]):
self.debugActions[2](instring, tokensStart, self, err)
raise
else:
tokens = self.parseAction(instring, tokensStart, retTokens)
if tokens is not None:
if isinstance(tokens, tuple):
tokens = tokens[1]
retTokens = ParseResults(tokens,
self.resultsName,
asList=self.saveAsList and isinstance(tokens, (ParseResults, list)),
modal=self.modalResults)
if debugging:
#~ print "Matched",self,"->",retTokens.asList()
if (self.debugActions[1]):
self.debugActions[1](instring, tokensStart, loc, self, retTokens)
return loc, retTokens
except IndexError:
raise ParseException(instring, len(instring), self.errmsg, self)
else:
loc, tokens = self.parseImpl(instring, loc, doActions)
tokens = self.postParse(instring, loc, tokens)
retTokens = ParseResults(tokens, self.resultsName, asList=self.saveAsList, modal=self.modalResults)
if self.parseAction and doActions:
if debugging:
try:
tokens = self.parseAction(instring, tokensStart, retTokens)
if tokens is not None:
if isinstance(tokens, tuple):
tokens = tokens[1]
retTokens = ParseResults(tokens,
self.resultsName,
asList=self.saveAsList and isinstance(tokens, (ParseResults, list)),
modal=self.modalResults)
except ParseException, err:
#~ print "Exception raised in user parse action:", err
if (self.debugActions[2]):
self.debugActions[2](instring, tokensStart, self, err)
raise
else:
tokens = self.parseAction(instring, tokensStart, retTokens)
if tokens is not None:
if isinstance(tokens, tuple):
tokens = tokens[1]
retTokens = ParseResults(tokens,
self.resultsName,
asList=self.saveAsList and isinstance(tokens, (ParseResults, list)),
if tmpReqd:
missing = ", ".join([str(e) for e in tmpReqd])
raise ParseException(instring, loc, "Missing one or more required elements (%s)" % missing)
resultlist = []
for e in matchOrder:
loc, results = e.parse(instring, loc, doActions)
resultlist.append(results)
finalResults = ParseResults([])
for r in resultlist:
dups = {}
for k in r.keys():
if k in finalResults.keys():
tmp = ParseResults(finalResults[k])
tmp += ParseResults(r[k])
dups[k] = tmp
finalResults += ParseResults(r)
for k, v in dups.items():
finalResults[k] = v
return loc, finalResults