Skip to main content

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

Import functions

Custom Dictionary Class

Convert Dictionary to Object style Dictionary

Contents

  1. Create tree type items
  2. Added New commands
    1. Put() : Put value at a item
    2. Get() : Get value of item
    3. Del() : Delete item
    4. Update() : Update value at item
    5. Print() : Print dictionary
    6. Diff() : Compare two dictionary
    7. Check() : Check put the value is same as the item(key)'s value
    8. List() : Return list of keys value
    9. Proper() : Show/Set/Update property at the item.
    10. Find() : Find data in the dictionary
    11. Load() : Load saved data from file
    12. Save() : dictionary save to file
    13. Sort() : Sort dictionary
    14. FirstKey(): Get first Key
    15. FirstKey(): Get first Key
  3. 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()

MISC functions

Useful commands

Type : Similar as isinstance(,(chk,type))

>>> import kmisc as km
>>> km.Type('abc','str')
>>> True
>>> km.Type('abc',str)
>>> True

Copy: 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,string

Delete : Delete data in list,tuple,dict,str

COLOR : class for console,html color string

FIND : find string or format data

DIFF : diff between data

LIST : handle list()

STR: handle string

TIME : handle time formats

SHELL : handle command run,progress,....

BYTES: handle byte data

CONVERT : data converter

MAC : handle mac address

VERSION : handle version

IP : handle IP address

GET: getting data from anywhere

IS: check the data

LOG: handle log data

HOST: handle Host Information

FILE: handle File (Read/Write)

WEB: handle web protocol data

EMAIL: handle email data

ANSI : handle hansi data

Multiprocessor : handle multi processing

FUNCTION: handle function information

SCREEN: handle ipmi SOL

CLI : handle Command Line Interface

Cut: cutting string to format

Get: Getting data from anywhere

Replace : replace string data

Insert : add data

Update: update data

printf : similar as printf in c

sprintf : similar as sprintf in c

Sort : sorting data

findXML : Get XML data

cat : similar as linux cat command

ls : similar as linux ls command

IsSame: check both data is same or not

etc...

Release files for kmisc 2.1.129

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kmisc 2.1.129
File Size Uploaded
kmisc-2.1.129.tar.gz 43.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kmisc 2.1.129
File Interpreter ABI Platform
kmisc-2.1.129-py3-none-any.whl Python 3 none any Details

Total release size: 84.1 kB

Release files / kmisc-2.1.129.tar.gz

Download URL kmisc-2.1.129.tar.gz
Size 43.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dedd2e30e26807854adca2cfe34d140c13b542289dd2da774e2185737b6c6b7e
BLAKE2b-256 checksum
How to use checksums
2a831533a0278cf0188b34cd86b86dd819d21b57c65e9bf69d61359d45f3e5f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Release files / kmisc-2.1.129-py3-none-any.whl

Download URL kmisc-2.1.129-py3-none-any.whl
Size 40.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74f9fd081727a9e77ee831bac2ba3a046cce17424fc450aef7ebd94b02f61a9d
BLAKE2b-256 checksum
How to use checksums
7e985b77b48d8cf28f0496b70423edb93f0afbcad597a545fe30dfe6cb83adc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Release history Release notifications | RSS feed

This release

2.1.129 This release

2 release files

2.1.99

2 release files

2.1.94

2 release files

2.1.93

2 release files

2.1.92

2 release files

2.1.91

2 release files

2.1.90

2 release files

2.1.88

2 release files

2.1.82

2 release files

2.1.81

2 release files

2.1.79

2 release files

2.1.76

2 release files

2.1.75

2 release files

2.1.74

2 release files

2.1.73

2 release files

2.1.72

2 release files

2.1.71

2 release files

2.1.69

2 release files

2.1.68

2 release files

2.1.67

2 release files

2.1.66

2 release files

2.1.65

2 release files

2.1.62

2 release files

2.1.61

2 release files

2.1.60

2 release files

2.1.59

2 release files

2.1.53

2 release files

2.1.52

2 release files

2.1.51

2 release files

2.1.43

2 release files

2.1.41

2 release files

2.1.40

2 release files

2.1.31

2 release files

2.1.29

2 release files

2.1.27

2 release files

2.1.26

2 release files

2.1.25

2 release files

2.1.24

2 release files

2.1.23

2 release files

2.1.22

2 release files

2.1.21

2 release files

2.1.20

2 release files

2.1.19

2 release files

2.1.18

2 release files

2.1.17

2 release files

2.1.16

2 release files

2.1.15

2 release files

2.1.14

2 release files

2.1.13

2 release files

2.1.12

2 release files

2.1.11

2 release files

2.1.10

2 release files

2.1.9

2 release files

2.1.8

2 release files

2.1.7

2 release files

2.1.3

2 release files

2.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page