zabgrab.services.resolve¶
Turning command line options, a template and config into a Query.
- zabgrab.services.resolve.TimeParser¶
Parses a user-supplied time in a timezone (
Nonefor local) to aware UTC.- Type:
- zabgrab.services.resolve.DefaultsSource¶
Gets where a
[defaults]key’s value came from (a file path orbuilt-in).- Type:
- zabgrab.services.resolve.SETTINGS¶
Settings resolved from the command line, the template and
[defaults], in the order they’re resolved (the timezone is needed to compare and parse times).
- zabgrab.services.resolve.DATA_SETTINGS¶
Settings that change which data is fetched (used to mark a query as custom).
Functions
|
Look up a template, with "did you mean" for unknown names. |
|
Get the command line option for a config key. |
|
Combine the command line, template and config into a |
Classes
|
What was given on the command line. |
- class zabgrab.services.resolve.CliRequest(template=None, items=(), server=None, values=<factory>)[source]¶
Bases:
objectWhat was given on the command line.
- Parameters:
- values¶
Settings given explicitly, by config key (e.g.
"from").- Type:
mapping
- zabgrab.services.resolve.flag(key)[source]¶
Get the command line option for a config key.
Examples
>>> flag("output_dir") '--output-dir'
- zabgrab.services.resolve.resolve_query(cli, config, ui, *, parse_time, defaults_source)[source]¶
Combine the command line, template and config into a
Query.Precedence: the command line, then the template, then
[defaults](including built-in values). Missing times are asked for. Overrides of template values are logged.- Parameters:
cli (CliRequest) – What was given on the command line.
config (Config) – The configuration.
ui (UI) – For questions and messages.
parse_time (TimeParser) – Parses times.
defaults_source (DefaultsSource) – Says where
[defaults]values came from, for--dry-run.
- Returns:
Query – The query.
- Raises:
ZabgrabError – If the template is unknown or a time is invalid, and the user can’t be asked.
InputRequired – If a question is needed but the session isn’t interactive.
- Return type:
- zabgrab.services.resolve.find_template(name, config, ui, answers=None)[source]¶
Look up a template, with “did you mean” for unknown names.
- Parameters:
- Returns:
tuple of str and Template – The template used and its name, which differs from
nameif the user chose another.- Raises:
ZabgrabError – If the name is unknown and the user can’t choose another.
- Return type: