buildz 0.4.91__tar.gz → 0.5.2__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.4.91/buildz.egg-info → buildz-0.5.2}/PKG-INFO +1 -1
- buildz-0.5.2/buildz/ioc/base.py +4 -0
- buildz-0.5.2/buildz/ioc/ioc/base.py +65 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc/conf.py +40 -16
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc/confs.py +35 -11
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/base.py +32 -8
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/call.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/calls.py +2 -2
- buildz-0.5.2/buildz/ioc/ioc_deal/conf/deal_lists.js +22 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/deals.js +13 -1
- buildz-0.5.2/buildz/ioc/ioc_deal/conf/xfile_defaults.js +2 -0
- buildz-0.5.2/buildz/ioc/ioc_deal/conf/xfile_lists.js +22 -0
- buildz-0.5.2/buildz/ioc/ioc_deal/deal.py +86 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/env.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/ioc.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/join.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/list.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/map.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/mcall.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/obj.py +21 -5
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/ovar.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/ref.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/var.py +2 -2
- buildz-0.5.2/buildz/ioc/ioc_deal/xfile.py +41 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/pyz.py +1 -1
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/__init__.py +2 -2
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/file.py +7 -1
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/spc.py +0 -4
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/mg.py +7 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/test.py +6 -5
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/mapz.py +1 -1
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/readz.py +16 -7
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/write.py +8 -1
- {buildz-0.4.91 → buildz-0.5.2/buildz.egg-info}/PKG-INFO +1 -1
- {buildz-0.4.91 → buildz-0.5.2}/buildz.egg-info/SOURCES.txt +6 -0
- {buildz-0.4.91 → buildz-0.5.2}/setup.py +1 -1
- buildz-0.4.91/buildz/ioc/ioc/base.py +0 -35
- {buildz-0.4.91 → buildz-0.5.2}/LICENSE +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/MANIFEST.in +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/README.md +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/__init__.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/__main__.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/argx.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/ioc/deal.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/ioc/help.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/myers/deal.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/myers/help.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/conf/ioc.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/conf/main.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/conf/myers.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/conf/search.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/conf/xf.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/help/default.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/help/ioc.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/help/myers.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/help/search.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/help/xf.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/res/test.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/search/deal.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/search/help.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/test.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/xf/deal.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/demo/xf/help.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/fz/__init__.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/fz/dirz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/fz/fio.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/fz/lsf.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/__init__.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/init.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/ref_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/demo.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/ioc/ioc_deal/val.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/tz/__init__.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/tz/myers_diff.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/__main__.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/base.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/buffer.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/listz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/lr.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/lrval.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/mapz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/nextz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/reval.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/setz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/spc.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/spt.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/deal/strz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/exp.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/item.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/mg.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loader/pos.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/base.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/buffer.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/listz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/lr.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/lrval.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/mapz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/nextz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/reval.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/setz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/spt.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/deal/strz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/exp.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/item.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/loaderz/pos.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/read.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/stack.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/writer/base.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/writer/conf.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/writer/deal/jsonval.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/writer/deal/listz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/writer/deal/mapz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/writer/deal/reval.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/writer/deal/strz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/writer/itemz.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/writer/mg.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz/xf/xargs.py +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz.egg-info/dependency_links.txt +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/buildz.egg-info/top_level.txt +0 -0
- {buildz-0.4.91 → buildz-0.5.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: buildz
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.5.2
|
4
4
|
Summary: 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
|
5
5
|
Home-page: https://github.com/buildCodeZ/buildz
|
6
6
|
Author: Zzz
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
from buildz import xf, pyz
|
3
|
+
from buildz.xf import g as xg
|
4
|
+
import json
|
5
|
+
import builtins
|
6
|
+
typez = builtins.type
|
7
|
+
class IOCError(Exception):
|
8
|
+
def __init__(self, msg):
|
9
|
+
super().__init__(msg)
|
10
|
+
|
11
|
+
pass
|
12
|
+
class Base:
|
13
|
+
def update_maps(self, maps, src, replace=1):
|
14
|
+
xf.deep_update(maps, src, replace)
|
15
|
+
def __init__(self, *args, **maps):
|
16
|
+
self.init(*args, **maps)
|
17
|
+
def init(self, *args, **maps):
|
18
|
+
pass
|
19
|
+
def __call__(self, *args, **maps):
|
20
|
+
return self.deal(*args, **maps)
|
21
|
+
def deal(self, *args, **maps):
|
22
|
+
return None
|
23
|
+
|
24
|
+
pass
|
25
|
+
class EncapeData(Base):
|
26
|
+
"""
|
27
|
+
包含data id对应的配置,配置文件id,配置文件对象
|
28
|
+
[object.test, call, ]
|
29
|
+
"""
|
30
|
+
def __init__(self, data, conf, local = False, type = None, src = None, info = None):
|
31
|
+
"""
|
32
|
+
data: 配置数据
|
33
|
+
conf: 配置数据对应的配置文件的管理器
|
34
|
+
local: 是否是locals的数据(配置文件局部数据)
|
35
|
+
type: 配置数据的type字段
|
36
|
+
src: 源对象,配置数据生成的对象调用conf获取对象,会有这个字段,目前只有object会放这个字段,其他要么透传要么不传
|
37
|
+
info: 额外的调用信息,目前只有object会用到里面的id字段,作为单例额外输入
|
38
|
+
"""
|
39
|
+
if typez(data)==dict:
|
40
|
+
pid = xf.g(data, parent=None)
|
41
|
+
if pid is not None:
|
42
|
+
pedt = conf.get_data(pid, local=True, search_confs = True,src = src, info = info)
|
43
|
+
if pedt is None:
|
44
|
+
raise IOCError("unfind parend: "+pid)
|
45
|
+
pdt = pedt.data
|
46
|
+
if typez(pdt)!=dict:
|
47
|
+
raise IOCError("only dict can be a parent: "+pid)
|
48
|
+
data = dict(data)
|
49
|
+
self.update_maps(data, pdt, replace=0)
|
50
|
+
del data['parent']
|
51
|
+
self.data = data
|
52
|
+
self.sid = conf.id
|
53
|
+
self.src = src
|
54
|
+
self.conf = conf
|
55
|
+
self.confs = conf.confs
|
56
|
+
self.local = local
|
57
|
+
if type is None:
|
58
|
+
type = conf.confs.get_data_type(data, 0, conf.default_type())
|
59
|
+
self.type = type
|
60
|
+
self.info = info
|
61
|
+
def deal(self, remove = False):
|
62
|
+
return self.conf.get(self, src = self.src, info=self.info, remove = remove)
|
63
|
+
|
64
|
+
|
65
|
+
pass
|
@@ -2,7 +2,8 @@
|
|
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
|
5
|
+
from .base import Base, EncapeData,IOCError
|
6
|
+
from builtins import id as _id
|
6
7
|
class Conf(Base):
|
7
8
|
"""
|
8
9
|
配置文件格式:
|
@@ -33,6 +34,12 @@ class Conf(Base):
|
|
33
34
|
item_conf,
|
34
35
|
...
|
35
36
|
]
|
37
|
+
// 初始化,会一个一个get(id)
|
38
|
+
// 其他地方调用该conf.get的时候,会先判断有没有进行init,没有就先调init里的get
|
39
|
+
inits: [
|
40
|
+
id,
|
41
|
+
...
|
42
|
+
]
|
36
43
|
}
|
37
44
|
如果只有全局数据配置项,可以只写datas里的东西:
|
38
45
|
[
|
@@ -63,7 +70,7 @@ class Conf(Base):
|
|
63
70
|
}
|
64
71
|
"""
|
65
72
|
if type(conf)!=dict:
|
66
|
-
conf = {'
|
73
|
+
conf = {'datas':conf}
|
67
74
|
id = xf.g(conf, id=None)
|
68
75
|
if id is None:
|
69
76
|
id = confs.conf_id()
|
@@ -74,9 +81,11 @@ class Conf(Base):
|
|
74
81
|
self.locals = self.map(xf.g(conf, locals=[]), self.confs.get_data_id)
|
75
82
|
self.datas = self.map(xf.g(conf, datas=[]), self.confs.get_data_id)
|
76
83
|
self.deals = self.map(xf.g(conf, deals = []), self.confs.get_deal_type)
|
84
|
+
self.inits = xf.g(conf, inits = [])
|
77
85
|
self._default_type = xf.g(conf, default_type = None)
|
78
86
|
self.envs = xf.g(conf, envs = {})
|
79
87
|
self.confs.flush_env(self.envs)
|
88
|
+
self.confs.update_env(self.envs)
|
80
89
|
for _type in list(self.deals.keys()):
|
81
90
|
conf = self.deals[_type]
|
82
91
|
if type(conf) in [list, tuple]:
|
@@ -97,25 +106,25 @@ class Conf(Base):
|
|
97
106
|
aliases = xf.g(conf, aliases = [])
|
98
107
|
for alias in aliases:
|
99
108
|
self.deals[alias] = deal
|
109
|
+
self.mark_init = False
|
110
|
+
def do_init(self):
|
111
|
+
if self.mark_init:
|
112
|
+
return
|
113
|
+
self.mark_init = True
|
114
|
+
for id in self.inits:
|
115
|
+
self.get(id)
|
100
116
|
def get_env(self, id, search_confs = True):
|
101
117
|
if self.confs.global_env and search_confs:
|
102
118
|
return self.confs.get_env(id, self.id)
|
103
|
-
|
104
|
-
envs = self.envs
|
105
|
-
find = None
|
106
|
-
for id in ids:
|
107
|
-
if type(envs)!=dict:
|
108
|
-
envs = None
|
109
|
-
break
|
110
|
-
if id not in envs:
|
111
|
-
envs = None
|
112
|
-
break
|
113
|
-
envs = envs[id]
|
119
|
+
envs = self.confs.get_env_maps(id, self.envs)
|
114
120
|
if envs is not None:
|
115
121
|
return envs
|
116
122
|
if not search_confs:
|
117
123
|
return None
|
118
124
|
return self.confs.get_env(id, self.id)
|
125
|
+
def set_deal(self, type, fc):
|
126
|
+
self.deals[type] = fc
|
127
|
+
self.confs.set_deal(type, fc)
|
119
128
|
def get_deal(self, type, search_confs = True):
|
120
129
|
if self.confs.global_deal and search_confs:
|
121
130
|
return self.confs.get_deal(type, self.id)
|
@@ -125,14 +134,23 @@ class Conf(Base):
|
|
125
134
|
return None
|
126
135
|
return self.confs.get_deal(type, self.id)
|
127
136
|
def get_data(self, id, local = True, search_confs = True, src = None, info = None):
|
137
|
+
self.do_init()
|
128
138
|
if id in self.datas:
|
129
139
|
obj = self.datas[id]
|
130
|
-
|
140
|
+
edata = EncapeData(obj, self, local = False, src=src, info = info)
|
141
|
+
if _id(obj) != _id(edata.data):
|
142
|
+
# 有parent,做了填充,用填充后的替换
|
143
|
+
self.datas[id] = edata.data
|
144
|
+
return edata
|
131
145
|
if not local:
|
132
146
|
return None
|
133
147
|
if id in self.locals:
|
134
148
|
obj = self.locals[id]
|
135
|
-
|
149
|
+
edata = EncapeData(obj, self, local = True, src=src, info = info)
|
150
|
+
if _id(obj) != _id(edata.data):
|
151
|
+
# 有parent,做了填充,用填充后的替换
|
152
|
+
self.locals[id] = edata.data
|
153
|
+
return edata
|
136
154
|
if not search_confs:
|
137
155
|
return None
|
138
156
|
return self.confs.get_data(id, self.id, src=src, info = info)
|
@@ -146,11 +164,17 @@ class Conf(Base):
|
|
146
164
|
"""
|
147
165
|
根据data id获取data对象,处理逻辑:根据data id查配置,根据配置的type查deal,返回deal处理过的配置
|
148
166
|
"""
|
149
|
-
|
167
|
+
self.do_init()
|
168
|
+
if type(id) == EncapeData:
|
169
|
+
conf = id
|
170
|
+
else:
|
171
|
+
conf = self.get_data(id, src = src, info = info)
|
150
172
|
if conf is None:
|
173
|
+
raise IOCError(f"can't find conf of {id}")
|
151
174
|
return None
|
152
175
|
deal = self.get_deal(conf.type)
|
153
176
|
if deal is None:
|
177
|
+
raise IOCError(f"can't find deal of {id}, type = {conf.type}")
|
154
178
|
return None
|
155
179
|
if not remove:
|
156
180
|
obj = deal(conf)
|
@@ -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
|
6
|
+
from .base import Base, EncapeData,IOCError
|
7
7
|
from .conf import Conf
|
8
8
|
import os
|
9
9
|
class ConfsNode(Base):
|
@@ -55,6 +55,7 @@ class Confs(Base):
|
|
55
55
|
data = xf.args()
|
56
56
|
env = data['env']
|
57
57
|
self.envs_args = env
|
58
|
+
self.flush_env(self.envs_args)
|
58
59
|
def build_env_args_buildz(self):
|
59
60
|
args, maps = argx.fetch()
|
60
61
|
e = xf.get(maps, e = [])
|
@@ -63,22 +64,25 @@ class Confs(Base):
|
|
63
64
|
env = [k.split("=") for k in env]
|
64
65
|
env = {k[0]:"=".join(k[1:]) for k in env}
|
65
66
|
self.envs_args = env
|
67
|
+
self.flush_env(self.envs_args)
|
68
|
+
def build_env_args(self):
|
69
|
+
if self.args_type == "xf":
|
70
|
+
self.build_env_args_xf()
|
71
|
+
else:
|
72
|
+
self.build_env_args_buildz()
|
66
73
|
def get_env_args(self, id, sid=None):
|
67
|
-
if self.envs_args is
|
68
|
-
|
69
|
-
|
70
|
-
else:
|
71
|
-
self.build_env_args_buildz()
|
72
|
-
return xf.get(self.envs_args, id)
|
74
|
+
if self.envs_args is None:
|
75
|
+
self.build_env_args()
|
76
|
+
return self.get_env_maps(id, self.envs_args)
|
73
77
|
def get_env_local(self, id, sid=None):
|
74
78
|
if sid is not None and not self.global_env:
|
75
79
|
val = self.confs[sid].get_env(id, False)
|
76
80
|
if val is not None:
|
77
81
|
return val
|
78
82
|
return None
|
79
|
-
def
|
83
|
+
def get_env_maps(self, id, maps):
|
80
84
|
ids = self.env_ids(id)
|
81
|
-
envs =
|
85
|
+
envs = maps
|
82
86
|
for id in ids:
|
83
87
|
if type(envs)!=dict:
|
84
88
|
envs = None
|
@@ -88,6 +92,8 @@ class Confs(Base):
|
|
88
92
|
break
|
89
93
|
envs = envs[id]
|
90
94
|
return envs
|
95
|
+
def get_env_conf(self, id, sid=None):
|
96
|
+
return self.get_env_maps(id, self.envs)
|
91
97
|
def get_env(self, id, sid=None):
|
92
98
|
for key in self.env_orders:
|
93
99
|
fc = self.env_fcs[key]
|
@@ -117,6 +123,8 @@ class Confs(Base):
|
|
117
123
|
obj = {id:val}
|
118
124
|
self.flush_env(obj)
|
119
125
|
self.update_maps(self.envs, obj)
|
126
|
+
def update_env(self, obj):
|
127
|
+
self.update_maps(self.envs, obj)
|
120
128
|
def set_deal(self, type, fc):
|
121
129
|
self.deals[type] = fc
|
122
130
|
def init_fp(self, fp):
|
@@ -205,7 +213,7 @@ class Confs(Base):
|
|
205
213
|
self.data_index_type = xf.g(conf, data_index_type = [0,1])
|
206
214
|
self.deal_key_type = xf.g(conf, deal_key_type = 'type')
|
207
215
|
self.deal_index_type = xf.g(conf, deal_index_type = 0)
|
208
|
-
self.env_orders = xf.g(conf, env_orders = ['
|
216
|
+
self.env_orders = xf.g(conf, env_orders = ['sys', 'local', 'conf'])
|
209
217
|
self.env_fcs = {
|
210
218
|
'args': self.get_env_args,
|
211
219
|
'sys': self.get_env_sys,
|
@@ -220,6 +228,15 @@ class Confs(Base):
|
|
220
228
|
self.deals = {}
|
221
229
|
self.envs = {}
|
222
230
|
self.envs_args = None
|
231
|
+
self.mark_init = False
|
232
|
+
if 'args' in self.env_orders:
|
233
|
+
self.build_env_args()
|
234
|
+
def do_init(self):
|
235
|
+
if self.mark_init:
|
236
|
+
return
|
237
|
+
self.mark_init = True
|
238
|
+
for id in self.confs:
|
239
|
+
self.confs[id].do_init()
|
223
240
|
def get_deal_type(self, obj):
|
224
241
|
if type(obj)==dict:
|
225
242
|
return obj[self.deal_key_type]
|
@@ -232,6 +249,7 @@ class Confs(Base):
|
|
232
249
|
obj = obj[self.data_index_id[1]]
|
233
250
|
return obj
|
234
251
|
def get_data_type(self, obj, type_first = 1, default = None):
|
252
|
+
self.do_init()
|
235
253
|
if type(obj)==dict:
|
236
254
|
if self.data_key_type not in obj:
|
237
255
|
return default
|
@@ -306,11 +324,17 @@ class Confs(Base):
|
|
306
324
|
"""
|
307
325
|
根据data id获取data对象,处理逻辑:根据data id查配置,根据配置的type查deal,返回deal处理过的配置
|
308
326
|
"""
|
309
|
-
|
327
|
+
self.do_init()
|
328
|
+
if type(id) == EncapeData:
|
329
|
+
conf = id
|
330
|
+
else:
|
331
|
+
conf = self.get_data(id, sid, src=src, info = info)
|
310
332
|
if conf is None:
|
333
|
+
raise IOCError(f"confs: can't find conf of {id}")
|
311
334
|
return None
|
312
335
|
deal = self.get_deal(conf.type, sid)
|
313
336
|
if deal is None:
|
337
|
+
raise IOCError(f"confs: can't find deal of {id}, type = {conf.type}")
|
314
338
|
return None
|
315
339
|
#print(f"get_obj: {id}({sid}), conf: {conf}, deal: {deal}, type: {conf.type}")
|
316
340
|
if not remove:
|
@@ -117,11 +117,38 @@ class FormatData(Base):
|
|
117
117
|
|
118
118
|
pass
|
119
119
|
|
120
|
-
|
121
120
|
class BaseDeal(Base):
|
122
|
-
|
123
|
-
|
124
|
-
self
|
121
|
+
"""
|
122
|
+
基础处理类,加了一些方便处理的方法,自己写的处理可以不用继承这个
|
123
|
+
自己实现的处理类,要实现两个方法:__call__(self, edata:EncapeData)和remove(self, edata:EncapeData)
|
124
|
+
其中remove可以只写个空方法
|
125
|
+
"""
|
126
|
+
def get_obj(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()
|
135
|
+
deal = conf.get_deal(edata.type)
|
136
|
+
if deal is None:
|
137
|
+
return None
|
138
|
+
return deal(edata)
|
139
|
+
def deal(self, edata:EncapeData):
|
140
|
+
"""
|
141
|
+
"""
|
142
|
+
return None
|
143
|
+
def remove(self, edata:EncapeData):
|
144
|
+
return None
|
145
|
+
|
146
|
+
pass
|
147
|
+
class FormatDeal(BaseDeal):
|
148
|
+
"""
|
149
|
+
格式化处理类,加了自动装填,但感觉不太好用(一方面忘记写注释,写的时间久了,不知道要怎么用了,另一方面不好扩展,再一方面自动填充要消耗时间))
|
150
|
+
"""
|
151
|
+
def init(self, name = "FormatDeal", fp_lists = None, fp_defaults = None, df_fp_lists=None, df_fp_defaults=None):
|
125
152
|
if fp_lists is None:
|
126
153
|
fp_lists = df_fp_lists
|
127
154
|
if fp_defaults is None:
|
@@ -145,13 +172,10 @@ class BaseDeal(Base):
|
|
145
172
|
data.reverse()
|
146
173
|
_type = conf.confs.get_data_type(data, 1, conf.default_type())
|
147
174
|
edata = EncapeData(data, conf, local=True, type=_type, src = src, info = info)
|
175
|
+
return edata()
|
148
176
|
deal = conf.get_deal(edata.type)
|
149
177
|
if deal is None:
|
150
178
|
return None
|
151
179
|
return deal(edata)
|
152
|
-
def deal(self, edata:EncapeData):
|
153
|
-
return None
|
154
|
-
def remove(self, edata:EncapeData):
|
155
|
-
return None
|
156
180
|
|
157
181
|
pass
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#
|
2
2
|
from ..ioc.base import Base, EncapeData
|
3
|
-
from .base import FormatData,
|
3
|
+
from .base import FormatData,FormatDeal
|
4
4
|
from buildz import xf, pyz
|
5
5
|
import os
|
6
6
|
dp = os.path.dirname(__file__)
|
7
7
|
join = os.path.join
|
8
|
-
class CallDeal(
|
8
|
+
class CallDeal(FormatDeal):
|
9
9
|
"""
|
10
10
|
函数调用call:
|
11
11
|
{
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#
|
2
2
|
from ..ioc.base import Base, EncapeData
|
3
|
-
from .base import FormatData,
|
3
|
+
from .base import FormatData,FormatDeal
|
4
4
|
from buildz import xf, pyz
|
5
5
|
import os
|
6
6
|
dp = os.path.dirname(__file__)
|
7
7
|
join = os.path.join
|
8
|
-
class CallsDeal(
|
8
|
+
class CallsDeal(FormatDeal):
|
9
9
|
"""
|
10
10
|
函数调用序列calls:
|
11
11
|
{
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// [[id, type, single], source, construct=[args, maps], sets=[]]
|
2
|
+
[
|
3
|
+
{
|
4
|
+
nullable: 0,
|
5
|
+
out: 1,
|
6
|
+
conf: {
|
7
|
+
sort: -1,
|
8
|
+
data:[
|
9
|
+
{key: id, default: null},
|
10
|
+
{key: type, default: null}
|
11
|
+
]
|
12
|
+
}
|
13
|
+
},
|
14
|
+
{
|
15
|
+
nullable: 0,
|
16
|
+
key: target
|
17
|
+
},
|
18
|
+
{
|
19
|
+
nullable: 0,
|
20
|
+
key: source
|
21
|
+
}
|
22
|
+
]
|
@@ -9,7 +9,8 @@
|
|
9
9
|
{
|
10
10
|
type: object,
|
11
11
|
note: 对象,
|
12
|
-
build: buildz.ioc.ioc_deal.obj.ObjectDeal
|
12
|
+
build: buildz.ioc.ioc_deal.obj.ObjectDeal,
|
13
|
+
aliases: [obj]
|
13
14
|
},
|
14
15
|
{
|
15
16
|
type: env,
|
@@ -65,6 +66,17 @@
|
|
65
66
|
type: join,
|
66
67
|
note: 文件路径拼接,
|
67
68
|
build: buildz.ioc.ioc_deal.join.JoinDeal
|
69
|
+
},
|
70
|
+
{
|
71
|
+
type: xfile,
|
72
|
+
note: xf配置文件读取,
|
73
|
+
build: buildz.ioc.ioc_deal.xfile.XfileDeal,
|
74
|
+
aliases: [xf]
|
75
|
+
},
|
76
|
+
{
|
77
|
+
type: deal,
|
78
|
+
note: 扩展的自定义deal方法,
|
79
|
+
build: buildz.ioc.ioc_deal.deal.DealDeal
|
68
80
|
}
|
69
81
|
]
|
70
82
|
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// [[id, type, single], source, construct=[args, maps], sets=[]]
|
2
|
+
[
|
3
|
+
{
|
4
|
+
nullable: 0,
|
5
|
+
out: 1,
|
6
|
+
conf: {
|
7
|
+
sort: -1,
|
8
|
+
data:[
|
9
|
+
{key: id, default: null},
|
10
|
+
{key: type, default: null}
|
11
|
+
]
|
12
|
+
}
|
13
|
+
},
|
14
|
+
{
|
15
|
+
nullable: 1,
|
16
|
+
key: filepath
|
17
|
+
},
|
18
|
+
{
|
19
|
+
nullable: 1,
|
20
|
+
key: fp
|
21
|
+
}
|
22
|
+
]
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
from ..ioc.base import Base, EncapeData,IOCError
|
3
|
+
from .base import FormatData,FormatDeal
|
4
|
+
from buildz import xf, pyz
|
5
|
+
import os
|
6
|
+
dp = os.path.dirname(__file__)
|
7
|
+
join = os.path.join
|
8
|
+
class DealDeal(FormatDeal):
|
9
|
+
"""
|
10
|
+
扩展的好处是自定义格式,除了id,type和parent字段,其他字段可以自己加
|
11
|
+
假设生成个test.Demo,构造函数只有一个字段val
|
12
|
+
{
|
13
|
+
id: test
|
14
|
+
type: object
|
15
|
+
source: test.Demo
|
16
|
+
construct: {
|
17
|
+
args: [
|
18
|
+
(val, 'demo')
|
19
|
+
]
|
20
|
+
}
|
21
|
+
}
|
22
|
+
自己写个生成特定对象的处理类:
|
23
|
+
配置文件1 def_demo.js:
|
24
|
+
{
|
25
|
+
datas:[
|
26
|
+
{
|
27
|
+
id: obj.demo.deal
|
28
|
+
type: object
|
29
|
+
source: test.BuildDemo
|
30
|
+
}
|
31
|
+
{
|
32
|
+
id: demo.deal
|
33
|
+
type: deal
|
34
|
+
source: obj.demo.deal
|
35
|
+
target: demo.deal
|
36
|
+
}
|
37
|
+
]
|
38
|
+
//inits初始化
|
39
|
+
inits: [
|
40
|
+
demo.deal
|
41
|
+
]
|
42
|
+
}
|
43
|
+
配置文件2 demo.js:
|
44
|
+
//只有datas的时候可以简写成只写datas列表里的数据
|
45
|
+
[
|
46
|
+
{
|
47
|
+
id: test
|
48
|
+
type: demo.deal
|
49
|
+
val: "demo"
|
50
|
+
}
|
51
|
+
]
|
52
|
+
调用后会注册到conf的deal上,用于扩展deals配置
|
53
|
+
deal字段deal:
|
54
|
+
{
|
55
|
+
id:id
|
56
|
+
type: deal
|
57
|
+
target: type
|
58
|
+
source: id # 要求source实现了方法__call__(self, edata:EncapeData)
|
59
|
+
}
|
60
|
+
简写:
|
61
|
+
[[id, deal], target, source]
|
62
|
+
[deal, target, source]
|
63
|
+
例:
|
64
|
+
[deal, target, source] //
|
65
|
+
"""
|
66
|
+
def init(self, fp_lists=None, fp_defaults=None):
|
67
|
+
super().init("DealDeal", fp_lists, fp_defaults, join(dp, "conf", "deal_lists.js"), None)
|
68
|
+
def deal(self, edata:EncapeData):
|
69
|
+
data = edata.data
|
70
|
+
source = xf.g(data, source=None)
|
71
|
+
if source is None:
|
72
|
+
raise IOCError("not source in dealdeal")
|
73
|
+
target = xf.g(data, target=None)
|
74
|
+
if target is None:
|
75
|
+
raise IOCError("not target in dealdeal")
|
76
|
+
obj = edata.conf.get(source)
|
77
|
+
if obj is None:
|
78
|
+
raise IOCError("source object not found in dealdeal")
|
79
|
+
targets = target
|
80
|
+
if type(targets) != list:
|
81
|
+
targets = [targets]
|
82
|
+
for target in targets:
|
83
|
+
edata.conf.set_deal(target, obj)
|
84
|
+
return None
|
85
|
+
|
86
|
+
pass
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#
|
2
2
|
from ..ioc.base import Base, EncapeData
|
3
|
-
from .base import FormatData,
|
3
|
+
from .base import FormatData,FormatDeal
|
4
4
|
from buildz import xf, pyz
|
5
5
|
import os
|
6
6
|
dp = os.path.dirname(__file__)
|
7
7
|
join = os.path.join
|
8
|
-
class EnvDeal(
|
8
|
+
class EnvDeal(FormatDeal):
|
9
9
|
"""
|
10
10
|
环境变量env:
|
11
11
|
{
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#coding=utf-8
|
2
2
|
from ..ioc.base import Base, EncapeData
|
3
|
-
from .base import FormatData,
|
3
|
+
from .base import FormatData,FormatDeal
|
4
4
|
from buildz import xf, pyz
|
5
5
|
import os
|
6
6
|
dp = os.path.dirname(__file__)
|
7
7
|
join = os.path.join
|
8
|
-
class IOCObjectDeal(
|
8
|
+
class IOCObjectDeal(FormatDeal):
|
9
9
|
"""
|
10
10
|
ioc字段ioc:
|
11
11
|
{
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#coding=utf-8
|
2
2
|
from ..ioc.base import Base, EncapeData
|
3
|
-
from .base import FormatData,
|
3
|
+
from .base import FormatData,FormatDeal
|
4
4
|
from buildz import xf, pyz
|
5
5
|
import os
|
6
6
|
dp = os.path.dirname(__file__)
|
7
7
|
join = os.path.join
|
8
|
-
class JoinDeal(
|
8
|
+
class JoinDeal(FormatDeal):
|
9
9
|
"""
|
10
10
|
文件路径合并join:
|
11
11
|
{
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#coding=utf-8
|
2
2
|
from ..ioc.base import Base, EncapeData
|
3
|
-
from .base import FormatData,
|
3
|
+
from .base import FormatData,FormatDeal
|
4
4
|
from buildz import xf, pyz
|
5
5
|
import os
|
6
6
|
dp = os.path.dirname(__file__)
|
7
7
|
join = os.path.join
|
8
|
-
class ListDeal(
|
8
|
+
class ListDeal(FormatDeal):
|
9
9
|
"""
|
10
10
|
list:
|
11
11
|
{
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#coding=utf-8
|
2
2
|
from ..ioc.base import Base, EncapeData
|
3
|
-
from .base import FormatData,
|
3
|
+
from .base import FormatData,FormatDeal
|
4
4
|
from buildz import xf, pyz
|
5
5
|
import os
|
6
6
|
dp = os.path.dirname(__file__)
|
7
7
|
join = os.path.join
|
8
|
-
class MapDeal(
|
8
|
+
class MapDeal(FormatDeal):
|
9
9
|
"""
|
10
10
|
map:
|
11
11
|
{
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#
|
2
2
|
from ..ioc.base import Base, EncapeData
|
3
|
-
from .base import FormatData,
|
3
|
+
from .base import FormatData,FormatDeal
|
4
4
|
from buildz import xf, pyz
|
5
5
|
import os
|
6
6
|
dp = os.path.dirname(__file__)
|
7
7
|
join = os.path.join
|
8
|
-
class MethodCallDeal(
|
8
|
+
class MethodCallDeal(FormatDeal):
|
9
9
|
"""
|
10
10
|
对象方法调用:
|
11
11
|
{
|