buildz 0.5.7__tar.gz → 0.5.9__tar.gz
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.
- {buildz-0.5.7/buildz.egg-info → buildz-0.5.9}/PKG-INFO +1 -1
- {buildz-0.5.7 → buildz-0.5.9}/buildz/argx.py +21 -0
- buildz-0.5.9/buildz/cmd.py +78 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/fz/__init__.py +2 -1
- buildz-0.5.9/buildz/fz/fhs.py +17 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/fz/fio.py +29 -1
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc/conf.py +11 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc/confs.py +5 -1
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/base.py +11 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/var_lists.js +1 -1
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/var.py +4 -4
- {buildz-0.5.7 → buildz-0.5.9}/buildz/pyz.py +7 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/listz.py +1 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/mapz.py +1 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/nextz.py +3 -2
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/spc.py +1 -1
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/strz.py +99 -3
- buildz-0.5.9/buildz/xf/loaderz/test1.py +7 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/mapz.py +15 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/readz.py +3 -1
- {buildz-0.5.7 → buildz-0.5.9/buildz.egg-info}/PKG-INFO +1 -1
- {buildz-0.5.7 → buildz-0.5.9}/buildz.egg-info/SOURCES.txt +2 -0
- {buildz-0.5.7 → buildz-0.5.9}/setup.py +1 -1
- buildz-0.5.7/buildz/xf/loaderz/test1.py +0 -7
- {buildz-0.5.7 → buildz-0.5.9}/LICENSE +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/MANIFEST.in +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/README.md +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/__init__.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/__main__.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/ioc/deal.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/ioc/help.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/myers/deal.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/myers/help.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/conf/ioc.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/conf/main.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/conf/myers.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/conf/search.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/conf/xf.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/help/default.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/help/ioc.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/help/myers.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/help/search.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/help/xf.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/res/test.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/search/deal.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/search/help.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/test.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/xf/deal.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/demo/xf/help.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/fz/dirz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/fz/lsf.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/__init__.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/base.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/init.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc/base.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc/single.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/call.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/calls.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/deal_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/deals.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/iocf_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/ref_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/xfile_defaults.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/conf/xfile_lists.js +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/deal.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/demo.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/env.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/ioc.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/iocf.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/join.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/list.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/map.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/mcall.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/obj.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/ovar.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/ref.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/val.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/ioc/ioc_deal/xfile.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/tz/__init__.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/tz/myers_diff.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/__init__.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/__main__.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/file.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/base.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/buffer.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/listz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/lr.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/lrval.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/mapz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/nextz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/reval.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/setz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/spc.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/spt.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/deal/strz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/exp.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/item.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/mg.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loader/pos.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/base.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/buffer.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/lr.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/lrval.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/reval.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/setz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/deal/spt.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/exp.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/item.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/mg.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/pos.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/loaderz/test.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/read.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/stack.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/write.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/writer/base.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/writer/conf.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/writer/deal/jsonval.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/writer/deal/listz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/writer/deal/mapz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/writer/deal/reval.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/writer/deal/strz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/writer/itemz.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/writer/mg.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz/xf/xargs.py +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz.egg-info/dependency_links.txt +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/buildz.egg-info/top_level.txt +0 -0
- {buildz-0.5.7 → buildz-0.5.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: buildz
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.9
|
4
4
|
Summary: 配置读写(基于json格式进行简化),以及ioc。a json-base file format's read and write code by python, and codes to read and product object from configure file in such format(ioc)
|
5
5
|
Home-page: https://github.com/buildCodeZ/buildz
|
6
6
|
Author: Zzz
|
@@ -15,8 +15,24 @@ class Fetch:
|
|
15
15
|
就是对引号不太适用
|
16
16
|
"""
|
17
17
|
def __init__(self, args = [], maps ={}):
|
18
|
+
args = [maps[k] if k in maps else k for k in args]
|
18
19
|
self.args = args
|
19
20
|
self.maps = maps
|
21
|
+
def des(self):
|
22
|
+
cmd = " ".join(self.args)
|
23
|
+
adds = []
|
24
|
+
for k, val in self.maps.items():
|
25
|
+
tmp = f" [-{k} param] [--{val}=param]"
|
26
|
+
adds.append(tmp)
|
27
|
+
adds = [cmd]+adds
|
28
|
+
rs = "\n".join(adds)
|
29
|
+
return rs
|
30
|
+
def check(self, args, ks):
|
31
|
+
rst = []
|
32
|
+
for k in ks:
|
33
|
+
if k not in args:
|
34
|
+
rst.append(k)
|
35
|
+
return rst
|
20
36
|
def __call__(self, argv = None):
|
21
37
|
args, maps = fetch(argv)
|
22
38
|
rst = {}
|
@@ -35,6 +51,11 @@ class Fetch:
|
|
35
51
|
del rst[key]
|
36
52
|
return rst
|
37
53
|
|
54
|
+
pass
|
55
|
+
class FetchX(Fetch):
|
56
|
+
def __init__(self, *a, **b):
|
57
|
+
super().__init__(a,b)
|
58
|
+
|
38
59
|
pass
|
39
60
|
def fetch(argv = None):
|
40
61
|
r"""
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
from . import xf
|
3
|
+
class Cmd:
|
4
|
+
def close(self):
|
5
|
+
self.running = False
|
6
|
+
def __init__(self, obj):
|
7
|
+
self.running = False
|
8
|
+
self.obj = obj
|
9
|
+
self.tmp = None
|
10
|
+
self.exits = "exit,close,quit".split(",")
|
11
|
+
def __call__(self):
|
12
|
+
self.run()
|
13
|
+
def doc(self, *arr):
|
14
|
+
if len(arr)>0:
|
15
|
+
rfc = getattr(self.obj, arr[0])
|
16
|
+
else:
|
17
|
+
rfc = self.obj
|
18
|
+
return rfc.__doc__
|
19
|
+
def help(self, *arr):
|
20
|
+
if len(arr)>0:
|
21
|
+
rfc = getattr(self.obj, arr[0])
|
22
|
+
else:
|
23
|
+
rfc = self.obj
|
24
|
+
help(rfc)
|
25
|
+
def dir(self, *arr):
|
26
|
+
if len(arr)>0:
|
27
|
+
rfc = getattr(self.obj, arr[0])
|
28
|
+
else:
|
29
|
+
rfc = self.obj
|
30
|
+
arr = rfc.__dir__()
|
31
|
+
arr = [k for k in arr if k[:2]!="__"]
|
32
|
+
return arr
|
33
|
+
def dict(self, *arr):
|
34
|
+
if len(arr)>0:
|
35
|
+
rfc = getattr(self.obj, arr[0])
|
36
|
+
else:
|
37
|
+
rfc = self.obj
|
38
|
+
return rfc.__dict__
|
39
|
+
def get(self, *arr):
|
40
|
+
if len(arr)>0:
|
41
|
+
return getattr(self.obj, arr[0])
|
42
|
+
return self.obj
|
43
|
+
def set(self, key, val):
|
44
|
+
setattr(self.obj,key, val)
|
45
|
+
return getattr(self.obj, key)
|
46
|
+
def run(self):
|
47
|
+
self.running = True
|
48
|
+
while self.running:
|
49
|
+
s = input(":").strip()
|
50
|
+
if s.strip()=="":
|
51
|
+
continue
|
52
|
+
if s in self.exits:
|
53
|
+
break
|
54
|
+
try:
|
55
|
+
arr = xf.loads(s)
|
56
|
+
if type(arr)!=list:
|
57
|
+
if type(arr)==dict:
|
58
|
+
rst = []
|
59
|
+
for k,v in arr.items():
|
60
|
+
rst+=[k,v]
|
61
|
+
arr = rst
|
62
|
+
else:
|
63
|
+
arr = [arr]
|
64
|
+
fc = arr[0]
|
65
|
+
if not hasattr(self.obj, fc):
|
66
|
+
fc = fc.split(".")[-1]
|
67
|
+
fc = getattr(self, fc)
|
68
|
+
else:
|
69
|
+
fc = getattr(self.obj, fc)
|
70
|
+
params = arr[1:]
|
71
|
+
tmp = fc(*params)
|
72
|
+
print(tmp)
|
73
|
+
except Exception as exp:
|
74
|
+
import traceback
|
75
|
+
print(f"[CMD] error:{exp}")
|
76
|
+
traceback.print_exc()
|
77
|
+
|
78
|
+
pass
|
@@ -2,6 +2,7 @@
|
|
2
2
|
#author:
|
3
3
|
from .dirz import dirs, FileDeal
|
4
4
|
from .lsf import lists, search, searchd,searchs,_search
|
5
|
-
from .fio import fread, freads, fwrite, fwrites, read,reads,write,writes, makefdir, dirpath,makedir
|
5
|
+
from .fio import fread, freads, fwrite, fwrites, read,reads,write,writes, makefdir, dirpath,makedir,removes, cover, fcover
|
6
|
+
from .fhs import fhash
|
6
7
|
|
7
8
|
__author__ = "Zzz, emails: 1174534295@qq.com, 1309458652@qq.com"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
|
3
|
+
import hashlib
|
4
|
+
|
5
|
+
#计算文件hash值
|
6
|
+
def fhash(fp, hm="sha256", blk_sz = 10240):
|
7
|
+
if type(hm) == str:
|
8
|
+
hm = getattr(hashlib, hm)()
|
9
|
+
with open(fp, 'rb') as f:
|
10
|
+
while True:
|
11
|
+
bs = f.read(blk_sz)
|
12
|
+
if len(bs)==0:
|
13
|
+
break
|
14
|
+
hm.update(bs)
|
15
|
+
return hm.hexdigest()
|
16
|
+
|
17
|
+
pass
|
@@ -53,4 +53,32 @@ def dirpath(fp, n=1):
|
|
53
53
|
return fp
|
54
54
|
|
55
55
|
pass
|
56
|
-
|
56
|
+
|
57
|
+
dirname = dirpath
|
58
|
+
|
59
|
+
def fcover(filepath, wsize = 1024*10):
|
60
|
+
st = os.stat(filepath)
|
61
|
+
size = st.st_size
|
62
|
+
bs = b'a'*wsize
|
63
|
+
with open(filepath, 'wb') as f:
|
64
|
+
for i in range(0, size, wsize):
|
65
|
+
f.write(bs)
|
66
|
+
|
67
|
+
pass
|
68
|
+
cover = fcover
|
69
|
+
def removes(fp, cover = False):
|
70
|
+
if not os.path.exists(fp):
|
71
|
+
return
|
72
|
+
if os.path.isfile(fp):
|
73
|
+
#print(f"remove file '{fp}'")
|
74
|
+
if cover:
|
75
|
+
fcover(fp)
|
76
|
+
os.remove(fp)
|
77
|
+
return
|
78
|
+
fps = os.listdir(fp)
|
79
|
+
fps = [os.path.join(fp, f) for f in fps]
|
80
|
+
[removes(f, cover) for f in fps]
|
81
|
+
#print(f"removedirs '{fp}'")
|
82
|
+
os.rmdir(fp)
|
83
|
+
|
84
|
+
pass
|
@@ -133,8 +133,19 @@ class Conf(Base):
|
|
133
133
|
if not search_confs:
|
134
134
|
return None
|
135
135
|
return self.confs.get_deal(type, self.id)
|
136
|
+
def get_data_conf(self, data, src = None, info = None):
|
137
|
+
if type(data) not in [list, dict, tuple]:
|
138
|
+
i = self.confs.data_index_type[0]
|
139
|
+
data = [self.default_type(), data]
|
140
|
+
if i != 0:
|
141
|
+
data.reverse()
|
142
|
+
_type = self.confs.get_data_type(data, 1, self.default_type())
|
143
|
+
edata = EncapeData(data, self, local=True, type=_type, src = src, info = info)
|
144
|
+
return edata
|
136
145
|
def get_data(self, id, local = True, search_confs = True, src = None, info = None):
|
137
146
|
self.do_init()
|
147
|
+
if type(id) in [list, tuple, dict]:
|
148
|
+
return self.get_data_conf(id, src, info)
|
138
149
|
if id in self.datas:
|
139
150
|
obj = self.datas[id]
|
140
151
|
edata = EncapeData(obj, self, local = False, src=src, info = info)
|
@@ -285,7 +285,11 @@ class Confs(Base):
|
|
285
285
|
for fp in fps:
|
286
286
|
self.add_fp(fp)
|
287
287
|
def add_fp(self, fp):
|
288
|
-
|
288
|
+
try:
|
289
|
+
conf = self.loads(xf.fread(fp))
|
290
|
+
except:
|
291
|
+
print(f'error in loads: {fp}')
|
292
|
+
raise
|
289
293
|
return self.add(conf)
|
290
294
|
def adds(self, confs):
|
291
295
|
for conf in confs:
|
@@ -123,7 +123,18 @@ class BaseDeal(Base):
|
|
123
123
|
自己实现的处理类,要实现两个方法:__call__(self, edata:EncapeData)和remove(self, edata:EncapeData)
|
124
124
|
其中remove可以只写个空方法
|
125
125
|
"""
|
126
|
+
def get_data(self, data, conf, src = None, info = None):
|
127
|
+
if type(data) not in [list, dict, tuple]:
|
128
|
+
i = conf.confs.data_index_type[0]
|
129
|
+
data = [conf.default_type(), data]
|
130
|
+
if i != 0:
|
131
|
+
data.reverse()
|
132
|
+
_type = conf.confs.get_data_type(data, 1, conf.default_type())
|
133
|
+
edata = EncapeData(data, conf, local=True, type=_type, src = src, info = info)
|
134
|
+
return edata
|
126
135
|
def get_obj(self, data, conf, src = None, info = None):
|
136
|
+
edata = self.get_data(data, conf, src, info)
|
137
|
+
return edata()
|
127
138
|
if type(data) not in [list, dict, tuple]:
|
128
139
|
i = conf.confs.data_index_type[0]
|
129
140
|
data = [conf.default_type(), data]
|
@@ -11,11 +11,11 @@ class VarDeal(FormatDeal):
|
|
11
11
|
{
|
12
12
|
id:id
|
13
13
|
type: var
|
14
|
-
|
14
|
+
data: string
|
15
15
|
}
|
16
16
|
简写:
|
17
|
-
[[id, var],
|
18
|
-
[var,
|
17
|
+
[[id, var], data]
|
18
|
+
[var, data]
|
19
19
|
例:
|
20
20
|
[var, buildz.pyz.is_windows] // 返回buildz.pyz下的is_windows
|
21
21
|
"""
|
@@ -30,7 +30,7 @@ class VarDeal(FormatDeal):
|
|
30
30
|
conf = edata.conf
|
31
31
|
data = self.format(data)
|
32
32
|
src = edata.src
|
33
|
-
key = xf.
|
33
|
+
key = xf.get_first(data, "var", "data")
|
34
34
|
key = pyz.load(key)
|
35
35
|
return key
|
36
36
|
|
@@ -1,6 +1,13 @@
|
|
1
1
|
|
2
2
|
import sys
|
3
3
|
import os
|
4
|
+
import hashlib
|
5
|
+
def hashcode(s):
|
6
|
+
if type(s)==str:
|
7
|
+
s = s.encode("utf-8")
|
8
|
+
return hashlib.md5(s).hexdigest()
|
9
|
+
|
10
|
+
pass
|
4
11
|
def test_current(fp, up = 1):
|
5
12
|
"""
|
6
13
|
将当前目录的上{up}层目录加入sys.path,这样可以在同层写测试代码,但是import还是要当在上{up}层做import
|
@@ -4,8 +4,8 @@ from .. import item
|
|
4
4
|
class PrevNextDeal(base.BaseDeal):
|
5
5
|
def labels(self):
|
6
6
|
return ['']
|
7
|
-
def types(self):
|
8
|
-
|
7
|
+
#def types(self):
|
8
|
+
# return [""]
|
9
9
|
"""
|
10
10
|
读取下一个字符放缓存里,应放最低优先级
|
11
11
|
"""
|
@@ -18,6 +18,7 @@ class PrevNextDeal(base.BaseDeal):
|
|
18
18
|
return False
|
19
19
|
obj = item.Item(rm, type = '', is_val = 0)
|
20
20
|
arr.append(obj)
|
21
|
+
# TODO return True?
|
21
22
|
return False
|
22
23
|
return True
|
23
24
|
def build(self, obj):
|
@@ -4,7 +4,97 @@ from .. import exp
|
|
4
4
|
from ... import file
|
5
5
|
import json
|
6
6
|
from . import lr
|
7
|
+
|
8
|
+
def init():
|
9
|
+
cs = "abfnrtv\\'\"?0123456789xcde"
|
10
|
+
maps = {k:k.encode()[0] for k in cs}
|
11
|
+
global c2b
|
12
|
+
c2b = maps
|
13
|
+
global symbal_a
|
14
|
+
global a_map
|
15
|
+
a_map = [0]*256
|
16
|
+
s = "abfnrtv\\'\"?"
|
17
|
+
ts = b"\a\b\f\n\r\t\v\\\'\"\?"
|
18
|
+
for c,t in zip(s, ts):
|
19
|
+
a_map[c2b[c]] = t
|
20
|
+
symbal_a = [False]*256
|
21
|
+
for c in s:
|
22
|
+
symbal_a[c2b[c]] = True
|
23
|
+
global id_0,id_a,id_x
|
24
|
+
id_0 = b'0'[0]
|
25
|
+
id_a = b'a'[0]
|
26
|
+
id_x = b'x'[0]
|
27
|
+
|
28
|
+
pass
|
29
|
+
|
30
|
+
init()
|
31
|
+
def translate_bts(bts):
|
32
|
+
i = 0
|
33
|
+
rs = []
|
34
|
+
while i<len(bts):
|
35
|
+
c = bts[i]
|
36
|
+
i+=1
|
37
|
+
if c!=c2b['\\']:
|
38
|
+
rs.append(c)
|
39
|
+
continue
|
40
|
+
x0 = bts[i]
|
41
|
+
i+=1
|
42
|
+
if symbal_a[x0]:
|
43
|
+
rs.append(a_map[x0])
|
44
|
+
continue
|
45
|
+
v = x0-id_0
|
46
|
+
if v>=0 and v<=7:
|
47
|
+
tmp = v
|
48
|
+
for j in range(2):
|
49
|
+
if i+j+1>=len(bts):
|
50
|
+
break
|
51
|
+
xi = bts[i+j+1]
|
52
|
+
vi = xi-id_0
|
53
|
+
if vi>=0 and vi<=7:
|
54
|
+
i+=1
|
55
|
+
tmp = (rs<<3)+vi
|
56
|
+
else:
|
57
|
+
break
|
58
|
+
rs.append(tmp)
|
59
|
+
continue
|
60
|
+
if x0 == id_x:
|
61
|
+
tmp = 0
|
62
|
+
for j in range(2):
|
63
|
+
if i+j+1>=len(bts):
|
64
|
+
raise Exception("\\xXX error")
|
65
|
+
xi = bts[i+j+1]
|
66
|
+
vi = xi-id_0
|
67
|
+
if vi<0 or vi>7:
|
68
|
+
vi = xi-id_a
|
69
|
+
if vi<0 or vi > 5:
|
70
|
+
raise Exception("\\xXX error")
|
71
|
+
vi +=10
|
72
|
+
tmp=(tmp<<4)+vi
|
73
|
+
rs.append(tmp)
|
74
|
+
continue
|
75
|
+
rs.append(c)
|
76
|
+
rs.append(x0)
|
77
|
+
#i-=1
|
78
|
+
return bytes(rs)
|
79
|
+
|
80
|
+
pass
|
81
|
+
|
7
82
|
class PrevStrDeal(lr.LRDeal):
|
83
|
+
def types(self):
|
84
|
+
if not self.deal_build:
|
85
|
+
return []
|
86
|
+
return ['']
|
87
|
+
def build(self, obj):
|
88
|
+
if type(obj.val)==list:
|
89
|
+
return None
|
90
|
+
if obj.is_val:
|
91
|
+
return obj
|
92
|
+
obj.is_val = 1
|
93
|
+
if self.translate:
|
94
|
+
val = obj.val
|
95
|
+
val = self.do_translate(val)
|
96
|
+
obj.val = val
|
97
|
+
return obj
|
8
98
|
def prepare(self, mg):
|
9
99
|
super().prepare(mg)
|
10
100
|
self.label_l2 = mg.like("\\")
|
@@ -13,11 +103,12 @@ class PrevStrDeal(lr.LRDeal):
|
|
13
103
|
self.label_lr = mg.like("\r")
|
14
104
|
self.label_nl = mg.like("")
|
15
105
|
self.et_in_right = self.right.count(self.label_et)
|
16
|
-
def init(self, left = '"', right= '"', single_line = False, note = False, translate = False):
|
106
|
+
def init(self, left = '"', right= '"', single_line = False, note = False, translate = False, deal_build = False):
|
17
107
|
super().init(left, right, 'str')
|
18
108
|
self.single_line = single_line
|
19
109
|
self.note = note
|
20
110
|
self.translate = translate
|
111
|
+
self.deal_build = deal_build
|
21
112
|
def json_loads(self, s):
|
22
113
|
x = s
|
23
114
|
cd = None
|
@@ -28,6 +119,13 @@ class PrevStrDeal(lr.LRDeal):
|
|
28
119
|
rs = rs.encode(cd)
|
29
120
|
return rs
|
30
121
|
def do_translate(self, s):
|
122
|
+
is_bytes = type(s)==bytes
|
123
|
+
if not is_bytes:
|
124
|
+
s = s.encode("utf-8")
|
125
|
+
s = translate_bts(s)
|
126
|
+
if not is_bytes:
|
127
|
+
s = s.decode("utf-8")
|
128
|
+
return s
|
31
129
|
"""
|
32
130
|
取巧直接调用json
|
33
131
|
"""
|
@@ -54,8 +152,6 @@ class PrevStrDeal(lr.LRDeal):
|
|
54
152
|
buffer.clean2read(self.ll)
|
55
153
|
if len(rm)>0:
|
56
154
|
if not self.note:
|
57
|
-
print("left:", self.left, rm)
|
58
|
-
print(f"rst: [{rst}]")
|
59
155
|
raise Exception(f"unexcept char before string: {rm}")
|
60
156
|
else:
|
61
157
|
rst.append(item.Item(rm, type = "", is_val = 0))
|
@@ -94,6 +94,16 @@ def s(obj, **maps):
|
|
94
94
|
v = maps[k]
|
95
95
|
obj[k] = v
|
96
96
|
|
97
|
+
pass
|
98
|
+
def fill_fc(maps, fc):
|
99
|
+
for k in maps:
|
100
|
+
v = maps[k]
|
101
|
+
if type(v) == dict:
|
102
|
+
fill_fc(v, fc)
|
103
|
+
continue
|
104
|
+
maps[k] = fc(v)
|
105
|
+
return maps
|
106
|
+
|
97
107
|
pass
|
98
108
|
def sets(maps, keys, val):
|
99
109
|
if type(keys) != list:
|
@@ -167,3 +177,8 @@ def deep_update(target, src, replace=1):
|
|
167
177
|
|
168
178
|
pass
|
169
179
|
update = deep_update
|
180
|
+
def deep_fill(src, target, replace=1):
|
181
|
+
return deep_update(target, src, replace)
|
182
|
+
|
183
|
+
pass
|
184
|
+
fill=deep_fill
|
@@ -46,9 +46,11 @@ pass
|
|
46
46
|
def build(as_bytes=False):
|
47
47
|
mgs = mg.Manager(as_bytes)
|
48
48
|
build_val(mgs)
|
49
|
+
#1,0,0,1: 没引号当r"..."
|
50
|
+
#1,0,1,1: 没引导当"..."
|
49
51
|
mgs.add(strz.PrevStrDeal("r'''","'''",0,0,0))
|
50
52
|
mgs.add(strz.PrevStrDeal('r"""','"""',0,0,0))
|
51
|
-
mgs.add(strz.PrevStrDeal("r'","'",1,0,0))
|
53
|
+
mgs.add(strz.PrevStrDeal("r'","'",1,0,0,1))
|
52
54
|
mgs.add(strz.PrevStrDeal('r"','"',1,0,0))
|
53
55
|
mgs.add(strz.PrevStrDeal("###","###",0,1))
|
54
56
|
mgs.add(strz.PrevStrDeal("/*","*/",0,1))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: buildz
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.9
|
4
4
|
Summary: 配置读写(基于json格式进行简化),以及ioc。a json-base file format's read and write code by python, and codes to read and product object from configure file in such format(ioc)
|
5
5
|
Home-page: https://github.com/buildCodeZ/buildz
|
6
6
|
Author: Zzz
|
@@ -5,6 +5,7 @@ setup.py
|
|
5
5
|
buildz/__init__.py
|
6
6
|
buildz/__main__.py
|
7
7
|
buildz/argx.py
|
8
|
+
buildz/cmd.py
|
8
9
|
buildz/pyz.py
|
9
10
|
buildz.egg-info/PKG-INFO
|
10
11
|
buildz.egg-info/SOURCES.txt
|
@@ -32,6 +33,7 @@ buildz/demo/xf/deal.py
|
|
32
33
|
buildz/demo/xf/help.py
|
33
34
|
buildz/fz/__init__.py
|
34
35
|
buildz/fz/dirz.py
|
36
|
+
buildz/fz/fhs.py
|
35
37
|
buildz/fz/fio.py
|
36
38
|
buildz/fz/lsf.py
|
37
39
|
buildz/ioc/__init__.py
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|