pyats.utils.yaml package¶
Submodules¶
-
class
pyats.utils.yaml.dumper.
OrderedSafeDumper
(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)¶ Bases:
yaml.dumper.SafeDumper
Order safe dumper
-
static
ordereddict_representer
(dumper, data)¶
-
yaml_representers
= {<class 'NoneType'>: <function SafeRepresenter.represent_none>, <class 'str'>: <function SafeRepresenter.represent_str>, <class 'bytes'>: <function SafeRepresenter.represent_binary>, <class 'bool'>: <function SafeRepresenter.represent_bool>, <class 'int'>: <function SafeRepresenter.represent_int>, <class 'float'>: <function SafeRepresenter.represent_float>, <class 'list'>: <function SafeRepresenter.represent_list>, <class 'tuple'>: <function SafeRepresenter.represent_list>, <class 'dict'>: <function SafeRepresenter.represent_dict>, <class 'set'>: <function SafeRepresenter.represent_set>, <class 'datetime.date'>: <function SafeRepresenter.represent_date>, <class 'datetime.datetime'>: <function SafeRepresenter.represent_datetime>, None: <function SafeRepresenter.represent_undefined>, <class 'collections.OrderedDict'>: <cyfunction OrderedSafeDumper.ordereddict_representer>}¶
-
static
Errors related to utils.yaml module
-
exception
pyats.utils.yaml.exceptions.
LoadError
¶ Bases:
Exception
Raised when the input loadable cannot be loaded
-
class
pyats.utils.yaml.loader.
Loader
(schema=None, supported_schema_versions=None, enable_extensions=False, preprocessor=None, markupprocessor=None, postprocessor=None, preserve_order=False)¶ Bases:
object
Generic YAML loader.
- Parameters
schema (A schema as understood by the) –
schemaengine
module containing the validation criteria for the content to load.supported_schema_versions (A list of schema version numbers) – that are supported.
markupprocessor (A function that, if specified, accepts content,) – transforms that content using markup processing, and returns the content. If not specified, use the default markup processor.
preprocessor (A function that, if specified, accepts content,) – performs pre-validation processing and returns the content.
postprocessor (A function that, if specified, accepts content,) – performs post-validation processing and returns the content.
enable_extensions (If specified as
True
then allow theextends
) – content key to contain an optional filename or list of filenames. The actual content is assembled by loading the raw content of each extension file in turn, starting with the last file in the list, and recursively updating content. Finally, the content of the input loadable is then updated on top. Theextends
key is expected to be present in the schema. If specified asFalse
, then no extension processing is done and theextends
key is not expected to be present in the schema. Defaults toFalse
.
-
load
(*loadables, locations=None)¶
-
load_arbitrary
(loadable, *, locations=None)¶
-
process_extensions
(content, locations=None)¶ Recursively merge user-specified extension files, in order.
Post-process the content and look for “extends” key. If found, bring in its content and then add this file’s content on top.
Also process nested extensions if they are present (ie. extending from a file which extends from another file …).
Note
Non-file YAML input is allowed but this means extension filenames must be specified with relative or absolute pathnames.
- Returns
The recursively updated contents of the extension files, with the
input content updated last (on top of the extension content).
For example, process_extensions(content) when the
extends
keycontains
[a b c]
returns(c + (b + (a + content)))
wherea + b
denotes a recursive dictionary update where b’s contentis added on top of a’s content.
-
class
pyats.utils.yaml.loader.
OrderedSafeLoader
(stream, *, locations=None, file_name=None)¶ Bases:
pyats.utils.locations.LocSafeLoader
Provides ordered loading from yaml file - preserving the insertion of key order as the yaml file is loaded.
Note - probably useless from Python 3.7 onward :-
-
static
ordered_dict_constructor
(loader, node)¶
-
yaml_constructors
= {'tag:yaml.org,2002:null': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:int': <function SafeConstructor.construct_yaml_int>, 'tag:yaml.org,2002:float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:binary': <function SafeConstructor.construct_yaml_binary>, 'tag:yaml.org,2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>, 'tag:yaml.org,2002:omap': <function SafeConstructor.construct_yaml_omap>, 'tag:yaml.org,2002:pairs': <function SafeConstructor.construct_yaml_pairs>, 'tag:yaml.org,2002:set': <function SafeConstructor.construct_yaml_set>, 'tag:yaml.org,2002:str': <function SafeConstructor.construct_yaml_str>, 'tag:yaml.org,2002:seq': <function SafeConstructor.construct_yaml_seq>, 'tag:yaml.org,2002:map': <cyfunction OrderedSafeLoader.ordered_dict_constructor>, None: <function SafeConstructor.construct_undefined>}¶
-
static
-
class
pyats.utils.yaml.markup.
Processor
(reference=True, callable=True, env_var=True, include_file=True, ask=True, encode=True, cli_var=True, yaml_loader_cls=None)¶ Bases:
object
-
argv
= ['-M', 'html', '.', '/home/andreas/ccdeve-docs/collected-docs/pyats/docs/__build__/documentation']¶
-
match_ask_markup
(data)¶
-
match_callable_markup
(data)¶
-
match_cli_markup
(data)¶
-
match_enc_markup
(data)¶
-
match_env_markup
(data)¶
-
match_include_file_markup
(data)¶
-
match_reference_markup
(data)¶
-
p_ask_markup
(match, data, index, locations=None)¶
-
p_callable_markup
(match, data, index, locations=None)¶
-
p_cli_markup
(match, data, index, locations=None)¶
-
p_enc_markup
(match, data, index, locations=None)¶
-
p_environ_markup
(match, data, index, locations=None)¶
-
p_file_markup
(match, data, index, locations=None)¶
-
p_reference_markup
(match, data, index, locations=None)¶
-
-
pyats.utils.yaml.markup.
ask_for_input
(prompt_text)¶