Package: kmisc
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 klibInstallpip3installkmiscImport functionsCustom Dictionary ClassConvert Dictionary to Object style DictionaryContentsCreate tree type itemsAdded New commandsPut()    : Put value at a itemGet()    : Get value of itemDel()    : Delete itemUpdate() : Update value at itemPrint()  : Print dictionaryDiff()   : Compare two dictionaryCheck()  : Check put the value is same as the item(key)'s valueList()   : Return list of keys valueProper() : Show/Set/Update property at the item.Find()   : Find data in the dictionaryLoad()   : Load saved data from fileSave()   : dictionary save to fileSort()   : Sort dictionaryFirstKey(): Get first KeyFirstKey(): Get first KeyAdded property at each keyInitialize dictionaryfromkmiscimportkDictroot=kDict.kDict()fromkmiscimportkDict>>>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 colorSet readonly>>>root.tree.apple.color.Proper('readonly',True)Try change data>>>root.tree.apple.Put('color','white')itemisreadonly>>>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)>>>fromkmiscimportkDict>>>kDict.kDict._dfile_='<dict file name>'>>>root.Save()Load Data (always use root if not then load at key)>>>fromkmiscimportkDict>>>kDict.kDict._dfile_='<dict file name>'>>>root.Load()MISC functionsUseful commandsType : Similar as isinstance(,(chk,type))>>>importkmiscaskm>>>km.Type('abc','str')>>>True>>>km.Type('abc',str)>>>TrueCopy: copy data for list,dict,str,int,tuple...>>>new_data=Copy(<data>)Join : Similar as os.path().join()
Joining data of bytes,string,....Next: Get data from list,tuple,dict,stringDelete : Delete data in list,tuple,dict,strCOLOR : class for console,html color stringFIND : find string or format dataDIFF : diff between dataLIST : handle list()STR: handle stringTIME : handle time formatsSHELL : handle command run,progress,....BYTES: handle byte dataCONVERT : data converterMAC : handle mac addressVERSION : handle versionIP : handle IP addressGET: getting data from anywhereIS: check the dataLOG: handle log dataHOST:  handle Host InformationFILE: handle File (Read/Write)WEB: handle web protocol dataEMAIL: handle email dataANSI : handle hansi dataMultiprocessor : handle multi processingFUNCTION: handle function informationSCREEN: handle ipmi SOLCLI : handle Command Line InterfaceCut: cutting string to formatGet: Getting data from anywhereReplace : replace string dataInsert : add dataUpdate: update dataprintf : similar as printf in csprintf : similar as sprintf in cSort : sorting datafindXML : Get XML datacat : similar as linux cat commandls : similar as linux ls commandIsSame: check both data is same or notetc...