avocado_i2n.params_parser module

SUMMARY

Module for handling all Cartesian config parsing and making it reusable and maximally performant.

Copyright: Intra2net AG

INTERFACE

exception avocado_i2n.params_parser.EmptyCartesianProduct(message)[source]

Bases: Exception

Empty Cartesian product of variants

__init__(message)[source]

Initialize an empty Cartesian product exception.

Parameters:message (str) – additional message about the exception
avocado_i2n.params_parser.custom_configs_dir()[source]

Custom directory for all config files.

avocado_i2n.params_parser.tests_ovrwrt_file()[source]

Overwrite config file for all tests (nodes).

avocado_i2n.params_parser.vms_ovrwrt_file()[source]

Overwrite config file for all vms (objects).

class avocado_i2n.params_parser.ParsedContent(content)[source]

Bases: object

Class for parsed content of a general type.

__init__(content)[source]

Initialize the parsed content.

reportable_form()[source]

Parsed content representation used in reports of parsing steps.

Returns:resulting report-compatible string
Return type:str
Raises:NotImlementedError as this is an abstract method
parsable_form()[source]

Convert parameter content into parsable string.

Returns:resulting parsable string
Return type:str
Raises:NotImlementedError as this is an abstract method
class avocado_i2n.params_parser.ParsedFile(content)[source]

Bases: avocado_i2n.params_parser.ParsedContent

Class for parsed content of file type.

__init__(content)[source]

Initialize the parsed content.

reportable_form()[source]

Parsed file representation used in reports of parsing steps.

Arguments are identical to the ones of the parent class.

parsable_form()[source]

Convert parameter file name into parsable string.

Returns:resulting parsable string
Return type:str
class avocado_i2n.params_parser.ParsedStr(content)[source]

Bases: avocado_i2n.params_parser.ParsedContent

Class for parsed content of string type.

reportable_form()[source]

Parsed string representation used in reports of parsing steps.

Arguments are identical to the ones of the parent class.

parsable_form()[source]

Convert parameter string into parsable string.

Returns:resulting parsable string
Return type:str

This is equivalent to the string since the string is parsable by definition.

class avocado_i2n.params_parser.ParsedDict(content)[source]

Bases: avocado_i2n.params_parser.ParsedContent

Class for parsed content of dictionary type.

reportable_form()[source]

Parsed dictionary representation used in reports of parsing steps.

Arguments are identical to the ones of the parent class.

parsable_form()[source]

Convert parameter dictionary into parsable string.

Returns:resulting parsable string
Return type:str
class avocado_i2n.params_parser.Reparsable[source]

Bases: object

Class to represent quickly parsable Cartesian configuration, producing both parser and parameters (parser dicts) on demand.

__init__()[source]

Initialize the parsable structure.

parse_next_file(pfile)[source]

Add a file parsing step.

Parameters:pfile (str) – file to be parsed next

If the parsable file has a relative form (not and absolute path), it will be searched in the relative test suite config directory.

parse_next_str(pstring)[source]

Add a string parsing step.

Parameters:pstring (str) – string to be parsed next
parse_next_dict(pdict)[source]

Add a dictionary parsing step.

Parameters:pdict ({str, str}) – dictionary to be parsed next
parse_next_batch(base_file=None, base_str='', base_dict=None, ovrwrt_file=None, ovrwrt_str='', ovrwrt_dict=None)[source]

Parse a batch of base file, string, and dictionary, and possibly an overwrite file (with custom parameters at the user’s home location).

Parameters:
  • base_file (str or None) – file to be parsed first
  • base_str (str or None) – string to be parsed first
  • base_dict ({str, str} or None) – params to be added first
  • ovrwrt_file (str or None) – file to be parsed last
  • ovrwrt_str (str or None) – string to be parsed last
  • ovrwrt_dict ({str, str} or None) – params to be added last

The priority of the setting follows the order of the arguments: Dictionary with some parameters is topmost, string with some parameters is next and the file with parameters is taken as a base. The overwriting version is taken last, the base version first.

print_parsed()[source]

Return printable information about what was parsed so far.

Returns:structured text of the base/ovrwrt file/str/dict parse steps
Return type:str
avocado_i2n.params_parser.all_restrictions()[source]

Return all restrictions that can be passed for any test configuration.

Returns:all available (from configuration) vms
Return type:[str]
avocado_i2n.params_parser.all_objects(key='vms', composites=None)[source]

Return all test objects that can be passed for any test configuration.

Param:str key: key to extract parametric objects from
Parameters:composites ([str]) – composite restriction of the returned objects
Returns:all available (from configuration) objects of a given type
Return type:[str]
avocado_i2n.params_parser.main_vm()[source]

Return the default main vm that can be passed for any test configuration.

Returns:main available (from configuration) vm
Return type:str or None
avocado_i2n.params_parser.re_str(variant_str, base_str='', tag='')[source]

Add a variant restriction to the base string, optionally adding a custom tag as well.

Parameters:
  • variant_str (str) – variant restriction
  • base_str (str) – string where the variant restriction will be added
  • tag (str) – additional tag to the variant combination
Returns:

restricted parameter string

Return type:

str

avocado_i2n.params_parser.join_str(variant_strs, base_str='')[source]

Join all object variant restrictions over the base string.

Parameters:
  • variant_strs ({str, str}) – variant restrictions for each object as key, value pair
  • base_str (str) – string where the variant restriction will be added
Returns:

restricted parameter string

Return type:

str