smalldict package

Submodules

smalldict.smalldict module

class smalldict.smalldict.SmallDict(d)[source]

Bases: object

SmallDict

Parameters

d (Any) – The source data, typically a nested dict and/or list, or path to a file, either JSON (.json) or YAML (.yaml, .yml).

__init__(d)

Initialize self. See help(type(self)) for accurate signature.

d: Any
get(dict_limit=None, list_limit=None, str_limit=None, json_out=None, yaml_out=None)[source]

Apply limit to the source data recursively for dict or list.

Parameters
  • dict_limit (Optional[int]) – Limit number of dict items. Defaults to None.

  • list_limit (Optional[int]) – Limit number of list items. Defaults to None.

  • str_limit (Optional[int]) – Limit length for str values. Defaults to None.

  • json_out (Optional[str]) – Path to the output JSON file. Defaults to None.

  • yaml_out (Optional[str]) – Path to the output YAML file. Defaults to None.

Return type

Any

Returns

The processed data.

smalldict.smalldict.slim_dict(d, dict_limit=None, list_limit=None, str_limit=None)[source]

Apply limit to the source data recursively for dict or list.

Parameters
  • d (Any) – The source data, typically a nested dict and/or list.

  • dict_limit (Optional[int]) – Limit number of dict items. Defaults to None.

  • list_limit (Optional[int]) – Limit number of list items. Defaults to None.

  • str_limit (Optional[int]) – Limit length for str values. Defaults to None.

Return type

Any

Returns

The processed data.