Skip to main content

schleppy

Utilities for traversing and transforming data structures

reach(source, pattern, [options])

Converts an object key chain string to reference

  • options - optional settings

    • separator - string to split chain path on, defaults to ‘.’

    • default - value to return if the path or value is not present, default is None

    • strict - if true, will throw an error on missing member, default is False

A pattern including negative numbers will work like negative indices on an array.

If chain is False-y, the object itself will be returned.

from schleppy import reach

pattern = 'a.b.c'
source_obj = {'a' : {'b' : { 'c' : 1}}}

reach(source_obj, pattern) # returns 1

pattern = 'a.b.-1'
source_obj = {'a' : {'b' : [2,3,6]}}

reach(source_obj, pattern) # returns 6

transform(source, transform, [options])

Transforms an existing object into a new one based on the supplied obj and transform map. options are the same as the reach options. The first argument can also be an array of objects. In that case the method will return an array of transformed objects. Note that options.separator will be respected for the keys in the transform object as well as values.

source = {
    'address': {
        'one': '123 main street',
        'two': 'PO Box 1234'
    },
    'title': 'Warehouse',
    'state': 'CA'
}

result = transform(source, {
    'person.address.lineOne': 'address.one',
    'person.address.lineTwo': 'address.two',
    'title': 'title',
    'person.address.region': 'state'
})
# Results in
# {
#     'person': {
#         'address': {
#             'lineOne': '123 main street',
#             'lineTwo': 'PO Box 1234',
#             'region': 'CA'
#         }
#     },
#     'title': 'Warehouse'
# }

Metadata

Release files for schleppy 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schleppy 0.4
File Size Uploaded Provenance
schleppy-0.4.tar.gz 4.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for schleppy 0.4
File Interpreter ABI Platform
schleppy-0.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / schleppy-0.4.tar.gz

Download URL schleppy-0.4.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
57ddfb54c3a44d2e930a03f9ca3f29b8b04ef10adee5da137a0ea3ae3714b6f0
BLAKE2b-256 checksum
How to use checksums
aa3e099a5dc26d1a38270319922804877759ca141b219bcbba32f3464af89db2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.2

Release files / schleppy-0.4-py3-none-any.whl

Download URL schleppy-0.4-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
085880dbe045797e447b4a38cbbbb4e4e0b49e86280593adcb0f9a0a620d6eee
BLAKE2b-256 checksum
How to use checksums
1d297d257d52a361f69323e796c3a870b39b195b202ecd601dc55573807c2801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.2

Security for schleppy 0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page