buildz 0.6.5__tar.gz → 0.6.8__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.6.5/buildz.egg-info → buildz-0.6.8}/PKG-INFO +1 -1
- {buildz-0.6.5 → buildz-0.6.8}/buildz/__init__.py +2 -1
- buildz-0.6.8/buildz/base.py +21 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/fz/__init__.py +1 -1
- buildz-0.6.8/buildz/fz/fhs.py +55 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc/base.py +12 -5
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc/conf.py +6 -2
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc/confs.py +26 -4
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc/single.py +15 -4
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/base.py +26 -19
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/call.py +1 -1
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/calls.py +0 -2
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/ref_lists.js +4 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/deal.py +1 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/iocf.py +1 -1
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/mcall.py +2 -2
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/obj.py +17 -40
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/ovar.py +1 -1
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/ref.py +13 -3
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/var.py +1 -1
- {buildz-0.6.5 → buildz-0.6.8}/buildz/pyz.py +48 -1
- buildz-0.6.8/buildz/tools.py +3 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/__init__.py +1 -1
- buildz-0.6.8/buildz/xf/loaderz/deal/listmapz.py +57 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/listz.py +5 -4
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/mapz.py +4 -4
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/item.py +3 -2
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/mg.py +5 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/mapz.py +17 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/readz.py +65 -2
- {buildz-0.6.5 → buildz-0.6.8/buildz.egg-info}/PKG-INFO +1 -1
- {buildz-0.6.5 → buildz-0.6.8}/buildz.egg-info/SOURCES.txt +3 -0
- {buildz-0.6.5 → buildz-0.6.8}/setup.py +1 -1
- buildz-0.6.5/buildz/fz/fhs.py +0 -17
- {buildz-0.6.5 → buildz-0.6.8}/LICENSE +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/MANIFEST.in +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/README.md +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/__main__.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/argx.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/cmd.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/__main__.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/dv/basez.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/dv/clickhousez.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/dv/lib/readme +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/dv/mysqlz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/dv/oraclez.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/dv/structz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/install.txt +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/run.conf +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/db/runz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/ioc/deal.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/ioc/help.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/myers/deal.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/myers/help.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/conf/ioc.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/conf/main.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/conf/myers.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/conf/search.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/conf/xf.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/help/default.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/help/ioc.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/help/myers.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/help/search.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/help/xf.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/res/test.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/search/deal.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/search/help.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/test.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/xf/deal.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/demo/xf/help.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/fz/dirz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/fz/fio.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/fz/lsf.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/__init__.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/base.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/init.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/deal_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/deals.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/iocf_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/xfile_defaults.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/conf/xfile_lists.js +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/demo.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/env.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/ioc.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/join.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/list.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/map.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/val.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/ioc/ioc_deal/xfile.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/tz/__init__.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/tz/myers_diff.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/__main__.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/code.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/code_modify.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/copy_old.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/file.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/base.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/buffer.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/listz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/lr.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/lrval.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/mapz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/nextz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/reval.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/setz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/spc.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/spt.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/deal/strz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/exp.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/item.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/mg.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loader/pos.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/base.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/buffer.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/lr.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/lrval.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/nextz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/reval.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/setz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/spc.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/spt.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/strz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/strz_new.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/deal/strz_old.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/exp.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/pos.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/test.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/loaderz/test1.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/read.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/stack.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/write.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/writer/base.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/writer/conf.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/writer/deal/jsonval.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/writer/deal/listz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/writer/deal/mapz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/writer/deal/reval.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/writer/deal/strz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/writer/itemz.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/writer/mg.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz/xf/xargs.py +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz.egg-info/dependency_links.txt +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/buildz.egg-info/top_level.txt +0 -0
- {buildz-0.6.5 → buildz-0.6.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: buildz
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.8
|
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), and other tool codes
|
5
5
|
Home-page: https://github.com/buildCodeZ/buildz
|
6
6
|
Author: Zzz
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
|
3
|
+
class Base:
|
4
|
+
def str(self):
|
5
|
+
return str(self.__class__)
|
6
|
+
def __str__(self):
|
7
|
+
return self.str()
|
8
|
+
def __repr__(self):
|
9
|
+
return self.__str__()
|
10
|
+
def __init__(self, *args, **maps):
|
11
|
+
self.init(*args, **maps)
|
12
|
+
def __call__(self, *args, **maps):
|
13
|
+
return self.call(*args, **maps)
|
14
|
+
def init(self, *args, **maps):
|
15
|
+
pass
|
16
|
+
def call(self, *args, **maps):
|
17
|
+
return self.deal(*args, **maps)
|
18
|
+
def deal(self, *args, **maps):
|
19
|
+
return None
|
20
|
+
|
21
|
+
pass
|
@@ -3,6 +3,6 @@
|
|
3
3
|
from .dirz import dirs, FileDeal
|
4
4
|
from .lsf import lists, search, searchd,searchs,_search
|
5
5
|
from .fio import fread, freads, fwrite, fwrites, read,reads,write,writes, makefdir, dirpath,makedir,removes, cover, fcover, sread, swrite
|
6
|
-
from .fhs import fhash
|
6
|
+
from .fhs import fhash, fhashs
|
7
7
|
|
8
8
|
__author__ = "Zzz, emails: 1174534295@qq.com, 1309458652@qq.com"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
|
3
|
+
import hashlib
|
4
|
+
import os
|
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
|
18
|
+
def bs_hash(bs, fhm):
|
19
|
+
obj = fhm()
|
20
|
+
obj.update(bs)
|
21
|
+
return obj.hexdigest()
|
22
|
+
|
23
|
+
pass
|
24
|
+
def fhashs(fp, blk_size = 10240, max_read = -1, hm = "sha256"):
|
25
|
+
if type(hm) == str:
|
26
|
+
fhm = getattr(hashlib, hm)
|
27
|
+
else:
|
28
|
+
fhm = hm
|
29
|
+
hashs = []
|
30
|
+
if not os.path.isfile(fp) or max_read==0:
|
31
|
+
return hashs
|
32
|
+
size = 0
|
33
|
+
bs = b""
|
34
|
+
reads = 0
|
35
|
+
mark_read = True
|
36
|
+
with open(fp, 'rb') as f:
|
37
|
+
while len(bs)>0 or mark_read:
|
38
|
+
if max_read>0 and size>=max_read:
|
39
|
+
break
|
40
|
+
read_size = blk_size
|
41
|
+
if max_read>0:
|
42
|
+
read_size = min(max_read-size, blk_size)
|
43
|
+
if mark_read:
|
44
|
+
curr = f.read(read_size)
|
45
|
+
if len(curr)==0:
|
46
|
+
mark_read = False
|
47
|
+
else:
|
48
|
+
bs += curr
|
49
|
+
if len(bs)>=read_size or not mark_read:
|
50
|
+
tmp = bs[:read_size]
|
51
|
+
bs = bs[read_size:]
|
52
|
+
size+=read_size
|
53
|
+
hashs.append(bs_hash(tmp, fhm))
|
54
|
+
return hashs
|
55
|
+
|
@@ -9,6 +9,8 @@ class IOCError(Exception):
|
|
9
9
|
super().__init__(msg)
|
10
10
|
|
11
11
|
pass
|
12
|
+
class IdNotFoundError(IOCError):
|
13
|
+
pass
|
12
14
|
class Base:
|
13
15
|
def update_maps(self, maps, src, replace=1):
|
14
16
|
xf.deep_update(maps, src, replace)
|
@@ -28,7 +30,7 @@ class EncapeData(Base):
|
|
28
30
|
包含data id对应的配置,配置文件id,配置文件对象
|
29
31
|
[object.test, call, ]
|
30
32
|
"""
|
31
|
-
def __init__(self, data, conf, local = False, type = None, src = None, info = None):
|
33
|
+
def __init__(self, data, conf=None, local = False, type = None, src = None, info = None, confs = None):
|
32
34
|
"""
|
33
35
|
data: 配置数据
|
34
36
|
conf: 配置数据对应的配置文件的管理器
|
@@ -54,16 +56,21 @@ class EncapeData(Base):
|
|
54
56
|
raise IOCError("only dict can be a parent: "+pid)
|
55
57
|
self.update_maps(data, pdt, replace=0)
|
56
58
|
self.data = data
|
57
|
-
|
59
|
+
if conf is not None:
|
60
|
+
self.sid = conf.id
|
61
|
+
if type is None:
|
62
|
+
type = conf.confs.get_data_type(data, 0, conf.default_type())
|
63
|
+
if confs is None:
|
64
|
+
confs = conf.confs
|
58
65
|
self.src = src
|
59
66
|
self.conf = conf
|
60
|
-
self.confs =
|
67
|
+
self.confs = confs
|
61
68
|
self.local = local
|
62
|
-
if type is None:
|
63
|
-
type = conf.confs.get_data_type(data, 0, conf.default_type())
|
64
69
|
self.type = type
|
65
70
|
self.info = info
|
66
71
|
def deal(self, remove = False):
|
72
|
+
if self.conf is None:
|
73
|
+
return self.confs.get(self, src = self.src, info=self.info, remove = remove)
|
67
74
|
return self.conf.get(self, src = self.src, info=self.info, remove = remove)
|
68
75
|
|
69
76
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
from buildz import xf, pyz
|
3
3
|
from buildz.xf import g as xg
|
4
4
|
import json
|
5
|
-
from .base import Base, EncapeData,IOCError
|
5
|
+
from .base import Base, EncapeData,IOCError, IdNotFoundError
|
6
6
|
from builtins import id as _id
|
7
7
|
class Conf(Base):
|
8
8
|
"""
|
@@ -198,8 +198,12 @@ class Conf(Base):
|
|
198
198
|
else:
|
199
199
|
conf = self.get_data(id, src = src, info = info)
|
200
200
|
if conf is None:
|
201
|
-
raise
|
201
|
+
raise IdNotFoundError(f"can't find conf of {id}")
|
202
202
|
return None
|
203
|
+
if conf.conf is None:
|
204
|
+
if remove:
|
205
|
+
return None
|
206
|
+
return conf.data()
|
203
207
|
deal = self.get_deal(conf.type)
|
204
208
|
if deal is None:
|
205
209
|
raise IOCError(f"can't find deal of {id}, type = {conf.type}")
|
@@ -3,7 +3,7 @@ from buildz import xf, pyz
|
|
3
3
|
from buildz.xf import g as xg
|
4
4
|
from buildz import argx
|
5
5
|
import json
|
6
|
-
from .base import Base, EncapeData,IOCError
|
6
|
+
from .base import Base, EncapeData,IOCError, IdNotFoundError
|
7
7
|
from .conf import Conf
|
8
8
|
import os
|
9
9
|
class ConfsNode(Base):
|
@@ -231,12 +231,26 @@ class Confs(Base):
|
|
231
231
|
self.envs_args = None
|
232
232
|
self.mark_init = False
|
233
233
|
self.vars = {}
|
234
|
+
self.fcs = {}
|
234
235
|
if 'args' in self.env_orders:
|
235
236
|
self.build_env_args()
|
237
|
+
def set_fc(self, key, fc):
|
238
|
+
self.fcs[key] = fc
|
239
|
+
def get_fc(self, key):
|
240
|
+
if key not in self.fcs:
|
241
|
+
return None
|
242
|
+
return self.fcs[key]
|
236
243
|
def get_var(self, key, i=-1):
|
237
244
|
if not self.has_var(key):
|
238
245
|
return None, False
|
239
246
|
return self.vars[key][i], True
|
247
|
+
def push_vars(self, vars):
|
248
|
+
if vars is not None:
|
249
|
+
[self.push_var(key,val) for key,val in vars.items()]
|
250
|
+
return pyz.with_out(lambda :self.pop_vars(vars))
|
251
|
+
def pop_vars(self, vars):
|
252
|
+
if vars is not None:
|
253
|
+
[self.pop_var(key) for key in vars]
|
240
254
|
def push_var(self, key, val):
|
241
255
|
if key not in self.vars:
|
242
256
|
self.vars[key] = []
|
@@ -331,7 +345,8 @@ class Confs(Base):
|
|
331
345
|
if type(conf) in [bytes, str]:
|
332
346
|
conf = self.loads(conf)
|
333
347
|
obj = Conf(conf, self)
|
334
|
-
id =
|
348
|
+
id = obj.namespace
|
349
|
+
#id = xf.g1(conf, id=None, namespace=None)
|
335
350
|
ids = self.ids(id)
|
336
351
|
node = self.node
|
337
352
|
for id in ids:
|
@@ -358,8 +373,12 @@ class Confs(Base):
|
|
358
373
|
else:
|
359
374
|
conf = self.get_data(id, sid, src=src, info = info)
|
360
375
|
if conf is None:
|
361
|
-
raise
|
376
|
+
raise IdNotFoundError(f"confs: can't find conf of {id}")
|
362
377
|
return None
|
378
|
+
if conf.conf is None:
|
379
|
+
if remove:
|
380
|
+
return None
|
381
|
+
return conf.data()
|
363
382
|
deal = self.get_deal(conf.type, sid)
|
364
383
|
if deal is None:
|
365
384
|
raise IOCError(f"confs: can't find deal of {id}, type = {conf.type}")
|
@@ -409,6 +428,9 @@ class Confs(Base):
|
|
409
428
|
_conf = conf.get_data(id, sid==conf.id, False, src = src, info = info)
|
410
429
|
if _conf is not None:
|
411
430
|
return _conf
|
412
|
-
|
431
|
+
fc = self.get_fc(id)
|
432
|
+
if fc is None:
|
433
|
+
return None
|
434
|
+
return EncapeData(fc, confs=self)
|
413
435
|
|
414
436
|
pass
|
@@ -25,7 +25,7 @@ class Single(Base):
|
|
25
25
|
data = edata.data
|
26
26
|
info = edata.info
|
27
27
|
if type(info) == dict:
|
28
|
-
cid = xf.get(info, self.
|
28
|
+
cid = xf.get(info, self.k_cid, None)
|
29
29
|
else:
|
30
30
|
cid = None
|
31
31
|
id = xf.g(data, id = None)
|
@@ -41,16 +41,27 @@ class Single(Base):
|
|
41
41
|
else:
|
42
42
|
ids = [sid, 'single', id]
|
43
43
|
return ids
|
44
|
-
def
|
45
|
-
ids = self.get_ids(edata)
|
44
|
+
def get_by_ids(self, ids):
|
46
45
|
if ids is None:
|
47
46
|
return None
|
48
47
|
obj = xf.gets(self.singles, ids)
|
49
48
|
return obj
|
50
|
-
def
|
49
|
+
def get(self, edata:EncapeData):
|
51
50
|
ids = self.get_ids(edata)
|
51
|
+
return self.get_by_ids(ids)
|
52
|
+
def set_by_ids(self, ids, obj):
|
52
53
|
if ids is None:
|
53
54
|
return
|
54
55
|
xf.sets(self.singles, ids, obj)
|
56
|
+
def set(self, obj, edata:EncapeData):
|
57
|
+
ids = self.get_ids(edata)
|
58
|
+
self.set_by_ids(ids, obj)
|
59
|
+
def rm_by_ids(self, idsj):
|
60
|
+
if ids is None:
|
61
|
+
return
|
62
|
+
xf.removes(self.singles, ids)
|
63
|
+
def remove(self,edata:EncapeData):
|
64
|
+
ids = self.get_ids(edata)
|
65
|
+
self.rm_by_ids(ids)
|
55
66
|
|
56
67
|
pass
|
@@ -96,8 +96,9 @@ class FormatData(Base):
|
|
96
96
|
null = xf.g(obj, nullable=1)
|
97
97
|
if not null:
|
98
98
|
raise Exception(f"error format in {self.name}, not default value for index {i}, key {key}")
|
99
|
-
default
|
100
|
-
|
99
|
+
if "default" in obj:
|
100
|
+
default = xf.g(obj, default=None)
|
101
|
+
maps[key] = default
|
101
102
|
cnt +=1
|
102
103
|
continue
|
103
104
|
next_conf = xf.g(obj, conf = None)
|
@@ -138,6 +139,12 @@ class BaseDeal(Base):
|
|
138
139
|
_type = conf.confs.get_data_type(data, 1, conf.default_type())
|
139
140
|
edata = EncapeData(data, conf, local=True, type=_type, src = src, info = info)
|
140
141
|
return edata
|
142
|
+
def fill_objs(self, data, conf, src = None, info = None):
|
143
|
+
if type(data)==list:
|
144
|
+
data = [get_obj(k, conf, src, info) for k in data]
|
145
|
+
else:
|
146
|
+
data = {k:get_obj(v, conf, src, info) for k,v in data.items()}
|
147
|
+
return data
|
141
148
|
def get_obj(self, data, conf, src = None, info = None):
|
142
149
|
edata = self.get_data(data, conf, src, info)
|
143
150
|
return edata()
|
@@ -149,10 +156,10 @@ class BaseDeal(Base):
|
|
149
156
|
_type = conf.confs.get_data_type(data, 1, conf.default_type())
|
150
157
|
edata = EncapeData(data, conf, local=True, type=_type, src = src, info = info)
|
151
158
|
return edata()
|
152
|
-
deal = conf.get_deal(edata.type)
|
153
|
-
if deal is None:
|
154
|
-
|
155
|
-
return deal(edata)
|
159
|
+
# deal = conf.get_deal(edata.type)
|
160
|
+
# if deal is None:
|
161
|
+
# return None
|
162
|
+
# return deal(edata)
|
156
163
|
def deal(self, edata:EncapeData):
|
157
164
|
"""
|
158
165
|
"""
|
@@ -190,18 +197,18 @@ class FormatDeal(BaseDeal):
|
|
190
197
|
data = self.format.l2m(data)
|
191
198
|
self.format.fill(data)
|
192
199
|
return data
|
193
|
-
def get_obj(self, data, conf, src = None, info = None):
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
200
|
+
# def get_obj(self, data, conf, src = None, info = None):
|
201
|
+
# if type(data) not in [list, dict, tuple]:
|
202
|
+
# i = conf.confs.data_index_type[0]
|
203
|
+
# data = [conf.default_type(), data]
|
204
|
+
# if i != 0:
|
205
|
+
# data.reverse()
|
206
|
+
# _type = conf.confs.get_data_type(data, 1, conf.default_type())
|
207
|
+
# edata = EncapeData(data, conf, local=True, type=_type, src = src, info = info)
|
208
|
+
# return edata()
|
209
|
+
# deal = conf.get_deal(edata.type)
|
210
|
+
# if deal is None:
|
211
|
+
# return None
|
212
|
+
# return deal(edata)
|
206
213
|
|
207
214
|
pass
|
@@ -60,9 +60,9 @@ class CallDeal(FormatDeal):
|
|
60
60
|
xf.fill(imaps, maps, 1)
|
61
61
|
# args = [self.get_obj(v, conf, src, info = edata.info) for v in args]
|
62
62
|
# maps = {k:self.get_obj(maps[k], conf, src, info = edata.info) for k in maps}
|
63
|
+
self.push_vars(conf, ivars)
|
63
64
|
args = [self.get_obj(v, conf, src) for v in args]
|
64
65
|
maps = {k:self.get_obj(maps[k], conf, src) for k in maps}
|
65
|
-
self.push_vars(conf, ivars)
|
66
66
|
rst = method(*args, **maps)
|
67
67
|
self.pop_vars(conf, ivars)
|
68
68
|
return rst
|
@@ -24,8 +24,6 @@ class CallsDeal(FormatDeal):
|
|
24
24
|
[[main_call, calls], [[call, buildz.pyz.pyexe], [call, buildz.pyz.pypkg]]]
|
25
25
|
"""
|
26
26
|
def init(self, fp_lists = None, fp_defaults = None):
|
27
|
-
self.singles = {}
|
28
|
-
self.sources = {}
|
29
27
|
super().init("CallsDeal", fp_lists, fp_defaults,
|
30
28
|
join(dp, "conf", "calls_lists.js"),
|
31
29
|
join(dp, "conf", "calls_defaults.js"))
|
@@ -67,6 +67,7 @@ class DealDeal(FormatDeal):
|
|
67
67
|
super().init("DealDeal", fp_lists, fp_defaults, join(dp, "conf", "deal_lists.js"), None)
|
68
68
|
def deal(self, edata:EncapeData):
|
69
69
|
data = edata.data
|
70
|
+
data = self.fill(data)
|
70
71
|
source = xf.g(data, source=None)
|
71
72
|
if source is None:
|
72
73
|
raise IOCError("not source in dealdeal")
|
@@ -62,7 +62,7 @@ class MethodCallDeal(FormatDeal):
|
|
62
62
|
iargs, imaps = None, None
|
63
63
|
ivars = None
|
64
64
|
if type(info) == dict:
|
65
|
-
iargs, imaps = xf.g(info, m_args = None, m_maps = None, vars=None)
|
65
|
+
iargs, imaps, ivars = xf.g(info, m_args = None, m_maps = None, vars=None)
|
66
66
|
args = xf.g(data, args=[])
|
67
67
|
maps = xf.g(data, maps ={})
|
68
68
|
vars = xf.g(data, vars={})
|
@@ -76,9 +76,9 @@ class MethodCallDeal(FormatDeal):
|
|
76
76
|
xf.fill(imaps, maps, 1)
|
77
77
|
# args = [self.get_obj(v, conf, src, edata.info) for v in args]
|
78
78
|
# maps = {k:self.get_obj(maps[k], conf, src, edata.info) for k in maps}
|
79
|
+
self.push_vars(conf, ivars)
|
79
80
|
args = [self.get_obj(v, conf, src) for v in args]
|
80
81
|
maps = {k:self.get_obj(maps[k], conf, src) for k in maps}
|
81
|
-
self.push_vars(conf, ivars)
|
82
82
|
rst = method(*args, **maps)
|
83
83
|
self.pop_vars(conf, ivars)
|
84
84
|
return rst
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
2
|
from ..ioc.base import Base, EncapeData,IOCError
|
3
|
+
from ..ioc.single import Single
|
3
4
|
from .base import FormatData,FormatDeal
|
4
5
|
from buildz import xf, pyz
|
5
6
|
import os
|
@@ -59,6 +60,7 @@ class ObjectDeal(FormatDeal):
|
|
59
60
|
"""
|
60
61
|
def init(self, fp_lists = None, fp_defaults = None, fp_cst = None, fp_set = None):
|
61
62
|
self.singles = {}
|
63
|
+
self.single = Single("single", "id", 1)
|
62
64
|
self.sources = {}
|
63
65
|
super().init("ObjectDeal", fp_lists, fp_defaults,
|
64
66
|
join(dp, "conf", "obj_lists.js"),
|
@@ -96,30 +98,17 @@ class ObjectDeal(FormatDeal):
|
|
96
98
|
cid = xf.g(info, id=None)
|
97
99
|
iargs, imaps = xf.g(info, args = None, maps = None)
|
98
100
|
icst = {'args':iargs, 'maps':imaps}
|
101
|
+
if iargs is None and imaps is None:
|
102
|
+
icst = None
|
99
103
|
isets = xf.g(info, sets = None)
|
100
104
|
ivars = xf.g(info, vars=None)
|
101
|
-
|
102
|
-
cid = None
|
105
|
+
ids = self.single.get_ids(edata)
|
103
106
|
id = xf.g(data, id = None)
|
104
|
-
single = xf.g(data, single=None)
|
105
|
-
if id is None:
|
106
|
-
single = 0
|
107
|
-
if single is None:
|
108
|
-
single = 1
|
109
|
-
ids = None
|
110
|
-
if single or cid is not None:
|
111
|
-
if cid is not None:
|
112
|
-
ids = [sid, 'local_id', id, cid]
|
113
|
-
else:
|
114
|
-
if icst is not None or isets is not None:
|
115
|
-
raise Exception("set info.construct/info.sets while using single without info.id")
|
116
|
-
ids = [sid, 'single', id]
|
117
107
|
#print(f"obj.deal ids: {ids} for {data}")
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
return obj
|
108
|
+
obj = self.single.get_by_ids(ids)
|
109
|
+
if obj is not None:
|
110
|
+
#raise IOCError(f"null for {ids}")
|
111
|
+
return obj
|
123
112
|
#source = xf.g(data, source=0)
|
124
113
|
source = xf.g1(data, source=0, src=0)
|
125
114
|
if source == 0:
|
@@ -141,13 +130,16 @@ class ObjectDeal(FormatDeal):
|
|
141
130
|
if icst is not None:
|
142
131
|
xf.fill(icst, cst, 1)
|
143
132
|
args = xf.g(cst, args=[])
|
133
|
+
args = xf.im2l(args)
|
144
134
|
maps = xf.g(cst, maps={})
|
135
|
+
self.push_vars(conf, ivars)
|
145
136
|
args = [self.get_obj(v, conf) for v in args]
|
146
137
|
maps = {k:self.get_obj(maps[k], conf) for k in maps}
|
147
|
-
self.
|
138
|
+
obj = self.single.get_by_ids(ids)
|
139
|
+
if obj is not None:
|
140
|
+
return obj
|
148
141
|
obj = fc(*args, **maps)
|
149
|
-
|
150
|
-
xf.sets(self.singles, ids, obj)
|
142
|
+
self.single.set_by_ids(ids, obj)
|
151
143
|
prev_call = xf.g(data, prev_call=None)
|
152
144
|
if prev_call is not None:
|
153
145
|
# TODO: 这边info透传不知道会不会有问题
|
@@ -187,23 +179,8 @@ class ObjectDeal(FormatDeal):
|
|
187
179
|
info = edata.info
|
188
180
|
conf = edata.conf
|
189
181
|
confs = edata.confs
|
190
|
-
|
191
|
-
|
192
|
-
else:
|
193
|
-
cid = None
|
194
|
-
id = xf.g(data, id = None)
|
195
|
-
single = xf.g(data, single=None)
|
196
|
-
if id is None:
|
197
|
-
single = 0
|
198
|
-
ids = None
|
199
|
-
if single or cid is not None:
|
200
|
-
if single:
|
201
|
-
ids = [sid, id]
|
202
|
-
else:
|
203
|
-
ids = [sid, id, cid]
|
204
|
-
if ids is None:
|
205
|
-
return None
|
206
|
-
obj = xf.gets(self.singles, ids)
|
182
|
+
ids = self.single.get_ids(edata)
|
183
|
+
obj = self.single.get_by_ids(ids)
|
207
184
|
if obj is None:
|
208
185
|
return None
|
209
186
|
call = xf.g(data, remove=None)
|
@@ -34,7 +34,7 @@ class ObjectVarDeal(FormatDeal):
|
|
34
34
|
src = edata.src
|
35
35
|
source = xf.g1(data, source=None, src=None)
|
36
36
|
#key = xf.g(data, key=0)
|
37
|
-
key = xf.get_first(data, "ovar", "key")
|
37
|
+
key = xf.get_first(data, "ovar", "key", "data")
|
38
38
|
info = xf.g(data, info=None)
|
39
39
|
if info is not None:
|
40
40
|
info = self.get_obj(info, src = edata.src, info = edata.info)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#coding=utf-8
|
2
|
-
from ..ioc.base import Base, EncapeData
|
2
|
+
from ..ioc.base import Base, EncapeData, IdNotFoundError
|
3
3
|
from .base import FormatData,FormatDeal
|
4
4
|
from buildz import xf, pyz
|
5
5
|
import os
|
@@ -31,10 +31,20 @@ class RefDeal(FormatDeal):
|
|
31
31
|
if info is not None and type(info)==dict:
|
32
32
|
#info = {k:self.get_obj(info, edata.conf, src = edata.src) for k in info}
|
33
33
|
info = {'type':'map', 'data':info}
|
34
|
-
info = self.get_obj(info, edata.conf, src = edata.src)
|
34
|
+
info = self.get_obj(info, edata.conf, src = edata.src)
|
35
|
+
else:
|
36
|
+
info = {}
|
37
|
+
_info = edata.info
|
38
|
+
if type(_info)==dict:
|
39
|
+
xf.deep_update(info, _info, 1)
|
35
40
|
var, exist = edata.conf.get_var(key)
|
36
41
|
if exist:
|
37
42
|
return var
|
38
|
-
|
43
|
+
try:
|
44
|
+
return edata.conf.get_obj(key, info = info, src = edata.src)
|
45
|
+
except IdNotFoundError as exp:
|
46
|
+
if "default" in data:
|
47
|
+
return data['default']
|
48
|
+
raise exp
|
39
49
|
|
40
50
|
pass
|
@@ -2,6 +2,31 @@
|
|
2
2
|
import sys
|
3
3
|
import os
|
4
4
|
import hashlib
|
5
|
+
import inspect
|
6
|
+
from .base import Base
|
7
|
+
class With:
|
8
|
+
def __init__(self, fc_in, fc_out, args = False):
|
9
|
+
self.fc_in = fc_in
|
10
|
+
self.fc_out = fc_out
|
11
|
+
self.args = args
|
12
|
+
def __enter__(self):
|
13
|
+
if self.fc_in is not None:
|
14
|
+
self.fc_in()
|
15
|
+
return self
|
16
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
17
|
+
rst = False
|
18
|
+
if self.fc_out is not None:
|
19
|
+
if self.args:
|
20
|
+
rst = self.fc_out(exc_type, exc_val, exc_tb)
|
21
|
+
else:
|
22
|
+
rst = self.fc_out()
|
23
|
+
return rst
|
24
|
+
|
25
|
+
pass
|
26
|
+
def with_out(fc, args = False):
|
27
|
+
return With(None, fc, args)
|
28
|
+
|
29
|
+
pass
|
5
30
|
def hashcode(s):
|
6
31
|
if type(s)==str:
|
7
32
|
s = s.encode("utf-8")
|
@@ -10,7 +35,7 @@ def hashcode(s):
|
|
10
35
|
pass
|
11
36
|
def test_current(fp, up = 1, adds = []):
|
12
37
|
"""
|
13
|
-
将当前目录的上{up}层目录加入sys.path
|
38
|
+
将当前目录的上{up}层目录加入sys.path,这样可以在同层写测试代码,但是写import的时候还是要当作是在上{up}层做import
|
14
39
|
"""
|
15
40
|
if type(adds) not in [list, tuple]:
|
16
41
|
adds = [adds]
|
@@ -22,6 +47,8 @@ def test_current(fp, up = 1, adds = []):
|
|
22
47
|
|
23
48
|
pass
|
24
49
|
add_path = test_current
|
50
|
+
add_current = test_current
|
51
|
+
add = test_current
|
25
52
|
def load(md, fc = None):
|
26
53
|
"""
|
27
54
|
import object(whether module or others) from md(or md.fc)
|
@@ -100,3 +127,23 @@ class Pth:
|
|
100
127
|
pass
|
101
128
|
|
102
129
|
_pth = Pth()
|
130
|
+
def main(name, fc, *args, **maps):
|
131
|
+
if name=="__main__":
|
132
|
+
fc(*args, **maps)
|
133
|
+
|
134
|
+
pass
|
135
|
+
|
136
|
+
def bylocals(mlocals, fc, *args, **maps):
|
137
|
+
if mlocals['__name__']=="__main__":
|
138
|
+
fc(*args, **maps)
|
139
|
+
|
140
|
+
pass
|
141
|
+
|
142
|
+
def mainerr(fc, *args, **maps):
|
143
|
+
st = inspect.stack()[1]
|
144
|
+
if st.filename == '<stdin>':
|
145
|
+
fc(*args, **maps)
|
146
|
+
else:
|
147
|
+
print("not main:", st.filename)
|
148
|
+
|
149
|
+
pass
|