kmisc 2.1.110__py3-none-any.whl → 2.1.112__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
kmisc/__init__.py CHANGED
@@ -2054,6 +2054,36 @@ def findXML(xmlfile,find_name=None,find_path=None,default=None,out='xmlobj',get_
2054
2054
  return found_root[0]
2055
2055
  return default
2056
2056
 
2057
+ def findPlanCfg(filename,find_name=None,default=False,original=False):
2058
+ data=cat(filename)
2059
+ if data is False:
2060
+ return default
2061
+ if find_name and isinstance(find_name,str):
2062
+ out=[]
2063
+ for ff in find_name.split(','):
2064
+ found=False
2065
+ for i in data.split('\n'):
2066
+ if isinstance(i,str) and '=' in i:
2067
+ i_a=i.split('=')
2068
+ if len(i_a) == 2 and i_a[0] == ff:
2069
+ found=True
2070
+ if original:
2071
+ out.append(i_a[1])
2072
+ else:
2073
+ if i_a[1][0] == '"' and i_a[1][-1] == '"':
2074
+ out.append(i_a[1][1:-1])
2075
+ elif i_a[1][0] == "'" and i_a[1][-1] == "'":
2076
+ out.append(i_a[1][1:-1])
2077
+ else:
2078
+ out.append(i_a[1])
2079
+ if not found:
2080
+ out.append(default)
2081
+ if len(out) == 1:
2082
+ return out[0]
2083
+ return out
2084
+ return data
2085
+
2086
+
2057
2087
  def Compress(data,mode='lz4'):
2058
2088
  if mode == 'lz4':
2059
2089
  Import('from lz4 import frame')
@@ -2858,13 +2888,21 @@ def net_put_data(IP,data,PORT=8805,key='kg',timeout=3,try_num=1,try_wait=[1,10],
2858
2888
 
2859
2889
  def encode(string):
2860
2890
  enc='{0}'.format(string)
2861
- tmp=zlib.compress(enc.encode("utf-8"))
2862
- return '{0}'.format(base64.b64encode(tmp).decode('utf-8'))
2891
+ try:
2892
+ tmp=zlib.compress(enc.encode("utf-8"))
2893
+ return '{0}'.format(base64.b64encode(tmp).decode('utf-8'))
2894
+ except Exception as e:
2895
+ printf('Issue for {}:\n{}'.format(string,e),mode='e')
2896
+ return False
2863
2897
 
2864
2898
  def decode(string):
2865
2899
  if type(string) is str:
2866
- dd=zlib.decompress(base64.b64decode(string))
2867
- return '{0}'.format(dd.decode("utf-8"))
2900
+ try:
2901
+ dd=zlib.decompress(base64.b64decode(string))
2902
+ return '{0}'.format(dd.decode("utf-8"))
2903
+ except Exception as e:
2904
+ printf('Issue for {}:\n{}'.format(string,e),mode='e')
2905
+ return False
2868
2906
  return string
2869
2907
 
2870
2908
  def get_node_info(loop=0):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kmisc
3
- Version: 2.1.110
3
+ Version: 2.1.112
4
4
  Summary: Enginering useful library
5
5
  Home-page: https://github.com/kagepark/kmisc
6
6
  Author: Kage Park
@@ -0,0 +1,6 @@
1
+ kmisc/__init__.py,sha256=zgj7-ElVI2mUW6Xce4xRVbMPqkHOIe7y5fIRwEr_dFs,136754
2
+ kmisc-2.1.112.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
3
+ kmisc-2.1.112.dist-info/METADATA,sha256=r54huC4xewWpYW5LaNMTOhVygncClsuEHkDPs6_pwKg,5523
4
+ kmisc-2.1.112.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
5
+ kmisc-2.1.112.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
6
+ kmisc-2.1.112.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- kmisc/__init__.py,sha256=KvOI3bqqfV6BPXDuUjYqusq7hYnx7bTqHpIX880hXeU,135389
2
- kmisc-2.1.110.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
3
- kmisc-2.1.110.dist-info/METADATA,sha256=U-mK3R2pVKlcIGBFzO6v6ZxIWFg0wjd3dz1Mb6dn31k,5523
4
- kmisc-2.1.110.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
5
- kmisc-2.1.110.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
6
- kmisc-2.1.110.dist-info/RECORD,,