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.

__call__(parser, namespace, values, option_string=None)[source]
__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:
  • d (dict) – the dict to search in
  • path (list) – the path to the key in the dict
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 in d at path to val.

Parameters:
  • d (dict) – the dict to search in
  • path (list) – the path to the key in the dict
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 of separator characters.

Parameters:
  • d (dict) – dict of string keys, string values
  • spaces (int) – number of spaces to separate columns by
  • separator (string) – character to fill in between columns
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:
  • function_ref (function) – the function to call
  • argv (tuple) – the parameters to pass to the function
  • kwargs (dict) – keyword arguments to pass to the function