Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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


Release history Release notifications

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.0
Filename, size File type Python version Upload date Hashes
Filename, size chibi_donkey-1.0.0-py3-none-any.whl (4.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page