Package: understreck
UnderstreckA collection of nice utility functions for pythonFree software: GNU General Public License v3Documentation:https://understreck.readthedocs.io.FeaturesPerform a safe get on a nested dictionary with the nested_get functionSplit a list into chunksFilter a list of dictionariesStrip indents from multiline stringsExamplesGet example:import understreck as _

test_dictionary = {
    "foo": {
        "second_level": {"third_level": "it works", "third_level_sibling": False},
        "second_level_list": ["Hello", "World", {"planet": "Earth"}, ["Hello", "World", {"planet": "jupiter"}, ]],
    }
}

# Using dot delimited strings
result = _.get(test_dictionary, "foo.second_level.third_level")  # result == "it works"
result = _.get(test_dictionary, "foo.second_level.DOES_NOT_EXIST")  # result == None

# Using a list or tuple
result = _.get(test_dictionary, ["foo", "second_level", "third_level"])  # result == "it works"
result = _.get(test_dictionary, ["foo", "second_level", "DOES_NOT_EXIST"])  # result == None

# Getting elements in list

result = _.get(test_dictionary, "foo.second_level_list[0]")  # result == "Hello"
result = _.get(test_dictionary, "foo.second_level_list[1]")  # result == "World"
result = _.get(test_dictionary, "foo.second_level_list[2].planet")  # result == "Earth"

# Getting a property in a nested list
nested_list = {
                "foo": {
                    "bar": [
                        "x", [
                            "first", "second", {"name": "Hello World"}
                        ]
                    ]
                }
              }

result = _.get(nested_list, "foo.bar[1][2].name")  # result == "Hello World"Chunks example:import understreck as _

to_chunk = ["one", "two", "three", "four", "five"]
result = _.chunks.split(to_chunk, 2)  # result == [["one", "two", "three"], ["four", "five"]]Filter example:import understreck as _

users = [
        {"user": "barney", "age": 36, "active": True},
        {"user": "fred", "age": 40, "active": False},
    ]

# Using a lambda function
result = _.filter(users, lambda x: not x.get("active"))  # result == [{"user": "fred", "age": 40, "active": False}]

# Using partial dictionary
result = _.filter(users, {"age": 36, "active": True})  # result == [{"user": "barney", "age": 36, "active": True}]

# Using a list with a property name and value
result = _.filter(users, ["active", False])  # result == [{"user": "fred", "age": 40, "active": False}]

# Using a list with a property name. The value must be truthy.
result = _.filter(users, ["active"])  # result == [{"user": "barney", "age": 36, "active": True}]Strip indents example:import understreck as _

def some_function():
    to_strip = """This is a
    multi-line
    string"""

    _.strip(to_strip)  # "This is a\nmulti-line\nstring"CreditsI have to credit theLodashproject for inspiration!This package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.HistoryUnreleased1.0.0 (2020-03-03)Get elements from nested lists0.5.1 (2019-11-09)Updates dev dependencies0.5.0 (2019-05-03)Updates dev dependenciesMoves to the new repository0.4.0 (2019-05-03)Adds Understreck.strip that strips indents0.3.0 (2019-05-03)Adds Understreck.filter with inspired byhttps://lodash.com/docs/4.17.11#filterUpdated the travis button URLReplaced nested_get with get in the README. (nested_get still works)Black formatting0.2.1 (2018-12-10)Add Understreck.chunks0.2.0 (2018-11-12)Add get as an alias for nested get0.1.1 (2018-11-02)Update the readme0.1.0 (2018-11-02)First release on PyPI.