| Home | Trees | Indices | Help |
|
|---|
|
|
object --+
|
ParserElement --+
|
ParseElementEnhance --+
|
SkipTo
Token for skipping over all undefined text until the matched expression is found.
Parameters:
False) if True, the target expression
is also parsed (the skipped text and target expression are returned
as a 2-element list).
None) used to define grammars
(typically quoted strings and comments) that might contain false
matches to the target expression
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
| Instance Methods | |||
|
|||
|
|||
|
Inherited from Inherited from Inherited from |
|||
| Static Methods | |
|
Inherited from |
| Class Variables | |
|
Inherited from |
| Properties | |
|
Inherited from |
| Method Details |
x.__init__(...) initializes x; see help(type(x)) for signature
|
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Mar 05 20:19:56 2017 | http://epydoc.sourceforge.net |