types
Support for checking types of easyconfig parameter values.
Authors:
- Caroline De Brouwer (Ghent University)
- Kenneth Hoste (Ghent University)
as_hashable(dict_value)
¶
Helper function, convert dict value to hashable equivalent via tuples.
check_element_types(elems, allowed_types)
¶
Check whether types of elements of specified (iterable) value are as expected.
PARAMETER | DESCRIPTION |
---|---|
elems |
iterable value (list or dict) of elements
|
allowed_types |
allowed types per element; either a simple list, or a dict of allowed_types by element name
|
check_key_types(val, allowed_types)
¶
Check whether type of keys for specific dict value are as expected.
check_known_keys(val, allowed_keys)
¶
Check whether all keys for specified dict value are known keys.
check_required_keys(val, required_keys)
¶
Check whether all required keys are present in the specified dict value.
check_type_of_param_value(key, val, auto_convert=False)
¶
Check value type of specified easyconfig parameter.
PARAMETER | DESCRIPTION |
---|---|
key |
name of easyconfig parameter
|
val |
easyconfig parameter value, of which type should be checked
|
auto_convert |
try to automatically convert to expected value type if required
DEFAULT:
|
convert_value_type(val, typ)
¶
Try to convert type of provided value to specific type.
PARAMETER | DESCRIPTION |
---|---|
val |
value to convert type of
|
typ |
target type
|
ensure_iterable_license_specs(specs)
¶
Ensures that the provided license file/server specifications are of correct type and converts them to a list. The input can either be None, a string, or a list/tuple of strings.
PARAMETER | DESCRIPTION |
---|---|
specs |
License file/server specifications as provided via
|
is_value_of_type(value, expected_type)
¶
Check whether specified value matches a particular very specific (non-trivial) type, which is specified by means of a 2-tuple: (parent type, tuple with additional type requirements).
PARAMETER | DESCRIPTION |
---|---|
value |
value to check the type of
|
expected_type |
type of value to check against
|
to_checksums(checksums)
¶
Ensure correct element types for list of checksums: convert list elements to tuples.
to_dependencies(dep_list)
¶
Convert a list of dependencies obtained from parsing a .yeb easyconfig to a list of dependencies in the correct format
to_dependency(dep)
¶
Convert a dependency specification to a dependency dict with name/version/versionsuffix/toolchain keys.
Example: {'foo': '1.2.3', 'toolchain': 'GCC, 4.8.2'} to {'name': 'foo', 'version': '1.2.3', 'toolchain': {'name': 'GCC', 'version': '4.8.2'}}
or {'name': 'fftw/3.3.4.1', 'external_module': True} to
to_list_of_strings(value)
¶
Convert specified value to a list of strings, if possible.
Supported: single string value, tuple of string values.
to_list_of_strings_and_tuples(spec)
¶
Convert a 'list of lists and strings' to a 'list of tuples and strings'
Example: ['foo', ['bar', 'baz']] to ['foo', ('bar', 'baz')]
to_list_of_strings_and_tuples_and_dicts(spec)
¶
Convert a 'list of dicts and tuples/lists and strings' to a 'list of dicts and tuples and strings'
Example: ['foo', ['bar', 'baz']] to ['foo', ('bar', 'baz')]
to_name_version_dict(spec)
¶
No longer supported, replaced by to_toolchain_dict.
to_sanity_check_paths_dict(spec)
¶
Convert a sanity_check_paths dict as received by yaml (a dict with list values that contain either lists or strings)
Example: {'files': ['file1', ['file2a', 'file2b]], 'dirs': ['foo/bar']} to
to_sanity_check_paths_entry(spec)
¶
Convert a 'list of lists and strings' to a 'list of tuples and strings' while allowing dicts of lists or strings
Example: ['foo', ['bar', 'baz'], {'f42': ['a', 'b']}] to ['foo', ('bar', 'baz'), {'f42': ('a', 'b')}]
to_toolchain_dict(spec)
¶
Convert a comma-separated string or 2/3-element list of strings to a dictionary with name/version keys, and optionally a hidden key. If the specified value is a dict already, the keys are checked to be only name/version/hidden.
For example: "intel, 2015a" => {'name': 'intel', 'version': '2015a'} "foss, 2016a, True" => {'name': 'foss', 'version': '2016a', 'hidden': True}
PARAMETER | DESCRIPTION |
---|---|
spec |
a comma-separated string with two or three values, or a 2/3-element list of strings, or a dict
|