|
def | __init__ (self, other, include=False, ignore=None, failOn=None) |
|
def | parseImpl (self, instring, loc, doActions=True) |
|
def | __init__ (self, expr, savelist=False) |
|
def | leaveWhitespace (self) |
|
def | ignore (self, other) |
|
def | streamline (self) |
|
def | checkRecursion (self, parseElementList) |
|
def | validate (self, validateTrace=None) |
|
def | __str__ (self) |
|
def | __init__ (self, savelist=False) |
|
def | copy (self) |
|
def | setName (self, name) |
|
def | setResultsName (self, name, listAllMatches=False) |
|
def | setBreak (self, breakFlag=True) |
|
def | setParseAction (self, *fns, **kwargs) |
|
def | addParseAction (self, *fns, **kwargs) |
|
def | addCondition (self, *fns, **kwargs) |
|
def | setFailAction (self, fn) |
|
def | preParse (self, instring, loc) |
|
def | postParse (self, instring, loc, tokenlist) |
|
def | tryParse (self, instring, loc) |
|
def | canParseNext (self, instring, loc) |
|
def | parseString (self, instring, parseAll=False) |
|
def | scanString (self, instring, maxMatches=_MAX_INT, overlap=False) |
|
def | transformString (self, instring) |
|
def | searchString (self, instring, maxMatches=_MAX_INT) |
|
def | split (self, instring, maxsplit=_MAX_INT, includeSeparators=False) |
|
def | __add__ (self, other) |
|
def | __radd__ (self, other) |
|
def | __sub__ (self, other) |
|
def | __rsub__ (self, other) |
|
def | __mul__ (self, other) |
|
def | __rmul__ (self, other) |
|
def | __or__ (self, other) |
|
def | __ror__ (self, other) |
|
def | __xor__ (self, other) |
|
def | __rxor__ (self, other) |
|
def | __and__ (self, other) |
|
def | __rand__ (self, other) |
|
def | __invert__ (self) |
|
def | __iter__ (self) |
|
def | __getitem__ (self, key) |
|
def | __call__ (self, name=None) |
|
def | suppress (self) |
|
def | setWhitespaceChars (self, chars) |
|
def | parseWithTabs (self) |
|
def | setDebugActions (self, startAction, successAction, exceptionAction) |
|
def | setDebug (self, flag=True) |
|
def | __repr__ (self) |
|
def | parseFile (self, file_or_filename, parseAll=False) |
|
def | __eq__ (self, other) |
|
def | __ne__ (self, other) |
|
def | __hash__ (self) |
|
def | __req__ (self, other) |
|
def | __rne__ (self, other) |
|
def | matches (self, testString, parseAll=True) |
|
def | runTests (self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False, postParse=None, file=None) |
|
Token for skipping over all undefined text until the matched
expression is found.
Parameters:
- expr - target expression marking the end of the data to be skipped
- include - (default= ``False``) if True, the target expression is also parsed
(the skipped text and target expression are returned as a 2-element list).
- ignore - (default= ``None``) used to define grammars (typically quoted strings and
comments) that might contain false matches to the target expression
- failOn - (default= ``None``) define expressions that are not allowed to be
included in the skipped test; if found before the target expression is found,
the SkipTo is not a match
Example::
report = '''
Outstanding Issues Report - 1 Jan 2000
# | Severity | Description | Days Open
-----+----------+-------------------------------------------+-----------
101 | Critical | Intermittent system crash | 6
94 | Cosmetic | Spelling error on Login ('log|n') | 14
79 | Minor | System slow when running too many reports | 47
'''
integer = Word(nums)
SEP = Suppress('|')
# use SkipTo to simply match everything up until the next SEP
# - ignore quoted strings, so that a '|' character inside a quoted string does not match
# - parse action will call token.strip() for each matched token, i.e., the description body
string_data = SkipTo(SEP, ignore=quotedString)
string_data.setParseAction(tokenMap(str.strip))
ticket_expr = (integer("issue_num") + SEP
+ string_data("sev") + SEP
+ string_data("desc") + SEP
+ integer("days_open"))
for tkt in ticket_expr.searchString(report):
print tkt.dump()
prints::
['101', 'Critical', 'Intermittent system crash', '6']
- days_open: 6
- desc: Intermittent system crash
- issue_num: 101
- sev: Critical
['94', 'Cosmetic', "Spelling error on Login ('log|n')", '14']
- days_open: 14
- desc: Spelling error on Login ('log|n')
- issue_num: 94
- sev: Cosmetic
['79', 'Minor', 'System slow when running too many reports', '47']
- days_open: 47
- desc: System slow when running too many reports
- issue_num: 79
- sev: Minor