Enginering useful library
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. I re-groupped to library. and change name to klib
Install
pip3 install kmisc
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
- Added property at each key
- Initialize dictionary
from DICT import DICT
root=DICT()
or
import DICT
root=DICT.DICT()
from DICT import DICT
>>> test={
'a':123,
'b':{
'c':{'ddd'},
'e':{}
}
}
root=DICT(test)
or
from DICT import DICT
>>> root=DICT()
- 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 DICT import DICT
>>> DICT._dfile_='<dict file name>'
>>> root.Save()
or
>>> import DICT
>>> DICT.DICT._dfile_='<dict file name>'
>>> root.Save()
- Load Data (always use root if not then load at key)
>>> from DICT import DICT
>>> DICT._dfile_='<dict file name>'
>>> root.Load()
or
>>> import DICT
>>> DICT.DICT._dfile_='<dict file name>'
>>> root.Load()
MISC functions
Useful commands
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.
Source Distribution
kmisc-2.1.19.tar.gz
(73.5 kB
view details)
Built Distribution
kmisc-2.1.19-py3-none-any.whl
(88.5 kB
view details)
File details
Details for the file kmisc-2.1.19.tar.gz
.
File metadata
- Download URL: kmisc-2.1.19.tar.gz
- Upload date:
- Size: 73.5 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 | 26fd123af0a5cb3186a2eeed00c3d36ceec01fd3e55d1cd1bf9277ea2c7842ba |
|
MD5 | 87764f86b1fc289704e0488dd96e2595 |
|
BLAKE2b-256 | 1979998b6631849206e9cf8b3cdd6ee12fa471618f56ce5b3398fd9b7b56a985 |
Provenance
File details
Details for the file kmisc-2.1.19-py3-none-any.whl
.
File metadata
- Download URL: kmisc-2.1.19-py3-none-any.whl
- Upload date:
- Size: 88.5 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 | 76e0f40042b1ce4742d45ce91283c8adcd6924c87803f15a351e7042f0099d09 |
|
MD5 | 4b0dbd46ef158caf8da613bdbee8a56e |
|
BLAKE2b-256 | 8504551a8f084f3c95d939ffdc899ce6716a16cb861b827a64dfbaccfc1ff9ee |