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.
make to seperate to Import from kmisc
# Install
```javascript
pip3 install kmport
```
# Functions
## Global()
Method's global variables
## StdOut(msg)
Standard Output Print without new line symbol
## def StdErr(msg)
Standard Error Print without new line symbol
## PyVer(main=None,miner=None,msym=None)
python version check
```
ex)
if PyVer(3): # If Python version 3 then ...
~~~
```
## find_executable(executable,path=None)
Find Excuatable command location
```
ex)
if find_executable('ping'): # if ping command is in the system
~~~
ping_path=find_executable('ping') # Get ping command full path
```
## ByteName(src)
Get Byte type name
## Bytes(src,**opts)
Convert data to bytes data
## Str(src,**opts)
Convert data to String data
## Int(i,default='org',sym=None,err=False):
Convert data to Int data when possible. if not then return default (original data)
support data type: int,float,digit number,list,tuple
default: (default org)
org : fail then return or keeping the input data
True,False,None: fail then return default value in single data or ignore the item in list
sym : split symbol when input is string
err :
False: replace data for possible positions
True : if convert error in list/tuple then return default
## Join(*inps,symbol='_-_',byte=None,ignore_data=(),append_front='',append_end='')
Similar as join function.
```
ex)
Join(['a','b','c'],' ') same as ' '.join(['a','b','c'])
Join(['a','b','c'],'\n',append_front=' ')
Output:
a
b
c
Join(['a','b','c'],'\n',append_end=' ')
Output:
a<newline>
b <newline>
c <newline>
Join(['a','b','c'],'\n',append_front=' ',ignore_data=['b']) # Ignore 'b' data
Output:
a
c
```
## FixIndex(src,idx,default=False,err=False):
Find Index number in the list,tuple,str,dict
default : if wrong or error then return default
err : default False
False: fixing index to correcting index without error
True: if wrong index then return default value
## Next(src,step=0,out=None,default='org')
Get Next data or first key of the dict
```
ex) get send data in the list
Next([1,2,3,4],step=1)
Output:
2
ex) get dictionary key
Next({'a':1})
Output:
a
Next({'a':1,'b':2},step=2)
Output:
b
```
## Copy(src)
Copy data
```
a={'a':1,'b':2}
b=Copy(a)
```
## TypeName(obj)
Get input's Type,Instance's name
```
TypeName(1) # int
TypeName('1') # str
TypeName(int) # int
TypeName('int') # int
TypeName(str) # str
TypeName('str') # str
def abc(): pass
TypeName(abc) # function
class cc:
def AA(): pass
TypeName(cc) # classobj
import os
TypeName(os) # module
...
```
## Type(*inps,**opts):
Similar as isinstance(A,())
support : basic type and ('byte','bytes'),('obj','object'),('func','unboundmethod','function'),('classobj','class'),'generator','method','long',....
## FIND(src).Find(find,src='_#_',sym='\n',default=[],out=None,findall=True,word=False,mode='value',prs=None,line_num=False,peel=None,idx=None)
Searching regular expression form data and return the data
## Found(data,find,digitstring=False,word=False,white_space=True,sense=True,location=False):
if found <find> in <data> then return True, not then False
If find "[All]" then you can type "\[All\]" at the <find> location
if not then "[]" will be work with re expression
<find> rule:
re.compile regular expression
any keep characters : *
any single character : ?
^ : start
$ : end
<option>
sense : True:(default) sensetive, False: lower and upper is same
white_space : True:(default) keep white_space, False: ignore white_space
word : True: <find> is correct word, False:(default) <find> in insde string
digitstring : True: string and intiger is same, False:(default) different
location : True: return found location ex:(3,10), False:(default) return True/False
## IsSame(src,dest,sense=False,order=False,Type=False,digitstring=True,white_space=False,**opts):
return True/False
Check same data or not between src and dest datas
<dest> rule:
re.compile format
any keep characters : *
any single character : ?
^ : start
$ : end
<option>
order : True: if list,tuple then check ordering too, False:(default) just check data is same or not
Type : True: check Type only, False:(default) check data
sense : True: sensetive, False:(default) lower and upper is same
white_space : True: keep white space, False:(default) ignore white_space
digitstring : True:(default) string and intiger is same, False: different
## IsIn(find,dest,idx=False,default=False,sense=False,startswith=True,endswith=True,Type=False,digitstring=True,word=True,white_space=False,order=False)
Check key or value in the dict, list or tuple then True, not then False
<find> can use IsSame's <dest> rule
```
IsIn('abc',['AC','abc','uuu']): True ('abc' in the list['AC','abc','uuu'])
IsIn('a*c',['AC','abc','uuu']): True ('a*c' in the list['AC','abc','uuu'])
```
## WhiteStrip(src,mode=True):
remove multi space to single space, remove first and end space
others return original
## IsNone(src,**opts):
Check the SRC is similar None type data('',None) or not
-check_type=<type> : include above and if different type then the return True
-list_none :
- False: check index item in the source (default)
- True : check all list of source
-index : if source is list then just want check index item
-space :
- True : aprove space to data in source
- False: ignore space data in source
```
IsNone('') : True
IsNone(None) : True
IsNone([]) : True
IsNone({}) : True
IsNone(0) : False
IsNone(False): False
```
## IsVar(src,obj=None,default=False,mode='all',parent=0)
Check the input(src) is Variable name or not (in OBJ or in my function)
```
g=9
def abc(c=5):
b=3
IsVar('b') : True
IsVar('c') : True
IsVar('g') : True
IsVar('m') : False
class AA:
def __init__(self):
self.abc=1111
IsVar('abc',AA()) : True ('abc' is a variable in the AA class)
```
## IsFunction(src,find='_#_')
Check the find is a Function in the src object(module,class)
```
def abc(): pass
IsFunction('abc') : False ('abc' is not a function)
IsFunction(abc) : True (abc is a function)
IsFunction(MyModule(),'abc') : True ('abc' is a function in my module)
IsFunction(MyModule(),abc) : True (abc is a function in my module)
IsFunction(MyModule(),'abcd') : False (not found 'abcd' in my module)
```
## IsBytes(src)
Check data is Bytes or not
## IsInt(src,mode='all'):
Check data is Int or not
- mode : int => check only int
str => int type string only
all => Int and int type string
## Dict(*inp,**opt):
Dictionary
- Define
- marge
- Update
- Append
support : Dict, list or tuple with 2 data, dict_items, Django request.data, request data, like path type list([('/a/b',2),('/a/c',3),...]), kDict
## CompVersion(*inp,**opts):
input: source, compare_symbol(>x,<x,==,!xx), destination
return BOOL
input: source, destination, compare_symbol='>x,<x,==,!xx'
return BOOL
input: source, destination
- without compare_symbol
- out=sym : return symbol (>, ==, <) (default)
- out=int : return 1(>), 0(==), -1(<)
- out=str : return bigger(>), same(==), lower(<)
input: source
- out=str : return '3.0.1' (default)
- out=tuple : return to tuple type (3,0,1)
- out=list : return to list type [3,0,1]
version_symbol or symbol : default '.'
sort list
<list>.sort(key=CompVersion) or sorted(<list>,key=CompVersion)
## ModVersion(mod)
Find Module Version
## Install(module,install_account='',mode=None,upgrade=False,version=None,force=False,pkg_map=None,err=False):
Install python module file
module name
install_accout='' : default None, --user : install on account's directory
upgrade :
False : default
True : Install or Upgrade the module
version :
None : default
<version>: Check the version
== <version> : if not Same version then install at the same version
>= <version> : if not bigger the version then install or upgrade
<= <version> : if not lower the version then install at the version
force : default False
True : if installed then force re-install, not then install
pkg_map: mapping package name and real package name
format => { <pkg name>: <real install pkg name> }
err : default False
True : if installing got any isseu then crashing
False: if installing got any issue then return False
## Import(*inps,**opts):
basic function of import
if not found the module then automaticall install
version check and upgrade, reinstall according to the version
support requirement files
inps has "require <require file>" then install the all require files in <require file>
Import('<module name> >= <version>') : Check version and lower then automaticall upgrade
Import('<module name> == <version>') : Check version and different then automaticall reinstall with the version
Import('<module name>',path='AAA,BBB,CCCC') : import <module name> from default and extra AAA and BBB and CCC.
-path= : searching and the module in the extra path (seperate with ',' or ':' )
-force=True : unload and load again when already loaded (default: False)
-reload=True : run reload when already loaded (default: False)
-unload=True : unload module (default : False)
-err=True : show install or loading error (default: False)
-dbg=True : show comment (default : False)
-install_account=: '--user','user','myaccount','account',myself then install at my local account
default: Install by System default setting
## MethodInClass(class_name)
Get Method list in Class
## ObjInfo(obj)
Get object information
type, name, method list, path, module_name, module_version, module
```
import requests
ObjInfo(requests)
Output:
{'type': 'module', 'name': 'requests', 'methods': ['ConnectTimeout', 'ConnectionError', 'DependencyWarning', 'FileModeWarning', 'HTTPError', 'JSONDecodeError', 'NullHandler', 'PreparedRequest', 'ReadTimeout', 'Request', 'RequestException', 'RequestsDependencyWarning', 'Response', 'Session', 'Timeout', 'TooManyRedirects', 'URLRequired', '__author__', '__author_email__', '__build__', '__builtins__', '__cached__', '__cake__', '__copyright__', '__description__', '__doc__', '__file__', '__license__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__title__', '__url__', '__version__', '_check_cryptography', '_internal_utils', 'adapters', 'api', 'auth', 'certs', 'chardet_version', 'charset_normalizer_version', 'check_compatibility', 'codes', 'compat', 'cookies', 'delete', 'exceptions', 'get', 'head', 'hooks', 'logging', 'models', 'options', 'packages', 'patch', 'post', 'put', 'request', 'session', 'sessions', 'ssl', 'status_codes', 'structures', 'urllib3', 'utils', 'warnings'], 'path': ['/usr/lib/python3.10/site-packages/requests'], 'version': '2.27.1', 'module_name': 'requests', 'module': <module 'requests' from '/usr/lib/python3.10/site-packages/requests/__init__.py'>}
```
## MyModule(default=False,parent=-1):
Get current module
- parent
-1 : my current python page's module
0 : my function's module
1 : my parent's module
## CallerName(default=False,detail=False):
Get the caller name of my group function
detail=True: return (func name, line number, filename)
default : If not found caller name then return default
def A(): #Group A()
CallerName() -> Called by module's A() => A
B()
def B(): #Group B()
CallerName() -> Called my group by A() function => A
def C():
CallerName() -> Called my group by A() function => A
C()
A() -> Calling def A() in python script(module)
## Frame2Function(obj,default=False):
Get Function Object from frame or frame info
## FunctionName(parent=0,default=False,history=0,tree=False,args=False,line_number=False,filename=False,obj=False,show=False):
Get function name
- parent
0 : my name (default)
1 : my parent function
... : going top parent function
- history : Getting history (return list)
- tree : tree (return list)
- show : show tree on screen
- args : show arguments
- line_number : show line number
- filename : show filename
- obj : Get OBJ (return list)
## FunctionList(obj=None)
Get function list in this object
## GetClass(obj,default=None)
Get Class object from instance,method,function
## FunctionArgs(func,**opts):
Get function's input Arguments
- mode
- defaults : get default (V=?,...)
- args : get args (V,V2,...)
- varargs : get varargs (*V)
- keywords : get keywords (**V)
- string : return arguments to string format
- list,tuple: return arguments to list format
default output : dictioniary format
- default : if nothing then return default value (default None)
## Args(src,field='all',default={}):
Get Class, instance's global arguments
Get Function input parameters
## Variable(src=None,obj=None,parent=0,history=False,default=False,mode='local',VarType=None,alltype=True):
Get available variable data
- src:
if None: return whole environment (dict)
if string then find the string variable in the environment
if variable then return that
- parent
0 : my function (default)
1 : my parents function
...
- history: from me to my top of the functions
- mode : variable area
local : function's local(inside) variable
global: function's global variable
## Uniq(src,default='org'):
make to uniq data
## Split(src,sym,default=None,sym_spliter='|'):
multipul split then 'a|b|...'
without "|" then same as string split function
## FormData(src,default=None,want_type=None):
convert string data to format
'1' => 1
json string to json format
"{'a':1}" => {'a':1}
"[1,2,3]" => [1,2,3]
....
## IndexForm(idx,idx_only=False,symbol=None):
return : <True/False>, Index Data
- False: not found Index form from input idx
- True : found Index
Index Data
- tuple(A,B) : Range Index (A~B)
- list [A,B] : OR Index or keys A or B
- Single : int: Index, others: key
- idx_only : only return integer index
- symbol : default None, if idx is string and want split with symbol
## Get(*inps,**opts):
Get (Any) something
Get('whoami') : return my function name
Get('funclist'): return my module's function list
- parent=1 : my parent's function list
Get(<list|string|dict|int|...>,<index|key|keypath>): Get data at the <index|key|keypath>
- keypath : '/a/b/c' => {'a':{'b':{'c':1,'d'}}} => return c's 1
Get('_this_',<key>): my functions's <key>
Get('<var name>') : return variable data
Get('_this_','args') : return my functions Arguments
Get(<function>,'args') : return the functions Arguments
<option>
default : None, any issue
## ExceptMessage(msg='',default=None):
Try:
AAA
Except:
err=ExceptMessage() => If excepting then taken error or traceback code and return it
## IpV4(ip,out='str',default=False,port=None,bmc=False,used=False,pool=None):
check/convert IP
ip : int, str, ...
out:
str : default : convert to xxx.xxx.xxx.xxx format
int : convert to int format
hex : convert to hex format
port: if you want check the IP with port then type
bmc : default False, True: check BMC port (623,664,443)
return : IP, if fail then return default value
used:
* required port option, but check with single port
False: default (not check)
True: Check IP already used the port(return True) or still available(return False)
pool: if give IP Pool(tuple) then check the IP is in the POOL or not.
## ping(host,**opts)
same as ping command
log_format='ping' : print ping output on screen
ping('<IP>',log_format='ping') : print ping output
ping('<IP>',count=5) : 5 times pinging then return True not then return False
ping('<IP>',timeout=50) : pinging then return True and passing 50 seconds then return False
ping('<IP>',keep_good=50,timeout=3600) : if keep pinging 50 seconds then return True in the 1hour.
## WEB
import requests
Web=WEB(requests)
Web.GetIP() : get my web server IP
Web.GetIP(mode='client') : get client IP
Web.Method() : return method name(get,post,...)
Web.Method(mode='upper') : return method name (GET,POST,...)
Web.Method('GET') : if requests' method is GET then return True, not then False
Web.Request('<host_url>') : return requests' output
WEB().str2url(<string>): if some special character then convert to URL
WEB().form2dict(<request.form>) : return form data to dictionary.
## TIME()
TIME().Int() : Now second time
TIME().Rset() : Reset initial Time
TIME().Format('<time format>') : return format time current time
TIME().Format('<time format>',time=<int>) : return format time from time
TIME().Format('<time format>',read_format='<time format>',time='<format time>'): Read time using read_format and return want time format (covert time format)
TIME().Time() : Same as time.time()
TIME().Datetime(): Sameas datetime.datetime()
Timeout example)
```
timeout=30
Time=TIME()
while True:
if Time.Out(timeout): break
~~~
Time.Sleep(1)
```
## rshell(cmd,timeout=None,ansi=True,path=None,progress=False,progress_pre_new_line=False,progress_post_new_line=False,log=None,progress_interval=5,cd=False,default_timeout=3600):
Run a shell command
## sprintf(string,*inps,**opts):
"""ipmitool -H %(ipmi_ip)s -U %(ipmi_user)s -P '%(ipmi_pass)s' """%(**opts)
"""{app} -H {ipmi_ip} -U {ipmi_user} -P '{ipmi_pass}' """.format(**opts)
"""{} -H {} -U {} -P '{}' """.format(*inps)
"""{0} -H {1} -U {2} -P '{3}' """.format(*inps)
## Sort(src,reverse=False,func=None,order=None,field=None,base='key',sym=None):
Sorting data
reverse=True: reverse sort
field=<num> : Sorting by tuple's index number(field) data in list
order
int : sorting by integer style
str : sorting by string style
len : sorting by string's length
base='key': (default), sort by key, 'value': sort by data for dictionary case
sym=<split symbol>: if src is string with symbol then automatically split with that symbol and sorting.
## MacV4(src,**opts):
Check Mac address format and convert
Hex to Int
Hex to Mac string
Mac string to Int
symbol : default ':' mac address spliter symbol
out :
str : default : XX:XX:XX:XX:XX format
int : integer format
default : False
case :
upper : upper case output
lower : lower case output
## Path(*inp,**opts):
Get Path of input
inputs)
~ : home path
~<user> : user's home path
None : current path
__file__: current python script file path
__mod__ : This python script file path
file : the file's path
[list] : convert to path rule
obj : support function, module, class, instance
remove_dot :
True : (default) /a/b/./../c => /a/c
False: /a/b/./../c => /a/b/./../c
error :
False: default, if path issue then return error
True : if path issue then ignore
out :
str : default: return path string
list: return list format
- force_root : default False, True: ['','a','b'] or ['a','b'] => '/a/b'
'/a/b/c' => ['','a','b','c'] (out=list)
'a/b/c' => ['a','b','c'] (out=list)
['','a','b','c'] => '/a/b/c'(out=str)
['a','b','c'] => 'a/b/c' (out=str)
## Cut(src,head_len=None,body_len=None,new_line='\n',out=str):
Cut string
head_len : int : first line length (default None)
if body_len is None then everything cut same length with head_len
body_len : int : line length after head_len (default None)
new_line : default linux new line
out=
str : output to string with new_line (default)
list : output to list instead new_line
## Space(num=4,fill=None,mode='space',tap=''):
make a charactor(space, tap) group
num: default 4, how many fill out <fill>
mode:
space : default: ' '
tap : \\t
fill:
None : default: following mode information
<special charactor> : fill out the charactor
tap:
'' : default
<spcial inital chractor>: pre-fillout with this chractor
## WrapString(string,fspace=0,nspace=0,new_line='\n',flength=0,nlength=0,ntap=0,NFLT=False,mode='space',default=''):
## GetKey(src,find=None,default=None,mode='first',root=None):
Get key from dict,list,tuple,str
find : if matched value then return the key/index of the data
mode :
first : default: return first find
all : return found all
default : return when not found
## rm(*args,**opts):
delete local file with option like as CLI
[<opt>] <files>/<directory>
-f : don't ask delete
-r : <directory> or recurring delete
delete local file with option like as Function
<files>/<directory>,...
force=True : don't ask delete, default False
recurring=True: <directory> or recurring delete
delete list/tuple
<list,tuple>,<del items>,...
option)
data
True : delete data like as <del items>
False: (default) delete index (<del items> are int)
delete dict
<dict>,<del items>,...
option)
data
True : delete data like as <del items>
False: (default) delete key like as <del items>
recurring
False: searching data in first level
True : keep searching inside dictionary
## List(*inps,**opts):
tuple2list:
True : convert tuple data to list data
False: append tuple into list
<dict input>
items : <dict>.items()
data : <dict>.value()
path : convert <dict> to path like list ([('/a/b',1),('/a/c',2),...])
(default): <dict>.keys()
<option>
idx=<int> : get <idx> data
del=<int> : delete <idx>
first=<data> : move <data> to first
end=<data> : move <data> to end
find=<data> : get Index list
default : False
mode
auto : auto fixing index
err : not found then return default(False)
ignore : not found then ignore the data
## Replace(src,replace_what,replace_to,default=None,newline='\n'):
replace string (src, from, to)
if not string then return default
default: return defined value when not string
'org': return src
... : return defined default
## OutFormat(data,out=None,strip=False,peel=None):
Output Format maker
<option>
out
None: Not convert
str,int,list,dict : convert data to want format
raw : Peeled data when single data(['a'],('a'),{'a':'abc'}) others then return orignal
peel
None : automatically working according to out
True : Peeling data
False: Not Peeling
strip
False: not remove white space
True : remove white space
## FeedFunc(obj,*inps,**opts):
Automatically Feed matched variables to function
FeedFunc(<func>,<function's arguments>,<function's variables>)
if something wrong then return False
if correct then return output of ran the Function with inputs
## printf(*msg,**opts):
## ColorStr(msg,**opts):
## CleanAnsi(data):
## cli_input(msg,**opts):
## TypeData(src,want_type=None,default='org',spliter=None)
Convert (input)data to want type (ex: str -> list, int, ...), can not convert to type then return False
## MoveData(src,data=None,to=None,from_idx=None,force=False,default='org'):
support src type is list,str,(tuple)
moving format : data(data) or from_idx(int)
- data : if src has many same data then just keep single data at moved
moving dest : to(int)
move data or index(from_idx) to want index(to)
force=True: even tuple to move
if not support then return default
default : org
Raw data
{
"_id": null,
"home_page": "https://github.com/kagepark/Import",
"name": "kmport",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Kage Park",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/b0/5f/0baf33aaaad8f3dd4d831b0df0c1aa1c6f945cdca6f2823f1fa8c18f5441/kmport-2.2.28.tar.gz",
"platform": null,
"description": "Open Kage's useful tools and class to public.\n(Long time used and upgraded)\nBut, this is develope version.\nSo, suddenly it will be big change when I got some more good idea.\nmake to seperate to Import from kmisc\n\n# Install\n```javascript\npip3 install kmport\n```\n\n# Functions\n\n## Global()\n Method's global variables\n\n## StdOut(msg)\n Standard Output Print without new line symbol\n\n## def StdErr(msg)\n Standard Error Print without new line symbol\n\n## PyVer(main=None,miner=None,msym=None)\n python version check\n ```\n ex)\n if PyVer(3): # If Python version 3 then ...\n ~~~\n ```\n\n## find_executable(executable,path=None)\n Find Excuatable command location\n ```\n ex)\n if find_executable('ping'): # if ping command is in the system\n ~~~\n\n ping_path=find_executable('ping') # Get ping command full path\n ```\n\n## ByteName(src)\n Get Byte type name\n\n## Bytes(src,**opts)\n Convert data to bytes data\n\n## Str(src,**opts)\n Convert data to String data\n\n## Int(i,default='org',sym=None,err=False):\n Convert data to Int data when possible. if not then return default (original data)\n support data type: int,float,digit number,list,tuple\n default: (default org)\n org : fail then return or keeping the input data\n True,False,None: fail then return default value in single data or ignore the item in list\n sym : split symbol when input is string\n err : \n False: replace data for possible positions\n True : if convert error in list/tuple then return default\n\n## Join(*inps,symbol='_-_',byte=None,ignore_data=(),append_front='',append_end='')\n Similar as join function.\n ```\n ex)\n Join(['a','b','c'],' ') same as ' '.join(['a','b','c'])\n\n Join(['a','b','c'],'\\n',append_front=' ') \n Output:\n a\n b\n c\n\n Join(['a','b','c'],'\\n',append_end=' ') \n Output:\n a<newline>\n b <newline>\n c <newline>\n\n Join(['a','b','c'],'\\n',append_front=' ',ignore_data=['b']) # Ignore 'b' data\n Output:\n a\n c\n ```\n\n## FixIndex(src,idx,default=False,err=False):\n Find Index number in the list,tuple,str,dict\n default : if wrong or error then return default\n err : default False\n False: fixing index to correcting index without error\n True: if wrong index then return default value\n\n## Next(src,step=0,out=None,default='org')\n Get Next data or first key of the dict \n ```\n ex) get send data in the list\n Next([1,2,3,4],step=1)\n Output:\n 2\n\n ex) get dictionary key\n Next({'a':1})\n Output:\n a\n\n Next({'a':1,'b':2},step=2)\n Output:\n b\n ```\n\n## Copy(src)\n Copy data\n ```\n a={'a':1,'b':2}\n b=Copy(a)\n ```\n\n## TypeName(obj)\n Get input's Type,Instance's name\n ```\n TypeName(1) # int\n TypeName('1') # str\n TypeName(int) # int\n TypeName('int') # int\n TypeName(str) # str\n TypeName('str') # str\n\n def abc(): pass\n TypeName(abc) # function\n\n class cc:\n def AA(): pass\n TypeName(cc) # classobj\n\n import os\n TypeName(os) # module\n\n ...\n ```\n\n## Type(*inps,**opts): \n Similar as isinstance(A,())\n support : basic type and ('byte','bytes'),('obj','object'),('func','unboundmethod','function'),('classobj','class'),'generator','method','long',....\n\n## FIND(src).Find(find,src='_#_',sym='\\n',default=[],out=None,findall=True,word=False,mode='value',prs=None,line_num=False,peel=None,idx=None)\n Searching regular expression form data and return the data\n\n## Found(data,find,digitstring=False,word=False,white_space=True,sense=True,location=False):\n if found <find> in <data> then return True, not then False\n If find \"[All]\" then you can type \"\\[All\\]\" at the <find> location\n if not then \"[]\" will be work with re expression\n <find> rule:\n re.compile regular expression\n any keep characters : *\n any single character : ?\n ^ : start\n $ : end\n <option>\n sense : True:(default) sensetive, False: lower and upper is same\n white_space : True:(default) keep white_space, False: ignore white_space\n word : True: <find> is correct word, False:(default) <find> in insde string\n digitstring : True: string and intiger is same, False:(default) different\n location : True: return found location ex:(3,10), False:(default) return True/False\n\n## IsSame(src,dest,sense=False,order=False,Type=False,digitstring=True,white_space=False,**opts):\n return True/False\n Check same data or not between src and dest datas\n <dest> rule:\n re.compile format\n any keep characters : *\n any single character : ?\n ^ : start\n $ : end\n <option>\n order : True: if list,tuple then check ordering too, False:(default) just check data is same or not\n Type : True: check Type only, False:(default) check data\n sense : True: sensetive, False:(default) lower and upper is same\n white_space : True: keep white space, False:(default) ignore white_space\n digitstring : True:(default) string and intiger is same, False: different\n\n## IsIn(find,dest,idx=False,default=False,sense=False,startswith=True,endswith=True,Type=False,digitstring=True,word=True,white_space=False,order=False)\n Check key or value in the dict, list or tuple then True, not then False\n <find> can use IsSame's <dest> rule\n ```\n IsIn('abc',['AC','abc','uuu']): True ('abc' in the list['AC','abc','uuu'])\n IsIn('a*c',['AC','abc','uuu']): True ('a*c' in the list['AC','abc','uuu'])\n ```\n\n## WhiteStrip(src,mode=True):\n remove multi space to single space, remove first and end space\n others return original\n\n## IsNone(src,**opts):\n Check the SRC is similar None type data('',None) or not\n -check_type=<type> : include above and if different type then the return True\n -list_none :\n - False: check index item in the source (default)\n - True : check all list of source\n -index : if source is list then just want check index item\n -space :\n - True : aprove space to data in source\n - False: ignore space data in source\n ```\n IsNone('') : True\n IsNone(None) : True\n IsNone([]) : True\n IsNone({}) : True\n IsNone(0) : False\n IsNone(False): False\n ```\n\n## IsVar(src,obj=None,default=False,mode='all',parent=0)\n Check the input(src) is Variable name or not (in OBJ or in my function)\n ```\n g=9\n def abc(c=5):\n b=3\n IsVar('b') : True\n IsVar('c') : True\n IsVar('g') : True\n IsVar('m') : False\n\n class AA:\n def __init__(self):\n self.abc=1111\n IsVar('abc',AA()) : True ('abc' is a variable in the AA class)\n ```\n\n## IsFunction(src,find='_#_')\n Check the find is a Function in the src object(module,class)\n ```\n def abc(): pass\n IsFunction('abc') : False ('abc' is not a function)\n IsFunction(abc) : True (abc is a function)\n IsFunction(MyModule(),'abc') : True ('abc' is a function in my module)\n IsFunction(MyModule(),abc) : True (abc is a function in my module)\n IsFunction(MyModule(),'abcd') : False (not found 'abcd' in my module)\n ```\n\n## IsBytes(src)\n Check data is Bytes or not\n\n## IsInt(src,mode='all'):\n Check data is Int or not\n - mode : int => check only int\n str => int type string only\n all => Int and int type string\n\n## Dict(*inp,**opt):\n Dictionary\n - Define\n - marge\n - Update\n - Append\n support : Dict, list or tuple with 2 data, dict_items, Django request.data, request data, like path type list([('/a/b',2),('/a/c',3),...]), kDict\n\n## CompVersion(*inp,**opts):\n input: source, compare_symbol(>x,<x,==,!xx), destination\n return BOOL\n input: source, destination, compare_symbol='>x,<x,==,!xx'\n return BOOL\n input: source, destination\n - without compare_symbol\n - out=sym : return symbol (>, ==, <) (default)\n - out=int : return 1(>), 0(==), -1(<)\n - out=str : return bigger(>), same(==), lower(<)\n input: source\n - out=str : return '3.0.1' (default)\n - out=tuple : return to tuple type (3,0,1)\n - out=list : return to list type [3,0,1]\n version_symbol or symbol : default '.'\n\n sort list\n <list>.sort(key=CompVersion) or sorted(<list>,key=CompVersion)\n\n## ModVersion(mod)\n Find Module Version\n\n## Install(module,install_account='',mode=None,upgrade=False,version=None,force=False,pkg_map=None,err=False):\n Install python module file\n module name\n install_accout='' : default None, --user : install on account's directory\n upgrade :\n False : default\n True : Install or Upgrade the module\n version :\n None : default\n <version>: Check the version\n == <version> : if not Same version then install at the same version\n >= <version> : if not bigger the version then install or upgrade\n <= <version> : if not lower the version then install at the version\n force : default False\n True : if installed then force re-install, not then install\n pkg_map: mapping package name and real package name\n format => { <pkg name>: <real install pkg name> }\n err : default False\n True : if installing got any isseu then crashing\n False: if installing got any issue then return False\n\n## Import(*inps,**opts):\n basic function of import\n if not found the module then automaticall install\n version check and upgrade, reinstall according to the version\n support requirement files\n\n inps has \"require <require file>\" then install the all require files in <require file>\n Import('<module name> >= <version>') : Check version and lower then automaticall upgrade \n Import('<module name> == <version>') : Check version and different then automaticall reinstall with the version\n Import('<module name>',path='AAA,BBB,CCCC') : import <module name> from default and extra AAA and BBB and CCC.\n -path= : searching and the module in the extra path (seperate with ',' or ':' )\n -force=True : unload and load again when already loaded (default: False)\n -reload=True : run reload when already loaded (default: False)\n -unload=True : unload module (default : False)\n -err=True : show install or loading error (default: False)\n -dbg=True : show comment (default : False)\n -install_account=: '--user','user','myaccount','account',myself then install at my local account\n default: Install by System default setting\n\n## MethodInClass(class_name)\n Get Method list in Class\n\n## ObjInfo(obj)\n Get object information\n type, name, method list, path, module_name, module_version, module\n ```\n import requests\n ObjInfo(requests)\n Output:\n {'type': 'module', 'name': 'requests', 'methods': ['ConnectTimeout', 'ConnectionError', 'DependencyWarning', 'FileModeWarning', 'HTTPError', 'JSONDecodeError', 'NullHandler', 'PreparedRequest', 'ReadTimeout', 'Request', 'RequestException', 'RequestsDependencyWarning', 'Response', 'Session', 'Timeout', 'TooManyRedirects', 'URLRequired', '__author__', '__author_email__', '__build__', '__builtins__', '__cached__', '__cake__', '__copyright__', '__description__', '__doc__', '__file__', '__license__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__title__', '__url__', '__version__', '_check_cryptography', '_internal_utils', 'adapters', 'api', 'auth', 'certs', 'chardet_version', 'charset_normalizer_version', 'check_compatibility', 'codes', 'compat', 'cookies', 'delete', 'exceptions', 'get', 'head', 'hooks', 'logging', 'models', 'options', 'packages', 'patch', 'post', 'put', 'request', 'session', 'sessions', 'ssl', 'status_codes', 'structures', 'urllib3', 'utils', 'warnings'], 'path': ['/usr/lib/python3.10/site-packages/requests'], 'version': '2.27.1', 'module_name': 'requests', 'module': <module 'requests' from '/usr/lib/python3.10/site-packages/requests/__init__.py'>}\n ```\n## MyModule(default=False,parent=-1): \n Get current module \n - parent\n -1 : my current python page's module\n 0 : my function's module\n 1 : my parent's module\n\n## CallerName(default=False,detail=False):\n Get the caller name of my group function\n detail=True: return (func name, line number, filename)\n default : If not found caller name then return default\n\n def A(): #Group A()\n CallerName() -> Called by module's A() => A\n B()\n def B(): #Group B()\n CallerName() -> Called my group by A() function => A\n def C():\n CallerName() -> Called my group by A() function => A\n C()\n A() -> Calling def A() in python script(module)\n\n## Frame2Function(obj,default=False):\n Get Function Object from frame or frame info\n\n## FunctionName(parent=0,default=False,history=0,tree=False,args=False,line_number=False,filename=False,obj=False,show=False):\n Get function name\n - parent\n 0 : my name (default)\n 1 : my parent function\n ... : going top parent function\n - history : Getting history (return list)\n - tree : tree (return list)\n - show : show tree on screen\n - args : show arguments\n - line_number : show line number\n - filename : show filename\n - obj : Get OBJ (return list)\n\n## FunctionList(obj=None)\n Get function list in this object\n\n## GetClass(obj,default=None)\n Get Class object from instance,method,function\n\n## FunctionArgs(func,**opts):\n Get function's input Arguments\n - mode\n - defaults : get default (V=?,...)\n - args : get args (V,V2,...)\n - varargs : get varargs (*V)\n - keywords : get keywords (**V)\n - string : return arguments to string format\n - list,tuple: return arguments to list format\n default output : dictioniary format\n - default : if nothing then return default value (default None)\n\n## Args(src,field='all',default={}):\n Get Class, instance's global arguments\n Get Function input parameters\n\n## Variable(src=None,obj=None,parent=0,history=False,default=False,mode='local',VarType=None,alltype=True):\n Get available variable data\n - src: \n if None: return whole environment (dict)\n if string then find the string variable in the environment\n if variable then return that\n - parent \n 0 : my function (default)\n 1 : my parents function\n ...\n - history: from me to my top of the functions\n - mode : variable area\n local : function's local(inside) variable\n global: function's global variable\n\n## Uniq(src,default='org'):\n make to uniq data\n\n## Split(src,sym,default=None,sym_spliter='|'):\n multipul split then 'a|b|...'\n without \"|\" then same as string split function\n\n## FormData(src,default=None,want_type=None):\n convert string data to format\n '1' => 1\n json string to json format\n \"{'a':1}\" => {'a':1}\n \"[1,2,3]\" => [1,2,3]\n ....\n\n## IndexForm(idx,idx_only=False,symbol=None):\n return : <True/False>, Index Data\n - False: not found Index form from input idx \n - True : found Index\n Index Data\n - tuple(A,B) : Range Index (A~B)\n - list [A,B] : OR Index or keys A or B\n - Single : int: Index, others: key\n - idx_only : only return integer index\n - symbol : default None, if idx is string and want split with symbol\n\n## Get(*inps,**opts):\n Get (Any) something\n Get('whoami') : return my function name\n Get('funclist'): return my module's function list\n - parent=1 : my parent's function list\n Get(<list|string|dict|int|...>,<index|key|keypath>): Get data at the <index|key|keypath>\n - keypath : '/a/b/c' => {'a':{'b':{'c':1,'d'}}} => return c's 1\n Get('_this_',<key>): my functions's <key>\n Get('<var name>') : return variable data\n Get('_this_','args') : return my functions Arguments\n Get(<function>,'args') : return the functions Arguments\n <option>\n default : None, any issue\n\n## ExceptMessage(msg='',default=None):\n Try:\n AAA\n Except:\n err=ExceptMessage() => If excepting then taken error or traceback code and return it\n\n## IpV4(ip,out='str',default=False,port=None,bmc=False,used=False,pool=None):\n check/convert IP\n ip : int, str, ...\n out:\n str : default : convert to xxx.xxx.xxx.xxx format\n int : convert to int format\n hex : convert to hex format\n port: if you want check the IP with port then type\n bmc : default False, True: check BMC port (623,664,443)\n return : IP, if fail then return default value\n used:\n * required port option, but check with single port\n False: default (not check)\n True: Check IP already used the port(return True) or still available(return False)\n pool: if give IP Pool(tuple) then check the IP is in the POOL or not.\n## ping(host,**opts)\n same as ping command\n log_format='ping' : print ping output on screen\n ping('<IP>',log_format='ping') : print ping output\n ping('<IP>',count=5) : 5 times pinging then return True not then return False\n ping('<IP>',timeout=50) : pinging then return True and passing 50 seconds then return False\n ping('<IP>',keep_good=50,timeout=3600) : if keep pinging 50 seconds then return True in the 1hour.\n\n## WEB\n import requests\n Web=WEB(requests)\n Web.GetIP() : get my web server IP\n Web.GetIP(mode='client') : get client IP \n Web.Method() : return method name(get,post,...)\n Web.Method(mode='upper') : return method name (GET,POST,...)\n Web.Method('GET') : if requests' method is GET then return True, not then False\n Web.Request('<host_url>') : return requests' output\n WEB().str2url(<string>): if some special character then convert to URL\n WEB().form2dict(<request.form>) : return form data to dictionary.\n\n## TIME()\n TIME().Int() : Now second time \n TIME().Rset() : Reset initial Time\n TIME().Format('<time format>') : return format time current time\n TIME().Format('<time format>',time=<int>) : return format time from time\n TIME().Format('<time format>',read_format='<time format>',time='<format time>'): Read time using read_format and return want time format (covert time format)\n TIME().Time() : Same as time.time()\n TIME().Datetime(): Sameas datetime.datetime()\n Timeout example)\n ```\n timeout=30\n Time=TIME()\n while True:\n if Time.Out(timeout): break\n ~~~ \n Time.Sleep(1)\n ```\n## rshell(cmd,timeout=None,ansi=True,path=None,progress=False,progress_pre_new_line=False,progress_post_new_line=False,log=None,progress_interval=5,cd=False,default_timeout=3600):\n Run a shell command\n\n## sprintf(string,*inps,**opts):\n \"\"\"ipmitool -H %(ipmi_ip)s -U %(ipmi_user)s -P '%(ipmi_pass)s' \"\"\"%(**opts)\n \"\"\"{app} -H {ipmi_ip} -U {ipmi_user} -P '{ipmi_pass}' \"\"\".format(**opts)\n \"\"\"{} -H {} -U {} -P '{}' \"\"\".format(*inps)\n \"\"\"{0} -H {1} -U {2} -P '{3}' \"\"\".format(*inps)\n\n## Sort(src,reverse=False,func=None,order=None,field=None,base='key',sym=None):\n Sorting data\n reverse=True: reverse sort\n field=<num> : Sorting by tuple's index number(field) data in list\n order\n int : sorting by integer style\n str : sorting by string style\n len : sorting by string's length\n base='key': (default), sort by key, 'value': sort by data for dictionary case\n sym=<split symbol>: if src is string with symbol then automatically split with that symbol and sorting.\n\n## MacV4(src,**opts):\n Check Mac address format and convert\n Hex to Int\n Hex to Mac string\n Mac string to Int\n symbol : default ':' mac address spliter symbol\n out :\n str : default : XX:XX:XX:XX:XX format\n int : integer format\n default : False\n case : \n upper : upper case output\n lower : lower case output\n\n## Path(*inp,**opts):\n Get Path of input\n inputs)\n ~ : home path\n ~<user> : user's home path\n None : current path\n __file__: current python script file path\n __mod__ : This python script file path\n file : the file's path\n [list] : convert to path rule \n obj : support function, module, class, instance\n\n remove_dot : \n True : (default) /a/b/./../c => /a/c\n False: /a/b/./../c => /a/b/./../c\n error : \n False: default, if path issue then return error\n True : if path issue then ignore\n out :\n str : default: return path string\n list: return list format\n - force_root : default False, True: ['','a','b'] or ['a','b'] => '/a/b'\n\n '/a/b/c' => ['','a','b','c'] (out=list)\n 'a/b/c' => ['a','b','c'] (out=list)\n ['','a','b','c'] => '/a/b/c'(out=str)\n ['a','b','c'] => 'a/b/c' (out=str)\n\n## Cut(src,head_len=None,body_len=None,new_line='\\n',out=str):\n Cut string\n head_len : int : first line length (default None)\n if body_len is None then everything cut same length with head_len\n body_len : int : line length after head_len (default None)\n new_line : default linux new line\n out=\n str : output to string with new_line (default)\n list : output to list instead new_line\n\n## Space(num=4,fill=None,mode='space',tap=''):\n make a charactor(space, tap) group\n num: default 4, how many fill out <fill>\n mode:\n space : default: ' '\n tap : \\\\t\n fill:\n None : default: following mode information\n <special charactor> : fill out the charactor\n tap:\n '' : default\n <spcial inital chractor>: pre-fillout with this chractor\n\n## WrapString(string,fspace=0,nspace=0,new_line='\\n',flength=0,nlength=0,ntap=0,NFLT=False,mode='space',default=''):\n\n## GetKey(src,find=None,default=None,mode='first',root=None):\n Get key from dict,list,tuple,str\n find : if matched value then return the key/index of the data\n mode :\n first : default: return first find\n all : return found all\n default : return when not found\n\n## rm(*args,**opts):\n delete local file with option like as CLI\n [<opt>] <files>/<directory>\n -f : don't ask delete\n -r : <directory> or recurring delete\n delete local file with option like as Function\n <files>/<directory>,...\n force=True : don't ask delete, default False\n recurring=True: <directory> or recurring delete\n delete list/tuple\n <list,tuple>,<del items>,...\n option)\n data\n True : delete data like as <del items>\n False: (default) delete index (<del items> are int)\n delete dict\n <dict>,<del items>,...\n option)\n data\n True : delete data like as <del items>\n False: (default) delete key like as <del items>\n recurring \n False: searching data in first level\n True : keep searching inside dictionary \n\n## List(*inps,**opts):\n tuple2list: \n True : convert tuple data to list data\n False: append tuple into list\n <dict input>\n items : <dict>.items()\n data : <dict>.value()\n path : convert <dict> to path like list ([('/a/b',1),('/a/c',2),...])\n (default): <dict>.keys()\n <option>\n idx=<int> : get <idx> data\n del=<int> : delete <idx>\n first=<data> : move <data> to first\n end=<data> : move <data> to end\n find=<data> : get Index list\n default : False\n mode \n auto : auto fixing index\n err : not found then return default(False)\n ignore : not found then ignore the data\n\n## Replace(src,replace_what,replace_to,default=None,newline='\\n'):\n replace string (src, from, to)\n if not string then return default\n default: return defined value when not string\n 'org': return src\n ... : return defined default\n\n## OutFormat(data,out=None,strip=False,peel=None):\n Output Format maker\n <option>\n out\n None: Not convert\n str,int,list,dict : convert data to want format\n raw : Peeled data when single data(['a'],('a'),{'a':'abc'}) others then return orignal\n peel\n None : automatically working according to out\n True : Peeling data\n False: Not Peeling\n strip \n False: not remove white space\n True : remove white space\n\n## FeedFunc(obj,*inps,**opts):\n Automatically Feed matched variables to function\n FeedFunc(<func>,<function's arguments>,<function's variables>)\n if something wrong then return False\n if correct then return output of ran the Function with inputs\n\n## printf(*msg,**opts):\n\n## ColorStr(msg,**opts):\n\n## CleanAnsi(data):\n\n## cli_input(msg,**opts):\n\n## TypeData(src,want_type=None,default='org',spliter=None)\n Convert (input)data to want type (ex: str -> list, int, ...), can not convert to type then return False\n\n## MoveData(src,data=None,to=None,from_idx=None,force=False,default='org'):\n support src type is list,str,(tuple)\n moving format : data(data) or from_idx(int)\n - data : if src has many same data then just keep single data at moved\n moving dest : to(int)\n move data or index(from_idx) to want index(to)\n force=True: even tuple to move\n if not support then return default\n default : org\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Extended import function",
"version": "2.2.28",
"project_urls": {
"Homepage": "https://github.com/kagepark/Import"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c9f73dc0fa0a222defc3dc1740dfa4f25210f89bcd9e9dea648d700c955f935b",
"md5": "f813cad0b03e31301e7d801a6abc4218",
"sha256": "c1c08f5c3df3c47bd522443c980e717cd20b9f47e00df3173cf81d8dfada743b"
},
"downloads": -1,
"filename": "kmport-2.2.28-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f813cad0b03e31301e7d801a6abc4218",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 104546,
"upload_time": "2025-07-17T18:51:56",
"upload_time_iso_8601": "2025-07-17T18:51:56.652472Z",
"url": "https://files.pythonhosted.org/packages/c9/f7/3dc0fa0a222defc3dc1740dfa4f25210f89bcd9e9dea648d700c955f935b/kmport-2.2.28-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b05f0baf33aaaad8f3dd4d831b0df0c1aa1c6f945cdca6f2823f1fa8c18f5441",
"md5": "4f29a76403ba64c1a7eea79288d5ed0c",
"sha256": "8d458a5d2929cf8b4c7dc1c56968584a3ad050e06bf9d1bf9395bb6a1418329e"
},
"downloads": -1,
"filename": "kmport-2.2.28.tar.gz",
"has_sig": false,
"md5_digest": "4f29a76403ba64c1a7eea79288d5ed0c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 115327,
"upload_time": "2025-07-17T18:51:58",
"upload_time_iso_8601": "2025-07-17T18:51:58.093850Z",
"url": "https://files.pythonhosted.org/packages/b0/5f/0baf33aaaad8f3dd4d831b0df0c1aa1c6f945cdca6f2823f1fa8c18f5441/kmport-2.2.28.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-17 18:51:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kagepark",
"github_project": "Import",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "kmport"
}