Extended Dictionary
Project description
Open Kage's useful tools and class to public. (Long time used and upgraded) But, this is develope version. So, suddenly it will be big change when I got some more good idea. seperate to kDict from kmisc
Install
pip3 install kDict
Custom Dictionary Class
Convert Dictionary to Object style Dictionary
Contents
- Create tree type items
- Added New commands
- Put() : Put value at a item
- Get() : Get value of item
- Del() : Delete item
- Update() : Update value at item
- Print() : Print dictionary
- Diff() : Compare two dictionary
- Check() : Check put the value is same as the item(key)'s value
- List() : Return list of keys value
- Proper() : Show/Set/Update property at the item.
- Find() : Find data in the dictionary
- Load() : Load saved data from file
- Save() : dictionary save to file
- Sort() : Sort dictionary
- FirstKey(): Get first Key
- FirstKey(): Get first Key
- Added property at each key
- Initialize dictionary
from kmisc import kDict
root=kDict.kDict()
from kmisc import kDict
>>> test={
'a':123,
'b':{
'c':{'ddd'},
'e':{}
}
}
root=kDict.kDict(test)
- Add new data
>>> root.tree.apple.color='red'
or
>>> root.tree.apple.Put('color','red')
or
>>> root.tree.apple['color']='red'
- Get data
>>> root.tree.apple.color.Get()
or
>>> root.tree.apple.Get('color')
- Print dictionary
>>> root.Print()
>>> root.tree.Print()
-
Set property at Apple's color
- Set readonly
>>> root.tree.apple.color.Proper('readonly',True)
- Try change data
>>> root.tree.apple.Put('color','white')
item is readonly
>>> root.tree.Print()
{'color': {'._d': 'red', '._p': {'readonly': True}}}
- Unset readonly
>>> root.tree.apple.color.Proper('readonly',False)
- Try change data
>>> root.tree.apple.Put('color','white')
>>> root.tree.Print()
{'color': {'._d': 'red', '._p': {'readonly': True}}}
Sample Dictionary:
{'a': 123,
'b': {'c': set(['ddd']), 'e': {}, 'z': 123},
'tree': {'apple': {'color': {'._d': 'white', '._p': {'readonly': False}}},
'banana': {'banana2': {'._d': 'white', '._p': {}},
'banana3': {'._d': 'yellow', '._p': {}},
'color': {'._d': 'yellow', '._p': {'readonly': True}}},
'yellow': {'monkey': {'._d': 'white', '._p': {}}}}}
- Find readonly property item path
>>> root.Find('readonly',property=True)
['tree/banana/color']
- Find apple key path
>>> root.Find('apple',mode='key')
['tree/apple']
- Find white color data path
>>> root.Find('white')
['tree/apple/color', 'tree/yellow/monkey', 'tree/banana/banana2']
- Find 123 data path
>>> root.Find('white')
['a', 'b/z']
- Find white color data path in key and value
>>> root.Find('yellow',mode='all')
['tree/yellow', 'tree/banana/color', 'tree/banana/banana3']
- Save Data (always use root if not then save partial data)
>>> from kmisc import kDict
>>> kDict.kDict._dfile_='<dict file name>'
>>> root.Save()
- Load Data (always use root if not then load at key)
>>> from kmisc import kDict
>>> kDict.kDict._dfile_='<dict file name>'
>>> root.Load()
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kDic-1.0.4.tar.gz.
File metadata
- Download URL: kDic-1.0.4.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.20.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afd1c0314928c618ed978481bad3912b6baa491a592dd6bdf57a30c921a53441
|
|
| MD5 |
0586bf833c53f445fd1db3b8c86caea9
|
|
| BLAKE2b-256 |
15dd6d8d0d842ae82f2e29cd5ca7be2b0e19488a681c8a67984c1ba5dbff5ca5
|
File details
Details for the file kDic-1.0.4-py3-none-any.whl.
File metadata
- Download URL: kDic-1.0.4-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.20.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
179a47a8d4ae6ec738863baaa4c172f92c25985477e0a586533ca29fec95a204
|
|
| MD5 |
4ba2bfcf8210c136dfe2d49423f7045a
|
|
| BLAKE2b-256 |
a752758dcc4adc58edb230dab4f1db7a1b47a8e214ff1ff8e7d3b2d97f689824
|