ssg.utils module
- class ssg.utils.VersionSpecifier(op, evr_ver_dict)[source]
Bases:
object
- property cpe_id
- property ev_ver
- property evr_op
- property evr_ver
- property oval_id
- property title
- property ver
- class ssg.utils.VersionSpecifierSet(s=())[source]
Bases:
set
- property cpe_id
- property oval_id
- property title
- ssg.utils.apply_formatting_on_dict_values(source_dict, string_dict, ignored_keys=frozenset({}))[source]
Uses Python built-in string replacement. It replaces strings marked by {token} if “token” is a key in the string_dict parameter. It skips keys in source_dict which are listed in ignored_keys parameter. This works only for dictionaries whose values are dicts or strings
- ssg.utils.check_conflict_regex_directory(data)[source]
Validate that either all path are directories OR file_regex exists.
Throws ValueError.
- ssg.utils.ensure_file_paths_and_file_regexes_are_correctly_defined(data)[source]
This function is common for the file_owner, file_groupowner and file_permissions templates. It ensures that the data structure meets certain rules, e.g. the file_path item is a list and number of list items in file_regex equals to number of items in file_path.
- ssg.utils.get_cpu_count()[source]
Returns the most likely estimate of the number of CPUs in the machine for threading purposes, gracefully handling errors and possible exceptions.
- ssg.utils.is_applicable(platform, product)[source]
Function to check if a platform is applicable for the product. Handles when a platform is really a list of products.
Returns true iff product is applicable for the platform or list of products
- ssg.utils.is_applicable_for_product(platform, product)[source]
Based on the platform dict specifier of the remediation script to determine if this remediation script is applicable for this product. Return ‘True’ if so, ‘False’ otherwise
- ssg.utils.map_name(version)[source]
Maps SSG Makefile internal product name to official product name
- ssg.utils.merge_dicts(left, right)[source]
Merges two dictionaries, keeing left and right as passed. If there are any common keys between left and right, the value from right is use.
Returns the merger of the left and right dictionaries
- ssg.utils.name_to_platform(names)[source]
Converts one or more full names to a string containing one or more <platform> elements.
- ssg.utils.parse_name(product)[source]
Returns a namedtuple of (name, version) from parsing a given product; e.g., “rhel7” -> (“rhel”, “7”)
- ssg.utils.parse_platform(platform)[source]
From a platform line, returns the set of platforms listed.
- ssg.utils.product_to_name(prod)[source]
Converts a vaguely-product-id-like thing into one or more full product names.
- ssg.utils.product_to_platform(prods)[source]
Converts one or more product ids into a string with one or more <platform> elements.
- ssg.utils.read_file_list(path)[source]
Reads the given file path and returns the contents as a list.
- ssg.utils.required_key(_dict, _key)[source]
Returns the value of _key if it is in _dict; otherwise, raise an exception stating that it was not found but is required.