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 | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
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 |
Close
Hashes for chibi_donkey-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 600b471109fb27950957fc65d0abef27ecf4c8bea831428beada78a104728d1a |
|
MD5 | 7308cbcafbddcac94e73a2a8fa4b8d4d |
|
BLAKE2-256 | 8b48472c0278e60c1a47ee28001eca1d464bb06b85cc8efdcf18d7d5b12b2010 |