buildz 0.5.9__tar.gz → 0.5.91__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.9/buildz.egg-info → buildz-0.5.91}/PKG-INFO +1 -1
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/help/search.js +6 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/search/deal.py +5 -1
- buildz-0.5.91/buildz/fz/lsf.py +192 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc/confs.py +2 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/obj.py +26 -7
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/strz.py +55 -19
- {buildz-0.5.9 → buildz-0.5.91/buildz.egg-info}/PKG-INFO +1 -1
- {buildz-0.5.9 → buildz-0.5.91}/setup.py +1 -1
- buildz-0.5.9/buildz/fz/lsf.py +0 -113
- {buildz-0.5.9 → buildz-0.5.91}/LICENSE +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/MANIFEST.in +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/README.md +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/__init__.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/__main__.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/argx.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/cmd.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/ioc/deal.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/ioc/help.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/myers/deal.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/myers/help.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/conf/ioc.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/conf/main.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/conf/myers.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/conf/search.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/conf/xf.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/help/default.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/help/ioc.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/help/myers.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/help/xf.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/res/test.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/search/help.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/test.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/xf/deal.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/demo/xf/help.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/fz/__init__.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/fz/dirz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/fz/fhs.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/fz/fio.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/__init__.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/base.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/init.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc/base.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc/conf.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc/single.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/base.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/call.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/calls.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/deal_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/deals.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/iocf_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/ref_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/xfile_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/conf/xfile_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/deal.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/demo.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/env.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/ioc.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/iocf.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/join.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/list.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/map.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/mcall.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/ovar.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/ref.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/val.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/var.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/ioc/ioc_deal/xfile.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/pyz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/tz/__init__.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/tz/myers_diff.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/__init__.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/__main__.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/file.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/base.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/buffer.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/listz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/lr.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/lrval.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/mapz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/nextz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/reval.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/setz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/spc.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/spt.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/deal/strz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/exp.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/item.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/mg.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loader/pos.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/base.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/buffer.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/listz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/lr.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/lrval.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/mapz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/nextz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/reval.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/setz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/spc.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/deal/spt.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/exp.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/item.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/mg.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/pos.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/test.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/loaderz/test1.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/mapz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/read.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/readz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/stack.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/write.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/writer/base.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/writer/conf.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/writer/deal/jsonval.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/writer/deal/listz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/writer/deal/mapz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/writer/deal/reval.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/writer/deal/strz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/writer/itemz.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/writer/mg.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz/xf/xargs.py +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz.egg-info/SOURCES.txt +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz.egg-info/dependency_links.txt +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/buildz.egg-info/top_level.txt +0 -0
- {buildz-0.5.9 → buildz-0.5.91}/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.91
|
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
|
@@ -12,9 +12,13 @@ class Deal:
|
|
12
12
|
ct = argx.get(maps, "c,content".split(","), None)
|
13
13
|
depth = argx.get(maps, "d,depth".split(","), None)
|
14
14
|
out_fp = argx.get(maps, "o,output".split(","), None)
|
15
|
+
show = argx.get(maps, "s,show".split(","), False)
|
16
|
+
prv = int(argx.get(maps, "p,prev".split(","), 10))
|
17
|
+
aft = int(argx.get(maps, "a,aft".split(","), 10))
|
18
|
+
shows = [prv, aft]
|
15
19
|
if depth is not None:
|
16
20
|
depth = int(depth)
|
17
|
-
rst = fz.search(dp, ct_fp, ct, depth)
|
21
|
+
rst = fz.search(dp, ct_fp, ct, depth, show=show, shows=shows)
|
18
22
|
l = len(rst)
|
19
23
|
rs = "\n".join(rst)
|
20
24
|
if out_fp is not None:
|
@@ -0,0 +1,192 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
|
3
|
+
from . import dirz
|
4
|
+
|
5
|
+
import re
|
6
|
+
class ListsDeal(dirz.FileDeal):
|
7
|
+
def result(self):
|
8
|
+
return self.fps, self.errors
|
9
|
+
def init(self):
|
10
|
+
super().init()
|
11
|
+
self.fps = []
|
12
|
+
self.errors = []
|
13
|
+
def visit(self, finfo, depth):
|
14
|
+
fp, isdir = finfo.path, finfo.isdir
|
15
|
+
self.fps.append([fp, isdir])
|
16
|
+
return True
|
17
|
+
def catch(self, finfo, depth, exp):
|
18
|
+
fp, isdir = finfo.path, finfo.isdir
|
19
|
+
self.errors.append([fp, isdir, exp])
|
20
|
+
|
21
|
+
pass
|
22
|
+
|
23
|
+
def decode(s, coding = 'utf-8'):
|
24
|
+
coding = coding.lower()
|
25
|
+
xcoding = 'utf-8'
|
26
|
+
if coding == 'utf-8':
|
27
|
+
xcoding = 'gbk'
|
28
|
+
try:
|
29
|
+
return s.decode(coding)
|
30
|
+
except:
|
31
|
+
return s.decode(xcoding)
|
32
|
+
|
33
|
+
pass
|
34
|
+
g_codes = ["utf-8", "gbk"]
|
35
|
+
class SearchDeal(dirz.FileDeal):
|
36
|
+
def init(self, pt_fp=None, pt = None, pt_dp = None, depth = None, relative = False, show_ct = False, shows = [10,10]):
|
37
|
+
super().init()
|
38
|
+
self.pt_fp = pt_fp
|
39
|
+
self.pt_dp = pt_dp
|
40
|
+
#if type(pt) == str:
|
41
|
+
# pt = pt.encode()
|
42
|
+
if pt is not None:
|
43
|
+
pfx = f"([\s\S]{{0,{shows[0]}}}"
|
44
|
+
sfx = f"[\s\S]{{0,{shows[1]}}})"
|
45
|
+
if type(pt)==bytes:
|
46
|
+
pfx = pfx.encode()
|
47
|
+
sfx = sfx.encode()
|
48
|
+
pt = pfx+pt+sfx
|
49
|
+
global g_codes
|
50
|
+
if pt is not None:
|
51
|
+
if type(pt) == str:
|
52
|
+
pts = [pt.encode(c) for c in g_codes]
|
53
|
+
else:
|
54
|
+
pts = [pt]
|
55
|
+
else:
|
56
|
+
pts = None
|
57
|
+
self.pts = pts
|
58
|
+
self.pt = pt
|
59
|
+
self.rst = []
|
60
|
+
self.errs = []
|
61
|
+
self.depth = depth
|
62
|
+
self.relative = relative
|
63
|
+
self.show_ct = show_ct
|
64
|
+
self.show_list = []
|
65
|
+
def fps(self, keep_dir = False, relative = None, fp_only = True):
|
66
|
+
if self.show_ct:
|
67
|
+
return self.show_list
|
68
|
+
if relative is None:
|
69
|
+
relative = self.relative
|
70
|
+
rst = self.rst
|
71
|
+
if relative:
|
72
|
+
rst = [[i.rpath, i.isdir] for i in rst]
|
73
|
+
else:
|
74
|
+
rst = [[i.path, i.isdir] for i in rst]
|
75
|
+
if not keep_dir:
|
76
|
+
rst = [k for k in rst if not k[1]]
|
77
|
+
if fp_only:
|
78
|
+
rst = [k[0] for k in rst]
|
79
|
+
return rst
|
80
|
+
def result(self):
|
81
|
+
if self.show_ct:
|
82
|
+
return self.show_list
|
83
|
+
return self.rst
|
84
|
+
def visit(self, finfo, depth):
|
85
|
+
if self.depth is not None and depth > self.depth:
|
86
|
+
return False
|
87
|
+
filepath = finfo.path
|
88
|
+
isdir = finfo.isdir
|
89
|
+
if self.relative:
|
90
|
+
filepath = finfo.rpath
|
91
|
+
if isdir:
|
92
|
+
if finfo.empty_dir or depth==self.depth:
|
93
|
+
if self.pt_dp is not None and len(re.findall(self.pt_dp, filepath))==0:
|
94
|
+
return True
|
95
|
+
self.rst.append(finfo)
|
96
|
+
return True
|
97
|
+
if self.pt_fp is not None and len(re.findall(self.pt_fp, filepath))==0:
|
98
|
+
return False
|
99
|
+
if self.pt is not None:
|
100
|
+
try:
|
101
|
+
with open(filepath, 'rb') as f:
|
102
|
+
s = f.read()
|
103
|
+
except Exception as exp:
|
104
|
+
self.catch(finfo, depth, exp)
|
105
|
+
return False
|
106
|
+
pt = self.pt
|
107
|
+
mark = False
|
108
|
+
finds = None
|
109
|
+
mark = -1
|
110
|
+
for i in range(len(self.pts)):
|
111
|
+
pt = self.pts[i]
|
112
|
+
finds = re.findall(pt, s)
|
113
|
+
if len(finds)>0:
|
114
|
+
mark = i
|
115
|
+
break
|
116
|
+
if mark<0:
|
117
|
+
return False
|
118
|
+
if self.show_ct:
|
119
|
+
arr = []
|
120
|
+
code = g_codes[mark]
|
121
|
+
bld = b"* "*32
|
122
|
+
blda = b"- "*32
|
123
|
+
bldi = b".."*32
|
124
|
+
arr.append(bld)
|
125
|
+
arr.append(f"filepath: {filepath}, find {len(finds)}:".encode("utf-8"))
|
126
|
+
arr.append(bldi)
|
127
|
+
if type(self.pt)==bytes:
|
128
|
+
pass
|
129
|
+
else:
|
130
|
+
try:
|
131
|
+
s = s.decode(code)
|
132
|
+
pt = self.pts[mark].decode(code)
|
133
|
+
finds = re.findall(pt, s)
|
134
|
+
except Exception as exp:
|
135
|
+
print(f"error in decode {filepath}, {pts[mark]} with '{code}': {exp}")
|
136
|
+
for bs_find in finds:
|
137
|
+
if type(bs_find)==[list, tuple]:
|
138
|
+
bs_find = bs_find[0]
|
139
|
+
if type(self.pt)==str:
|
140
|
+
bs_find = bs_find.encode(code)
|
141
|
+
#bs_find = b">>>>>>>\n"+bs_find+b"\n<<<<<<\n"
|
142
|
+
#bs_find += b"\n"+bld+b"\n"
|
143
|
+
arr.append(bs_find)
|
144
|
+
arr.append(bldi)
|
145
|
+
arr.append(blda)
|
146
|
+
arr.append(b"")
|
147
|
+
arr = b"\n".join(arr)
|
148
|
+
try:
|
149
|
+
arr = decode(arr)
|
150
|
+
except Exception as exp:
|
151
|
+
arr = filepath
|
152
|
+
self.show_list.append(arr)
|
153
|
+
self.rst.append(finfo)
|
154
|
+
return False
|
155
|
+
def catch(self, finfo, depth, exp):
|
156
|
+
filepath = finfo.path
|
157
|
+
if self.relative:
|
158
|
+
filepath = finfo.rpath
|
159
|
+
print(f"exp in {finfo}: {exp}")
|
160
|
+
self.errs.append([finfo, exp])
|
161
|
+
pass
|
162
|
+
|
163
|
+
pass
|
164
|
+
|
165
|
+
def lists(fp):
|
166
|
+
return ListsDeal().dirs(fp)
|
167
|
+
|
168
|
+
pass
|
169
|
+
def _search(dp, pt_fp = None, pt = None, pt_dp = None, depth=None, relative = False, show = False, shows = [10,10]):
|
170
|
+
deal = SearchDeal(pt_fp, pt, pt_dp, depth,relative, show, shows)
|
171
|
+
return deal.dirs(dp)
|
172
|
+
|
173
|
+
pass
|
174
|
+
def searchs(dp, pt_fp = None, pt = None, pt_dp = None, depth=None, relative = False, show = False, shows = [10,10]):
|
175
|
+
deal = SearchDeal(pt_fp, pt, pt_dp, depth,relative, show, shows)
|
176
|
+
deal.dirs(dp)
|
177
|
+
return deal.fps(keep_dir=True, fp_only=False)
|
178
|
+
|
179
|
+
pass
|
180
|
+
def searchd(dp, pt_fp = None, pt = None, pt_dp = None, depth=None, relative = False, show = False, shows = [10,10]):
|
181
|
+
deal = SearchDeal(pt_fp, pt, pt_dp, depth,relative, show, shows)
|
182
|
+
deal.dirs(dp)
|
183
|
+
return deal.fps(keep_dir=True, fp_only=True)
|
184
|
+
|
185
|
+
pass
|
186
|
+
|
187
|
+
def search(dp, pt_fp = None, pt = None, depth=None, relative = False, show = False, shows = [10,10]):
|
188
|
+
deal = SearchDeal(pt_fp, pt, None, depth,relative, show, shows)
|
189
|
+
deal.dirs(dp)
|
190
|
+
return deal.fps(keep_dir=False, fp_only=True)
|
191
|
+
|
192
|
+
pass
|
@@ -320,6 +320,7 @@ class Confs(Base):
|
|
320
320
|
for k in obj.deals:
|
321
321
|
self.deals[k] = obj.deals[k]
|
322
322
|
self.update_maps(self.envs, obj.envs)
|
323
|
+
self.mark_init = False
|
323
324
|
def get(self, *args, **maps):
|
324
325
|
return self.get_obj(*args, **maps)
|
325
326
|
def remove(self, *a,**b):
|
@@ -350,6 +351,7 @@ class Confs(Base):
|
|
350
351
|
"""
|
351
352
|
根据type类型查处理函数deal,sid(配置文件id)不为空并且global_deal=False则先查局部
|
352
353
|
"""
|
354
|
+
self.do_init()
|
353
355
|
if sid is not None and not self.global_deal:
|
354
356
|
deal = self.confs[sid].get_deal(type, False)
|
355
357
|
if deal is not None:
|
@@ -90,8 +90,13 @@ class ObjectDeal(FormatDeal):
|
|
90
90
|
info = edata.info
|
91
91
|
conf = edata.conf
|
92
92
|
confs = edata.confs
|
93
|
+
icst = None
|
94
|
+
isets = None
|
93
95
|
if type(info) == dict:
|
94
96
|
cid = xf.g(info, id=None)
|
97
|
+
iargs, imaps = xf.g(info, args = None, maps = None)
|
98
|
+
icst = {'args':iargs, 'maps':imaps}
|
99
|
+
isets = xf.g(info, sets = None)
|
95
100
|
else:
|
96
101
|
cid = None
|
97
102
|
id = xf.g(data, id = None)
|
@@ -105,6 +110,8 @@ class ObjectDeal(FormatDeal):
|
|
105
110
|
if cid is not None:
|
106
111
|
ids = [sid, 'local_id', id, cid]
|
107
112
|
else:
|
113
|
+
if icst is not None or isets is not None:
|
114
|
+
raise Exception("set info.construct/info.sets while using single without info.id")
|
108
115
|
ids = [sid, 'single', id]
|
109
116
|
if ids is not None:
|
110
117
|
obj = xf.gets(self.singles, ids)
|
@@ -124,6 +131,8 @@ class ObjectDeal(FormatDeal):
|
|
124
131
|
_maps = xf.g(data, maps = {})
|
125
132
|
cst = [_args, _maps]
|
126
133
|
cst = self.fmt_cst(cst)
|
134
|
+
if icst is not None:
|
135
|
+
xf.fill(icst, cst, 1)
|
127
136
|
args = xf.g(cst, args=[])
|
128
137
|
maps = xf.g(cst, maps={})
|
129
138
|
args = [self.get_obj(v, conf) for v in args]
|
@@ -133,20 +142,30 @@ class ObjectDeal(FormatDeal):
|
|
133
142
|
xf.sets(self.singles, ids, obj)
|
134
143
|
prev_call = xf.g(data, prev_call=None)
|
135
144
|
if prev_call is not None:
|
136
|
-
# TODO: 这边info
|
145
|
+
# TODO: 这边info透传不知道会不会有问题
|
137
146
|
self.get_obj(prev_call, conf, obj, edata.info)
|
138
147
|
sets = xf.g(data, sets=[])
|
139
148
|
if type(sets)==list:
|
149
|
+
tmp = {}
|
140
150
|
for kv in sets:
|
141
151
|
kv = self.fmt_set(kv)
|
142
152
|
k = kv['key']
|
143
153
|
v = xf.get_first(kv, "val", "data")
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
154
|
+
tmp[k] = v
|
155
|
+
sets = tmp
|
156
|
+
if type(isets) == list:
|
157
|
+
tmp = {}
|
158
|
+
for kv in isets:
|
159
|
+
kv = self.fmt_set(kv)
|
160
|
+
k = kv['key']
|
161
|
+
v = xf.get_first(kv, "val", "data")
|
162
|
+
tmp[k] = v
|
163
|
+
isets = tmp
|
164
|
+
if isets is not None:
|
165
|
+
xf.fill(isets, sets, 1)
|
166
|
+
for k,v in sets.items():
|
167
|
+
v = self.get_obj(v, conf, obj, edata.info)
|
168
|
+
setattr(obj, k, v)
|
150
169
|
call = xf.g(data, call=None)
|
151
170
|
if call is not None:
|
152
171
|
self.get_obj(call, conf, obj, edata.info)
|
@@ -2,7 +2,7 @@ from .. import base
|
|
2
2
|
from .. import item
|
3
3
|
from .. import exp
|
4
4
|
from ... import file
|
5
|
-
|
5
|
+
|
6
6
|
from . import lr
|
7
7
|
|
8
8
|
def init():
|
@@ -10,13 +10,12 @@ def init():
|
|
10
10
|
maps = {k:k.encode()[0] for k in cs}
|
11
11
|
global c2b
|
12
12
|
c2b = maps
|
13
|
-
global
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
ts = b"\a\b\f\n\r\t\v\\\'\"\?"
|
13
|
+
global special_keys
|
14
|
+
special_keys = [-1]*256
|
15
|
+
s = "abfnrtv\\'\""
|
16
|
+
ts = b"\a\b\f\n\r\t\v\\\'\""
|
18
17
|
for c,t in zip(s, ts):
|
19
|
-
|
18
|
+
special_keys[c2b[c]] = t
|
20
19
|
symbal_a = [False]*256
|
21
20
|
for c in s:
|
22
21
|
symbal_a[c2b[c]] = True
|
@@ -26,9 +25,8 @@ def init():
|
|
26
25
|
id_x = b'x'[0]
|
27
26
|
|
28
27
|
pass
|
29
|
-
|
30
28
|
init()
|
31
|
-
def translate_bts(bts):
|
29
|
+
def translate_bts(bts, octs = None, hexs = None):
|
32
30
|
i = 0
|
33
31
|
rs = []
|
34
32
|
while i<len(bts):
|
@@ -39,30 +37,37 @@ def translate_bts(bts):
|
|
39
37
|
continue
|
40
38
|
x0 = bts[i]
|
41
39
|
i+=1
|
42
|
-
if
|
43
|
-
rs.append(
|
40
|
+
if special_keys[x0]>=0:
|
41
|
+
rs.append(special_keys[x0])
|
44
42
|
continue
|
45
43
|
v = x0-id_0
|
46
44
|
if v>=0 and v<=7:
|
47
45
|
tmp = v
|
46
|
+
base=i
|
48
47
|
for j in range(2):
|
49
|
-
if
|
48
|
+
if base+j>=len(bts):
|
50
49
|
break
|
51
|
-
xi = bts[
|
50
|
+
xi = bts[base+j]
|
52
51
|
vi = xi-id_0
|
53
52
|
if vi>=0 and vi<=7:
|
54
53
|
i+=1
|
55
|
-
tmp = (
|
54
|
+
tmp = (tmp<<3)+vi
|
56
55
|
else:
|
57
56
|
break
|
58
|
-
|
57
|
+
if octs is not None:
|
58
|
+
#print(f"tmp: '{tmp}', {type(tmp)}")
|
59
|
+
#print(f"ocst: {octs}, {type(octs)}")
|
60
|
+
tmp = octs[tmp]
|
61
|
+
else:
|
62
|
+
tmp = [tmp%256]
|
63
|
+
rs+=tmp
|
59
64
|
continue
|
60
65
|
if x0 == id_x:
|
61
66
|
tmp = 0
|
62
67
|
for j in range(2):
|
63
|
-
if i+j
|
68
|
+
if i+j>=len(bts):
|
64
69
|
raise Exception("\\xXX error")
|
65
|
-
xi = bts[i+j
|
70
|
+
xi = bts[i+j]
|
66
71
|
vi = xi-id_0
|
67
72
|
if vi<0 or vi>7:
|
68
73
|
vi = xi-id_a
|
@@ -70,7 +75,12 @@ def translate_bts(bts):
|
|
70
75
|
raise Exception("\\xXX error")
|
71
76
|
vi +=10
|
72
77
|
tmp=(tmp<<4)+vi
|
73
|
-
|
78
|
+
i+=2
|
79
|
+
if hexs is not None:
|
80
|
+
tmp = hexs[tmp]
|
81
|
+
else:
|
82
|
+
tmp = [tmp]
|
83
|
+
rs+=tmp
|
74
84
|
continue
|
75
85
|
rs.append(c)
|
76
86
|
rs.append(x0)
|
@@ -78,7 +88,23 @@ def translate_bts(bts):
|
|
78
88
|
return bytes(rs)
|
79
89
|
|
80
90
|
pass
|
91
|
+
def gen_chars(code="utf-8"):
|
92
|
+
simple = "abfnrtv\\'\""
|
93
|
+
octs = [0]*512
|
94
|
+
hexs = [0]*256
|
95
|
+
for i in range(512):
|
96
|
+
if i<256:
|
97
|
+
vhex = hex(i)[2:]
|
98
|
+
if len(vhex)==1:
|
99
|
+
vhex = "0"+vhex
|
100
|
+
cmd = f"'\\x{vhex}'"
|
101
|
+
hexs[i] = list(eval(cmd).encode(code))
|
102
|
+
voct = oct(i)[2:]
|
103
|
+
cmd = f"'\\{voct}'"
|
104
|
+
octs[i] = list(eval(cmd).encode(code))
|
105
|
+
return octs, hexs
|
81
106
|
|
107
|
+
pass
|
82
108
|
class PrevStrDeal(lr.LRDeal):
|
83
109
|
def types(self):
|
84
110
|
if not self.deal_build:
|
@@ -97,6 +123,9 @@ class PrevStrDeal(lr.LRDeal):
|
|
97
123
|
return obj
|
98
124
|
def prepare(self, mg):
|
99
125
|
super().prepare(mg)
|
126
|
+
self.as_bytes = mg.as_bytes
|
127
|
+
if not self.as_bytes:
|
128
|
+
self.octs,self.hexs = gen_chars()
|
100
129
|
self.label_l2 = mg.like("\\")
|
101
130
|
self.label_qt = mg.like('"')
|
102
131
|
self.label_et = mg.like("\n")
|
@@ -109,7 +138,11 @@ class PrevStrDeal(lr.LRDeal):
|
|
109
138
|
self.note = note
|
110
139
|
self.translate = translate
|
111
140
|
self.deal_build = deal_build
|
141
|
+
self.as_bytes = True
|
142
|
+
self.octs = None
|
143
|
+
self.hexs = None
|
112
144
|
def json_loads(self, s):
|
145
|
+
import json
|
113
146
|
x = s
|
114
147
|
cd = None
|
115
148
|
if type(x)==bytes:
|
@@ -119,10 +152,13 @@ class PrevStrDeal(lr.LRDeal):
|
|
119
152
|
rs = rs.encode(cd)
|
120
153
|
return rs
|
121
154
|
def do_translate(self, s):
|
155
|
+
"""
|
156
|
+
取巧用python的eval来生成字符表
|
157
|
+
"""
|
122
158
|
is_bytes = type(s)==bytes
|
123
159
|
if not is_bytes:
|
124
160
|
s = s.encode("utf-8")
|
125
|
-
s = translate_bts(s)
|
161
|
+
s = translate_bts(s, self.octs, self.hexs)
|
126
162
|
if not is_bytes:
|
127
163
|
s = s.decode("utf-8")
|
128
164
|
return s
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: buildz
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.91
|
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
|
buildz-0.5.9/buildz/fz/lsf.py
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
#coding=utf-8
|
2
|
-
|
3
|
-
from . import dirz
|
4
|
-
|
5
|
-
import re
|
6
|
-
class ListsDeal(dirz.FileDeal):
|
7
|
-
def result(self):
|
8
|
-
return self.fps, self.errors
|
9
|
-
def init(self):
|
10
|
-
super().init()
|
11
|
-
self.fps = []
|
12
|
-
self.errors = []
|
13
|
-
def visit(self, finfo, depth):
|
14
|
-
fp, isdir = finfo.path, finfo.isdir
|
15
|
-
self.fps.append([fp, isdir])
|
16
|
-
return True
|
17
|
-
def catch(self, finfo, depth, exp):
|
18
|
-
fp, isdir = finfo.path, finfo.isdir
|
19
|
-
self.errors.append([fp, isdir, exp])
|
20
|
-
|
21
|
-
pass
|
22
|
-
|
23
|
-
class SearchDeal(dirz.FileDeal):
|
24
|
-
def init(self, pt_fp=None, pt = None, pt_dp = None, depth = None, relative = False):
|
25
|
-
super().init()
|
26
|
-
self.pt_fp = pt_fp
|
27
|
-
self.pt_dp = pt_dp
|
28
|
-
if type(pt) == str:
|
29
|
-
pt = pt.encode()
|
30
|
-
self.pt = pt
|
31
|
-
self.rst = []
|
32
|
-
self.errs = []
|
33
|
-
self.depth = depth
|
34
|
-
self.relative = relative
|
35
|
-
def fps(self, keep_dir = False, relative = None, fp_only = True):
|
36
|
-
if relative is None:
|
37
|
-
relative = self.relative
|
38
|
-
rst = self.rst
|
39
|
-
if relative:
|
40
|
-
rst = [[i.rpath, i.isdir] for i in rst]
|
41
|
-
else:
|
42
|
-
rst = [[i.path, i.isdir] for i in rst]
|
43
|
-
if not keep_dir:
|
44
|
-
rst = [k for k in rst if not k[1]]
|
45
|
-
if fp_only:
|
46
|
-
rst = [k[0] for k in rst]
|
47
|
-
return rst
|
48
|
-
def result(self):
|
49
|
-
return self.rst
|
50
|
-
def visit(self, finfo, depth):
|
51
|
-
if self.depth is not None and depth > self.depth:
|
52
|
-
return False
|
53
|
-
filepath = finfo.path
|
54
|
-
isdir = finfo.isdir
|
55
|
-
if self.relative:
|
56
|
-
filepath = finfo.rpath
|
57
|
-
if isdir:
|
58
|
-
if finfo.empty_dir or depth==self.depth:
|
59
|
-
if self.pt_dp is not None and len(re.findall(self.pt_dp, filepath))==0:
|
60
|
-
return True
|
61
|
-
self.rst.append(finfo)
|
62
|
-
return True
|
63
|
-
if self.pt_fp is not None and len(re.findall(self.pt_fp, filepath))==0:
|
64
|
-
return False
|
65
|
-
if self.pt is not None:
|
66
|
-
try:
|
67
|
-
with open(filepath, 'rb') as f:
|
68
|
-
s = f.read()
|
69
|
-
except Exception as exp:
|
70
|
-
self.catch(finfo, depth, exp)
|
71
|
-
return False
|
72
|
-
if len(re.findall(self.pt, s))==0:
|
73
|
-
return False
|
74
|
-
self.rst.append(finfo)
|
75
|
-
return False
|
76
|
-
def catch(self, finfo, depth, exp):
|
77
|
-
filepath = finfo.path
|
78
|
-
if self.relative:
|
79
|
-
filepath = finfo.rpath
|
80
|
-
print(f"exp in {finfo}: {exp}")
|
81
|
-
self.errs.append([finfo, exp])
|
82
|
-
pass
|
83
|
-
|
84
|
-
pass
|
85
|
-
|
86
|
-
def lists(fp):
|
87
|
-
return ListsDeal().dirs(fp)
|
88
|
-
|
89
|
-
pass
|
90
|
-
def _search(dp, pt_fp = None, pt = None, pt_dp = None, depth=None, relative = False):
|
91
|
-
deal = SearchDeal(pt_fp, pt, pt_dp, depth,relative)
|
92
|
-
return deal.dirs(dp)
|
93
|
-
|
94
|
-
pass
|
95
|
-
def searchs(dp, pt_fp = None, pt = None, pt_dp = None, depth=None, relative = False):
|
96
|
-
deal = SearchDeal(pt_fp, pt, pt_dp, depth,relative)
|
97
|
-
deal.dirs(dp)
|
98
|
-
return deal.fps(keep_dir=True, fp_only=False)
|
99
|
-
|
100
|
-
pass
|
101
|
-
def searchd(dp, pt_fp = None, pt = None, pt_dp = None, depth=None, relative = False):
|
102
|
-
deal = SearchDeal(pt_fp, pt, pt_dp, depth,relative)
|
103
|
-
deal.dirs(dp)
|
104
|
-
return deal.fps(keep_dir=True, fp_only=True)
|
105
|
-
|
106
|
-
pass
|
107
|
-
|
108
|
-
def search(dp, pt_fp = None, pt = None, depth=None, relative = False):
|
109
|
-
deal = SearchDeal(pt_fp, pt, None, depth,relative)
|
110
|
-
deal.dirs(dp)
|
111
|
-
return deal.fps(keep_dir=False, fp_only=True)
|
112
|
-
|
113
|
-
pass
|
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
|
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
|