How to use the dotmap.DotMap.__str__ function in dotmap

To help you get started, we’ve selected a few dotmap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thulio / dict-to-csv / dict_to_csv / __init__.py View on Github external
import collections
import functools
import typing  # noqa: F401
from contextlib import closing
from io import StringIO

from dotmap import DotMap


def empty_str(_):
    # type: (typing.Any) -> typing.Text
    return ""


DotMap.__str__ = empty_str


def recursive_mapping_iterator(nested_mapping):
    # type: (typing.Mapping) -> typing.Generator[typing.Tuple[typing.Text, typing.Any], None, None]  # noqa: E501
    for key, value in nested_mapping.items():
        if isinstance(value, collections.Mapping):
            for inner_key, inner_value in recursive_mapping_iterator(value):
                yield key + '.' + inner_key, inner_value
        else:
            yield key, value


def recursive_getattr(obj, attributes):
    # type: (typing.Any, typing.Text) -> typing.Any
    return functools.reduce(getattr, [obj] + attributes.split('.'))

dotmap

ordered, dynamically-expandable dot-access dictionary

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages