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.

Source Distribution

chibi_donkey-1.0.1.tar.gz (4.3 kB view hashes)

Uploaded source

Built Distribution

chibi_donkey-1.0.1-py2.py3-none-any.whl (6.1 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page