awslimitchecker.utils module¶
-
class
awslimitchecker.utils.
StoreKeyValuePair
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶ Bases:
argparse.Action
Store key=value options in a dict as {‘key’: ‘value’}.
Supports specifying the option multiple times, but NOT with
nargs
.See
Action
.-
__init__
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶
-
__module__
= 'awslimitchecker.utils'¶
-
-
awslimitchecker.utils.
_get_dict_value_by_path
(d, path)[source]¶ Given a dict (
d
) and a list specifying the hierarchical path to a key in that dict (path
), return the value at that path or None if it does not exist.Parameters:
-
awslimitchecker.utils.
_get_latest_version
()[source]¶ Attempt to retrieve the latest awslimitchecker version from PyPI, timing out after 4 seconds. If the version can be retrieved and is greater than the currently running version, return it as a string. If the version cannot be retrieved or is not greater than the currently running version, return None.
This function MUST not ever raise an exception.
Returns: latest version from PyPI, if newer than current version Return type: str or None
-
awslimitchecker.utils.
_set_dict_value_by_path
(d, val, path)[source]¶ Given a dict (
d
), a value (val
), and a list specifying the hierarchical path to a key in that dict (path
), set the value ind
atpath
toval
.Parameters: Raises: TypeError if the path is too short
Returns: the modified dict
-
awslimitchecker.utils.
dict2cols
(d, spaces=2, separator=' ')[source]¶ Take a dict of string keys and string values, and return a string with them formatted as two columns separated by at least
spaces
number ofseparator
characters.Parameters:
-
awslimitchecker.utils.
paginate_dict
(function_ref, *argv, **kwargs)[source]¶ Paginate through a query that returns a dict result, and return the combined result.
Note that this function requires some special kwargs to be passed in:
- __alc_marker_path__ - The dictionary path to the Marker for the next result set. If this path does not exist, the raw result will be returned.
- __alc_data_path__ - The dictionary path to the list containing the query results. This will be updated with the results of subsequent queries.
- __alc_marker_param__ - The parameter name to pass to
function_ref
with the marker value.
These paths should be lists, in a form usable by
_get_dict_value_by_path()
.Parameters: