Skip to main content

library for proccess the format double undescore

Project description

small lib for inflate and compress dict using double underscore or proccess string using the format double undescore

how to used with dict

import chibi_donkey as donkey

example = {
        'a': {
                'aa': {
                        'aaa': 'aaa',
                        'aab': 'aab',
                        'aac': 'aac'
                'ab': 'ab',
                'ac': None,
                'b': {
                'ba': [ 1, 2, 3 ],
                'bb': 'bb',
                'bc': None,

example_compress= {
        'a__aa__aaa': 'aaa',
        'a__aa__aab': 'aab',
        'a__aa__aac': 'aac',
        'a__ab': 'ab',
        'a__ac': None,
        'b__ba': [ 1, 2, 3 ],
        'b__bb': 'bb',
        'b__bc': None,

assert donkey.compress( example ) == example_compress
assert donkey.inflate( example_compress ) == example

assert donkey.get( 'a__aa__aaa', example ) == 'aaa'
assert donkey.get( 'a__ba', example ) == [ 1, 2, 3 ]

donkey.setter( 'a__aa__aaa', example, 'asdf' )
assert donkey.get( 'a__aa__aaa', example ) == 'asdf'

how to use with strings

import chibi_donkey as donkey

assert donkey.init( 'a__b__c' ) == 'a'
assert donkey.last( 'a__b__c' ) == 'c'

assert donkey.key( 'a', 'b', 'c' ) == 'a__b__c'
assert donkey.partition( 'a__b__c' ) == [ 'a', 'b', 'c' ]

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for chibi-donkey, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size chibi_donkey-1.0.1.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View
Filename, size chibi_donkey-1.0.1-py2.py3-none-any.whl (6.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page