| |
- exceptions.Exception
-
- BadTemplate
- MatchAborted
-
- HelpRequested
- UnknownOptionFound
- UsageRequested
- VersionRequested
- MatchFailed
-
- SwitchConflict
- FunctionalMatcher
- Matcher
-
- BaseMatcher
-
- Append
- Apply
- Function(BaseMatcher, FunctionalMatcher)
- Get(BaseMatcher, FunctionalMatcher)
- Increment
- Last
- Lookahead(BaseMatcher, FunctionalMatcher)
- MapPriority
- NoArgs
- Option
- Optional
- Or
- Pipe
- Prepend
- Quote(BaseMatcher, FunctionalMatcher)
- Raise
- Repeat
- Reversed
- Set
- SetAtLeast
- SetItem
- Split
- Stuff
- SubEnv
- Switch
- UnknownOption
- __builtin__.str(__builtin__.basestring)
-
- Unique
class Append(BaseMatcher) |
|
Append(key, matcher) - append matcher's info to env[key]. |
|
- Method resolution order:
- Append
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
|
class Apply(BaseMatcher) |
|
Apply(callable, matcher) - match and apply `callable` to info.
Fails on any exception (converting to MatchFailed if needed). |
|
- Method resolution order:
- Apply
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
|
class BaseMatcher(Matcher) |
|
Base class recommended for defining matchers; always fails.
All subclasses accept at construction time: some (possibly 0) fixed number
of parameters, followed by (usaully 0 or 1, sometimes unlimited) matcher
arguments that can also be templates and optinal keyword arguments (at
least `doc` and `snip`).
The specifics are described in each subclass' docstring; note that
*arguments described as optional - having default values - can only be
given as keyword arguments!* |
|
Methods defined here:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- match(self, args, env)
- Return (info, left_args, new_env) tuple.
Should be implemented by every matcher.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes defined here:
- data_args = 0
- keyword_args = []
- matcher_args = 0
|
class Function(BaseMatcher, FunctionalMatcher) |
|
Function(callable) - return callable(args[0]), args[1:], env.
Fails on any exception (converting to MatchFailed if needed). Intended to
do the right thing with functions like `int`, `str` or even `file`... |
|
- Method resolution order:
- Function
- BaseMatcher
- Matcher
- FunctionalMatcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
- matcher_args = 0
|
class FunctionalMatcher |
|
Empty marker class, subclass if your main function is useful info.
It's not really important that you don't modify args/env (in fact the
standard matchers inheriting from this do modify args) -- this is only
used by ``template({...})`` to decide to wrap the matcher automagically in
a `Set`. If in doubt, it's safer not to subclass this (there is currently
no mechanism for disabling this in the template). In particular you
should probably avoid this on any compound matcher... |
|
|
class Get(BaseMatcher, FunctionalMatcher) |
|
Get(key) - return env[key], args, env; fail if key not found. |
|
- Method resolution order:
- Get
- BaseMatcher
- Matcher
- FunctionalMatcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
- matcher_args = 0
|
class Increment(BaseMatcher) |
|
Increment(key, step=1, default=0) - increment env[key] by `step`.
If `key` is not found in env, set it to `default` + `step`. |
|
- Method resolution order:
- Increment
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
- keyword_args = ['step', 'start']
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- matcher_args = 0
|
class Last(BaseMatcher) |
|
Last(matcher) - match and extract info[-1].
Fails if info returned by matcher is not a sequence. |
|
- Method resolution order:
- Last
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
|
class Lookahead(BaseMatcher, FunctionalMatcher) |
|
Lookahead(matcher) - match and restore original args. |
|
- Method resolution order:
- Lookahead
- BaseMatcher
- Matcher
- FunctionalMatcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
|
class MapPriority(BaseMatcher) |
|
MapPriority(mapping, matcher) - map priorities returned by `Switch`.
`matcher` should return a (priority, info) pair. If priority is a key in
`mapping` it is replaced by the corresponding value; otherwise it's passed
unchanged.
Typical use is described in the module's docstring about
`exporting matchers from libraries and using them`_. |
|
- Method resolution order:
- MapPriority
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
|
class Matcher |
|
Empty marker class, subclass to indicate that you are a matcher.
Otherwise you are assumed to be a template. |
|
|
class NoArgs(BaseMatcher) |
|
NoArgs() - return 1 if args is empty, otherwise fail. |
|
- Method resolution order:
- NoArgs
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
- matcher_args = 0
|
class Option(BaseMatcher) |
| |
- Method resolution order:
- Option
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
- tag(self)
- Make a valid python identifier from the option string.
All non-alnums are converted to '_'; leading and trailing ones are
stripped. Note: if first letter is a digit, the value is not a valid
python identifier.
Data and other attributes defined here:
- data_args = 1
- keyword_args = ['abbrev', 'valsep', 'emptyval', 'valprepend']
- letter = '\xff'
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
Data and other attributes inherited from BaseMatcher:
- matcher_args = 0
|
class Optional(BaseMatcher) |
|
Optional(matcher) - instead of failing, return (None, args, env).
Equivallent to `Or(matcher, None)`. *Not* equivallent to
`Repeat(matcher, min=0, max=1)` (doesn't return a list). |
|
- Method resolution order:
- Optional
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
|
class Or(BaseMatcher) |
|
Or(matcher1, matcher2...) - try in order until one matches. |
|
- Method resolution order:
- Or
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- matcher_args = -1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
|
class Pipe(BaseMatcher) |
|
Pipe(matcher1, matcher2...) - pipe args and env, collect list of infos.
Passes args and env from each matcher to the next (returning the args and
env returned by last matcher). Extracted info is list of infos extracted
by sub-matchers. Fails if any sub-matcher fails. |
|
- Method resolution order:
- Pipe
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- matcher_args = -1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
|
class Prepend(BaseMatcher) |
|
Prepend(key, matcher) - prepend matcher's info to env[key]. |
|
- Method resolution order:
- Prepend
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
|
class Quote(BaseMatcher, FunctionalMatcher) |
|
Quote(x) - return x as info, don't touch args/env. |
|
- Method resolution order:
- Quote
- BaseMatcher
- Matcher
- FunctionalMatcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
- matcher_args = 0
|
class Raise(BaseMatcher) |
|
Raise(exc) - raise given exception (never matches). |
|
- Method resolution order:
- Raise
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
- matcher_args = 0
|
class Repeat(BaseMatcher) |
|
Repeat(matcher, min=0, max=None) - match until ``env[BREAK]`` set.
Matches `matcher` on args and env, feeds the results to it again and so
on. Returns list of infos extracted each time. Stops after `max`
iterations (if ``None`` - no upper limit), when the environment `matcher`
returns contains the special key `BREAK` (value ignored) or when there are
no more args.
If at the end the environment contains the special key `POSTPONE`, its
value (should be a list) is prepended to the returned args.
The state of `BREAK` and `POSTPONE` in the env is saved before matching
and restored on return (including deleting if they were not set).
Must match at least `min` times to succeed. Fails if `matcher` fails. |
|
- Method resolution order:
- Repeat
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- keywords = ['min', 'max']
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
|
class Reversed(BaseMatcher) |
|
Reversed(matcher) - match on temporarily reversed args. |
|
- Method resolution order:
- Reversed
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
|
class Set(BaseMatcher) |
|
Set(key, matcher) - store matcher's info as env[key].
Returns `None` as info, doesn't modify args. All value setoring matchers
behave in this way. |
|
- Method resolution order:
- Set
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
|
class SetAtLeast(BaseMatcher) |
|
SetAtLeast(key, matcher) - store if info >= than env[key], else fail.
Also stores if `key` not found in env. Fails if env[key] exists and is
higher than `matcher`'s info. Possible use: manage priority value
controlling other things. |
|
- Method resolution order:
- SetAtLeast
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
|
class SetItem(BaseMatcher) |
|
SetItem(matcher) - store matcher's info in env as (key,value) pair. |
|
- Method resolution order:
- SetItem
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
|
class Split(BaseMatcher) |
|
Split(sep, matcher) - match `matcher` on `args[0].split(sep)`.
Consume first argument, split it using `sep` as separator and give the
result to `matcher` as the arglist. If `sep` is `None`, any whitespace
string is a separator. Args left by `matcher` are ignored. |
|
- Method resolution order:
- Split
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
|
class Stuff(BaseMatcher) |
|
Stuff(matcher) - prepend info (a list) returned by matcher to args. |
|
- Method resolution order:
- Stuff
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
|
class SubEnv(BaseMatcher) |
|
SubEnv(key, matcher) - match in the environment env[key]. |
|
- Method resolution order:
- SubEnv
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
- matcher_args = 1
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
|
class Switch(BaseMatcher) |
|
Switch(dictionary) - exactly one key can match (of same priority).
Keys and values are templates/matchers.
Instead of a dict a list of tuples can be passed.
Attempt to match each matcher specified as a key (in parallel). Of those
that match the returned infos are treated as priorities - the one with
highest (`>`) priority is chosen. The corresponding value matcher is then
matched on the args and environment returned by the key. The results of
the switch are: a tuple (priority, vinfo) as the info, vargs, venv (where
v... are the results of the value matcher).
If no key matches, Switch raises self. If more than one match with same
highest priority, `SwitchConflict` is raised. If the value matcher fails,
it's exception is propogated. In the later two cases (at least one key
matched), the `._Switch__priority` attribute is set on the exception
object to the priority. This is useful if the switch is nested inside
another one.
If the value for a key is `NESTED`, the key is assumed to be a nested
switch (or a matcher containing a switch inside):
- The info it returns is taken (instead of discarding it and matching
`NESTED`) and treated as a (priority, info) sequence.
- If this key is choosen, return the `(priority, info), args, env` it
returned.
- If the key raised an exception (any, not only MatchFailed):
- If the exception has a `._Switch__priority` attribute, it is re-raised
unless some other key matches with higher priority.
- This implies that a conflict in the nested switch will propogate out
(unless overriden by something with higher priority).
- Otherwise the key is considered to have failed.
This mechanism is a bit complex but seems to be the right thing for merging
multiple sets of options... |
|
- Method resolution order:
- Switch
- BaseMatcher
- Matcher
Methods defined here:
- __init__(self, *args, **kwargs)
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- match(self, args, env)
Data and other attributes defined here:
- data_args = 1
Methods inherited from BaseMatcher:
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- keyword_args = []
- matcher_args = 0
|
class Unique(__builtin__.str) |
|
A unique values used by the argexp module. Compares by id. |
|
- Method resolution order:
- Unique
- __builtin__.str
- __builtin__.basestring
- __builtin__.object
Methods defined here:
- __eq__(self, other)
- __repr__(self)
Data and other attributes defined here:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
Methods inherited from __builtin__.str:
- __add__(...)
- x.__add__(y) <==> x+y
- __contains__(...)
- x.__contains__(y) <==> y in x
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __getitem__(...)
- x.__getitem__(y) <==> x[y]
- __getnewargs__(...)
- __getslice__(...)
- x.__getslice__(i, j) <==> x[i:j]
Use of negative indices is not supported.
- __gt__(...)
- x.__gt__(y) <==> x>y
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __mod__(...)
- x.__mod__(y) <==> x%y
- __mul__(...)
- x.__mul__(n) <==> x*n
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __rmod__(...)
- x.__rmod__(y) <==> y%x
- __rmul__(...)
- x.__rmul__(n) <==> n*x
- __str__(...)
- x.__str__() <==> str(x)
- capitalize(...)
- S.capitalize() -> string
Return a copy of the string S with only its first character
capitalized.
- center(...)
- S.center(width) -> string
Return S centered in a string of length width. Padding is done
using spaces.
- count(...)
- S.count(sub[, start[, end]]) -> int
Return the number of occurrences of substring sub in string
S[start:end]. Optional arguments start and end are
interpreted as in slice notation.
- decode(...)
- S.decode([encoding[,errors]]) -> object
Decodes S using the codec registered for encoding. encoding defaults
to the default encoding. errors may be given to set a different error
handling scheme. Default is 'strict' meaning that encoding errors raise
a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
as well as any other name registerd with codecs.register_error that is
able to handle UnicodeDecodeErrors.
- encode(...)
- S.encode([encoding[,errors]]) -> object
Encodes S using the codec registered for encoding. encoding defaults
to the default encoding. errors may be given to set a different error
handling scheme. Default is 'strict' meaning that encoding errors raise
a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
'xmlcharrefreplace' as well as any other name registered with
codecs.register_error that is able to handle UnicodeEncodeErrors.
- endswith(...)
- S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
- expandtabs(...)
- S.expandtabs([tabsize]) -> string
Return a copy of S where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
- find(...)
- S.find(sub [,start [,end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within s[start,end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- index(...)
- S.index(sub [,start [,end]]) -> int
Like S.find() but raise ValueError when the substring is not found.
- isalnum(...)
- S.isalnum() -> bool
Return True if all characters in S are alphanumeric
and there is at least one character in S, False otherwise.
- isalpha(...)
- S.isalpha() -> bool
Return True if all characters in S are alphabetic
and there is at least one character in S, False otherwise.
- isdigit(...)
- S.isdigit() -> bool
Return True if all characters in S are digits
and there is at least one character in S, False otherwise.
- islower(...)
- S.islower() -> bool
Return True if all cased characters in S are lowercase and there is
at least one cased character in S, False otherwise.
- isspace(...)
- S.isspace() -> bool
Return True if all characters in S are whitespace
and there is at least one character in S, False otherwise.
- istitle(...)
- S.istitle() -> bool
Return True if S is a titlecased string and there is at least one
character in S, i.e. uppercase characters may only follow uncased
characters and lowercase characters only cased ones. Return False
otherwise.
- isupper(...)
- S.isupper() -> bool
Return True if all cased characters in S are uppercase and there is
at least one cased character in S, False otherwise.
- join(...)
- S.join(sequence) -> string
Return a string which is the concatenation of the strings in the
sequence. The separator between elements is S.
- ljust(...)
- S.ljust(width) -> string
Return S left justified in a string of length width. Padding is
done using spaces.
- lower(...)
- S.lower() -> string
Return a copy of the string S converted to lowercase.
- lstrip(...)
- S.lstrip([chars]) -> string or unicode
Return a copy of the string S with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
If chars is unicode, S will be converted to unicode before stripping
- replace(...)
- S.replace (old, new[, count]) -> string
Return a copy of string S with all occurrences of substring
old replaced by new. If the optional argument count is
given, only the first count occurrences are replaced.
- rfind(...)
- S.rfind(sub [,start [,end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within s[start,end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- rindex(...)
- S.rindex(sub [,start [,end]]) -> int
Like S.rfind() but raise ValueError when the substring is not found.
- rjust(...)
- S.rjust(width) -> string
Return S right justified in a string of length width. Padding is
done using spaces.
- rstrip(...)
- S.rstrip([chars]) -> string or unicode
Return a copy of the string S with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
If chars is unicode, S will be converted to unicode before stripping
- split(...)
- S.split([sep [,maxsplit]]) -> list of strings
Return a list of the words in the string S, using sep as the
delimiter string. If maxsplit is given, at most maxsplit
splits are done. If sep is not specified or is None, any
whitespace string is a separator.
- splitlines(...)
- S.splitlines([keepends]) -> list of strings
Return a list of the lines in S, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends
is given and true.
- startswith(...)
- S.startswith(prefix[, start[, end]]) -> bool
Return True if S starts with the specified prefix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
- strip(...)
- S.strip([chars]) -> string or unicode
Return a copy of the string S with leading and trailing
whitespace removed.
If chars is given and not None, remove characters in chars instead.
If chars is unicode, S will be converted to unicode before stripping
- swapcase(...)
- S.swapcase() -> string
Return a copy of the string S with uppercase characters
converted to lowercase and vice versa.
- title(...)
- S.title() -> string
Return a titlecased version of S, i.e. words start with uppercase
characters, all remaining cased characters have lowercase.
- translate(...)
- S.translate(table [,deletechars]) -> string
Return a copy of the string S, where all characters occurring
in the optional argument deletechars are removed, and the
remaining characters have been mapped through the given
translation table, which must be a string of length 256.
- upper(...)
- S.upper() -> string
Return a copy of the string S converted to uppercase.
- zfill(...)
- S.zfill(width) -> string
Pad a numeric string S with zeros on the left, to fill a field
of the specified width. The string S is never truncated.
Data and other attributes inherited from __builtin__.str:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class UnknownOption(BaseMatcher) |
|
UnknownOption() - match any string starting with '-' but '-'/'--'.
Returned info is -1, to be lower than real option matchers in `Switch`. |
|
- Method resolution order:
- UnknownOption
- BaseMatcher
- Matcher
Methods defined here:
- match(self, args, env)
Methods inherited from BaseMatcher:
- __init__(self, *args, **kwargs)
- Generic constructor; real arg meaning defined by subclasses.
A subclass should define (as class attributes):
- `self.data_args` - the number of args to store as is into
`self.data` (if it's 1, the single arg is also stored as
self.datum). This number is fixed; optional args should be
implemented as keywords.
- `self.matcher_args` - the number (-1 for unlimited) of floowing
arguments to process by `template()` and store as `self.matchers`
(if 1, also stored as `self.matcher`).
- `self.keyword_args` - a list of keyword arg names to recognize and
store as attributes with same names (set only if supplied). 'doc'
and 'snip' are always handled this way.
If bogus args are supplied, TypeError is raised.
- __repr__(self)
- Return indented expression hopefully suitable for creating self.
- help(self)
- Return list of usage string and extra strings.
- tag(self)
- Return tag() of first data/matcher or his str().
Data and other attributes inherited from BaseMatcher:
- data_args = 0
- keyword_args = []
- matcher_args = 0
|
|