buildz 0.4.9__tar.gz → 0.5.1__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.
Files changed (136) hide show
  1. {buildz-0.4.9/buildz.egg-info → buildz-0.5.1}/PKG-INFO +5 -1
  2. {buildz-0.4.9 → buildz-0.5.1}/README.md +4 -0
  3. {buildz-0.4.9 → buildz-0.5.1}/buildz/__init__.py +2 -1
  4. {buildz-0.4.9 → buildz-0.5.1}/buildz/argx.py +36 -0
  5. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/test.js +1 -0
  6. buildz-0.5.1/buildz/ioc/ioc/base.py +61 -0
  7. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc/conf.py +22 -2
  8. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc/confs.py +11 -1
  9. buildz-0.5.1/buildz/ioc/ioc_deal/conf/deal_lists.js +22 -0
  10. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/deals.js +13 -1
  11. buildz-0.5.1/buildz/ioc/ioc_deal/conf/xfile_defaults.js +2 -0
  12. buildz-0.5.1/buildz/ioc/ioc_deal/conf/xfile_lists.js +22 -0
  13. buildz-0.5.1/buildz/ioc/ioc_deal/deal.py +40 -0
  14. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/obj.py +19 -3
  15. buildz-0.5.1/buildz/ioc/ioc_deal/xfile.py +41 -0
  16. {buildz-0.4.9 → buildz-0.5.1}/buildz/pyz.py +1 -1
  17. {buildz-0.4.9 → buildz-0.5.1}/buildz/tz/__init__.py +2 -1
  18. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/__init__.py +1 -1
  19. buildz-0.5.1/buildz/xf/__main__.py +6 -0
  20. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/base.py +4 -0
  21. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/buffer.py +35 -0
  22. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/lr.py +1 -0
  23. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/reval.py +4 -0
  24. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/spc.py +5 -0
  25. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/strz.py +5 -0
  26. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/mg.py +27 -5
  27. buildz-0.5.1/buildz/xf/loaderz/base.py +34 -0
  28. buildz-0.5.1/buildz/xf/loaderz/buffer.py +101 -0
  29. buildz-0.5.1/buildz/xf/loaderz/deal/listz.py +19 -0
  30. buildz-0.5.1/buildz/xf/loaderz/deal/lr.py +58 -0
  31. buildz-0.5.1/buildz/xf/loaderz/deal/lrval.py +40 -0
  32. buildz-0.5.1/buildz/xf/loaderz/deal/mapz.py +24 -0
  33. buildz-0.5.1/buildz/xf/loaderz/deal/nextz.py +21 -0
  34. buildz-0.5.1/buildz/xf/loaderz/deal/reval.py +30 -0
  35. buildz-0.5.1/buildz/xf/loaderz/deal/setz.py +15 -0
  36. buildz-0.5.1/buildz/xf/loaderz/deal/spc.py +24 -0
  37. buildz-0.5.1/buildz/xf/loaderz/deal/spt.py +38 -0
  38. buildz-0.5.1/buildz/xf/loaderz/deal/strz.py +96 -0
  39. buildz-0.5.1/buildz/xf/loaderz/exp.py +12 -0
  40. buildz-0.5.1/buildz/xf/loaderz/item.py +68 -0
  41. buildz-0.5.1/buildz/xf/loaderz/mg.py +96 -0
  42. buildz-0.5.1/buildz/xf/loaderz/pos.py +51 -0
  43. buildz-0.5.1/buildz/xf/loaderz/test.py +77 -0
  44. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/mapz.py +6 -1
  45. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/read.py +1 -1
  46. buildz-0.5.1/buildz/xf/readz.py +82 -0
  47. buildz-0.5.1/buildz/xf/stack.py +68 -0
  48. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/xargs.py +5 -2
  49. {buildz-0.4.9 → buildz-0.5.1/buildz.egg-info}/PKG-INFO +5 -1
  50. {buildz-0.4.9 → buildz-0.5.1}/buildz.egg-info/SOURCES.txt +25 -0
  51. {buildz-0.4.9 → buildz-0.5.1}/setup.py +1 -1
  52. buildz-0.4.9/buildz/ioc/ioc/base.py +0 -35
  53. {buildz-0.4.9 → buildz-0.5.1}/LICENSE +0 -0
  54. {buildz-0.4.9 → buildz-0.5.1}/MANIFEST.in +0 -0
  55. {buildz-0.4.9 → buildz-0.5.1}/buildz/__main__.py +0 -0
  56. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/ioc/deal.py +0 -0
  57. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/ioc/help.py +0 -0
  58. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/myers/deal.py +0 -0
  59. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/myers/help.py +0 -0
  60. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/conf/ioc.js +0 -0
  61. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/conf/main.js +0 -0
  62. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/conf/myers.js +0 -0
  63. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/conf/search.js +0 -0
  64. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/conf/xf.js +0 -0
  65. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/help/default.js +0 -0
  66. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/help/ioc.js +0 -0
  67. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/help/myers.js +0 -0
  68. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/help/search.js +0 -0
  69. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/res/help/xf.js +0 -0
  70. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/search/deal.py +0 -0
  71. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/search/help.py +0 -0
  72. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/test.py +0 -0
  73. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/xf/deal.py +0 -0
  74. {buildz-0.4.9 → buildz-0.5.1}/buildz/demo/xf/help.py +0 -0
  75. {buildz-0.4.9 → buildz-0.5.1}/buildz/fz/__init__.py +0 -0
  76. {buildz-0.4.9 → buildz-0.5.1}/buildz/fz/dirz.py +0 -0
  77. {buildz-0.4.9 → buildz-0.5.1}/buildz/fz/fio.py +0 -0
  78. {buildz-0.4.9 → buildz-0.5.1}/buildz/fz/lsf.py +0 -0
  79. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/__init__.py +0 -0
  80. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/init.py +0 -0
  81. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/base.py +0 -0
  82. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/call.py +0 -0
  83. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/calls.py +0 -0
  84. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
  85. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
  86. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
  87. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
  88. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
  89. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
  90. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
  91. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
  92. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
  93. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
  94. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
  95. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
  96. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
  97. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
  98. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
  99. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
  100. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/ref_lists.js +0 -0
  101. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
  102. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/demo.py +0 -0
  103. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/env.py +0 -0
  104. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/ioc.py +0 -0
  105. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/join.py +0 -0
  106. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/list.py +0 -0
  107. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/map.py +0 -0
  108. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/mcall.py +0 -0
  109. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/ovar.py +0 -0
  110. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/ref.py +0 -0
  111. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/val.py +0 -0
  112. {buildz-0.4.9 → buildz-0.5.1}/buildz/ioc/ioc_deal/var.py +0 -0
  113. {buildz-0.4.9 → buildz-0.5.1}/buildz/tz/myers_diff.py +0 -0
  114. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/file.py +0 -0
  115. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/listz.py +0 -0
  116. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/lrval.py +0 -0
  117. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/mapz.py +0 -0
  118. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/nextz.py +0 -0
  119. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/setz.py +0 -0
  120. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/deal/spt.py +0 -0
  121. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/exp.py +0 -0
  122. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/item.py +0 -0
  123. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/loader/pos.py +0 -0
  124. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/write.py +0 -0
  125. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/writer/base.py +0 -0
  126. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/writer/conf.py +0 -0
  127. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/writer/deal/jsonval.py +0 -0
  128. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/writer/deal/listz.py +0 -0
  129. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/writer/deal/mapz.py +0 -0
  130. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/writer/deal/reval.py +0 -0
  131. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/writer/deal/strz.py +0 -0
  132. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/writer/itemz.py +0 -0
  133. {buildz-0.4.9 → buildz-0.5.1}/buildz/xf/writer/mg.py +0 -0
  134. {buildz-0.4.9 → buildz-0.5.1}/buildz.egg-info/dependency_links.txt +0 -0
  135. {buildz-0.4.9 → buildz-0.5.1}/buildz.egg-info/top_level.txt +0 -0
  136. {buildz-0.4.9 → buildz-0.5.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: buildz
3
- Version: 0.4.9
3
+ Version: 0.5.1
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
@@ -28,6 +28,8 @@ License-File: LICENSE
28
28
 
29
29
  运行python -m buildz查看帮助
30
30
 
31
+ PS: 对比了下json.loads(修改了下json的scanner.py,让它在纯python下运行,不然json.loads会更快)和目前的xf.loads(buildz.xf.readz.loads)的速度,xf.loads比json.loads慢7倍,可能是读字符串更频繁,方法调用更多(为了代码更结构化和容易修改),其实有一版更慢(buildz.xf.read.loads,废弃代码,后面看情况删掉),慢100倍,因为只考虑结构化,没考虑列表增减开销
32
+
31
33
  1, a profile file format base on json, make it easy to write profile file, module is in buildz.xf
32
34
  2, a ioc profile file read function base on xf format, module is in buildz.ioc
33
35
  3, other tools module:
@@ -42,4 +44,6 @@ code relationship:
42
44
  buildz.demo use all other modules
43
45
 
44
46
  run python -m buildz to see help
47
+
48
+ PS: testing speed on json.loads(has modified scanner.py in json module to make it purely run on Python, which make it run slower) and xf.loads(real func is buildz.xf.readz.loads), xf.loads takes 7 times longer than json.loads, it may cost by more func calls and more string cutting and reading(to make codes more structuring and easier to update)
45
49
  ```
@@ -15,6 +15,8 @@
15
15
 
16
16
  运行python -m buildz查看帮助
17
17
 
18
+ PS: 对比了下json.loads(修改了下json的scanner.py,让它在纯python下运行,不然json.loads会更快)和目前的xf.loads(buildz.xf.readz.loads)的速度,xf.loads比json.loads慢7倍,可能是读字符串更频繁,方法调用更多(为了代码更结构化和容易修改),其实有一版更慢(buildz.xf.read.loads,废弃代码,后面看情况删掉),慢100倍,因为只考虑结构化,没考虑列表增减开销
19
+
18
20
  1, a profile file format base on json, make it easy to write profile file, module is in buildz.xf
19
21
  2, a ioc profile file read function base on xf format, module is in buildz.ioc
20
22
  3, other tools module:
@@ -29,4 +31,6 @@ code relationship:
29
31
  buildz.demo use all other modules
30
32
 
31
33
  run python -m buildz to see help
34
+
35
+ PS: testing speed on json.loads(has modified scanner.py in json module to make it purely run on Python, which make it run slower) and xf.loads(real func is buildz.xf.readz.loads), xf.loads takes 7 times longer than json.loads, it may cost by more func calls and more string cutting and reading(to make codes more structuring and easier to update)
32
36
  ```
@@ -1,7 +1,8 @@
1
1
  #coding=utf-8
2
2
 
3
- __version__="0.4.5"
3
+ __version__="0.4.91"
4
4
 
5
+ # 小号多
5
6
  __author__ = "Zzz, emails: 1174534295@qq.com, 1309458652@qq.com"
6
7
 
7
8
  from .argx import fetch as args
@@ -1,5 +1,41 @@
1
1
  #coding=utf-8
2
2
  import sys
3
+ class Fetch:
4
+ """
5
+ 命令行参数读取
6
+ ft = Fetch("id,name,kind".split(","), {"a":"age"})
7
+ or
8
+ ft = Fetch(*xf.loads("[[id,name,kind],{a:age}]"))
9
+
10
+ ft("001 zero life -a12".split(" ")) = {'id': '001', 'name': 'zero', 'kind': 'life', 'age': '12'}
11
+
12
+ 但更简单的方法是:
13
+ xf.args("{id:'001', name: zero, kind: life, age: 12}".split(" ")) = {'id': '001', 'name': 'zero', 'kind': 'life', 'age': 12}
14
+ python buildz.xf {id:'001', name: zero, kind: life, age: 12}
15
+ 就是对引号不太适用
16
+ """
17
+ def __init__(self, args = [], maps ={}):
18
+ self.args = args
19
+ self.maps = maps
20
+ def __call__(self, argv = None):
21
+ args, maps = fetch(argv)
22
+ rst = {}
23
+ for i in range(len(args)):
24
+ if i >= len(self.args):
25
+ break
26
+ key = self.args[i]
27
+ rst[key] = args[i]
28
+ for key in maps:
29
+ rst[key] = maps[key]
30
+ for key in self.maps:
31
+ rkey = self.maps[key]
32
+ if key in rst:
33
+ val = rst[key]
34
+ rst[rkey] = val
35
+ del rst[key]
36
+ return rst
37
+
38
+ pass
3
39
  def fetch(argv = None):
4
40
  r"""
5
41
  format: a b c -a 123 -b456 --c=789 +d -x"??? ???" y z
@@ -18,6 +18,7 @@
18
18
  # 字符串里有特殊符合,还是要用引号括起来
19
19
  # if special charater is contained in string, use '' or "" to wrap string
20
20
  'a:b':"{c,d,e,f}"
21
+ <1,int>=<0,bool>
21
22
  }
22
23
  ]
23
24
  }
@@ -0,0 +1,61 @@
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
+ self.data = data
51
+ self.sid = conf.id
52
+ self.src = src
53
+ self.conf = conf
54
+ self.confs = conf.confs
55
+ self.local = local
56
+ if type is None:
57
+ type = conf.confs.get_data_type(data, 0, conf.default_type())
58
+ self.type = type
59
+ self.info = info
60
+
61
+ pass
@@ -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
5
+ from .base import Base, EncapeData,IOCError
6
6
  class Conf(Base):
7
7
  """
8
8
  配置文件格式:
@@ -33,6 +33,12 @@ class Conf(Base):
33
33
  item_conf,
34
34
  ...
35
35
  ]
36
+ // 初始化,会一个一个get(id)
37
+ // 其他地方调用该conf.get的时候,会先判断有没有进行init,没有就先调init里的get
38
+ inits: [
39
+ id,
40
+ ...
41
+ ]
36
42
  }
37
43
  如果只有全局数据配置项,可以只写datas里的东西:
38
44
  [
@@ -63,7 +69,7 @@ class Conf(Base):
63
69
  }
64
70
  """
65
71
  if type(conf)!=dict:
66
- conf = {'data':conf}
72
+ conf = {'datas':conf}
67
73
  id = xf.g(conf, id=None)
68
74
  if id is None:
69
75
  id = confs.conf_id()
@@ -74,6 +80,7 @@ class Conf(Base):
74
80
  self.locals = self.map(xf.g(conf, locals=[]), self.confs.get_data_id)
75
81
  self.datas = self.map(xf.g(conf, datas=[]), self.confs.get_data_id)
76
82
  self.deals = self.map(xf.g(conf, deals = []), self.confs.get_deal_type)
83
+ self.inits = xf.g(conf, inits = [])
77
84
  self._default_type = xf.g(conf, default_type = None)
78
85
  self.envs = xf.g(conf, envs = {})
79
86
  self.confs.flush_env(self.envs)
@@ -97,6 +104,13 @@ class Conf(Base):
97
104
  aliases = xf.g(conf, aliases = [])
98
105
  for alias in aliases:
99
106
  self.deals[alias] = deal
107
+ self.mark_init = False
108
+ def do_init(self):
109
+ if self.mark_init:
110
+ return
111
+ self.mark_init = True
112
+ for id in self.inits:
113
+ self.get(id)
100
114
  def get_env(self, id, search_confs = True):
101
115
  if self.confs.global_env and search_confs:
102
116
  return self.confs.get_env(id, self.id)
@@ -116,6 +130,9 @@ class Conf(Base):
116
130
  if not search_confs:
117
131
  return None
118
132
  return self.confs.get_env(id, self.id)
133
+ def set_deal(self, type, fc):
134
+ self.deals[type] = fc
135
+ self.confs.set_deal(type, fc)
119
136
  def get_deal(self, type, search_confs = True):
120
137
  if self.confs.global_deal and search_confs:
121
138
  return self.confs.get_deal(type, self.id)
@@ -125,6 +142,7 @@ class Conf(Base):
125
142
  return None
126
143
  return self.confs.get_deal(type, self.id)
127
144
  def get_data(self, id, local = True, search_confs = True, src = None, info = None):
145
+ self.do_init()
128
146
  if id in self.datas:
129
147
  obj = self.datas[id]
130
148
  return EncapeData(obj, self, local = False, src=src, info = info)
@@ -148,9 +166,11 @@ class Conf(Base):
148
166
  """
149
167
  conf = self.get_data(id, src = src, info = info)
150
168
  if conf is None:
169
+ raise IOCError(f"can't find conf of {id}")
151
170
  return None
152
171
  deal = self.get_deal(conf.type)
153
172
  if deal is None:
173
+ raise IOCError(f"can't find deal of {id}, type = {conf.type}")
154
174
  return None
155
175
  if not remove:
156
176
  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):
@@ -220,6 +220,13 @@ class Confs(Base):
220
220
  self.deals = {}
221
221
  self.envs = {}
222
222
  self.envs_args = None
223
+ self.mark_init = False
224
+ def do_init(self):
225
+ if self.mark_init:
226
+ return
227
+ self.mark_init = True
228
+ for id in self.confs:
229
+ self.confs[id].do_init()
223
230
  def get_deal_type(self, obj):
224
231
  if type(obj)==dict:
225
232
  return obj[self.deal_key_type]
@@ -306,11 +313,14 @@ class Confs(Base):
306
313
  """
307
314
  根据data id获取data对象,处理逻辑:根据data id查配置,根据配置的type查deal,返回deal处理过的配置
308
315
  """
316
+ self.do_init()
309
317
  conf = self.get_data(id, sid, src=src, info = info)
310
318
  if conf is None:
319
+ raise IOCError(f"confs: can't find conf of {id}")
311
320
  return None
312
321
  deal = self.get_deal(conf.type, sid)
313
322
  if deal is None:
323
+ raise IOCError(f"confs: can't find deal of {id}, type = {conf.type}")
314
324
  return None
315
325
  #print(f"get_obj: {id}({sid}), conf: {conf}, deal: {deal}, type: {conf.type}")
316
326
  if not remove:
@@ -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,40 @@
1
+ #coding=utf-8
2
+ from ..ioc.base import Base, EncapeData,IOCError
3
+ from .base import FormatData,BaseDeal
4
+ from buildz import xf, pyz
5
+ import os
6
+ dp = os.path.dirname(__file__)
7
+ join = os.path.join
8
+ class DealDeal(BaseDeal):
9
+ """
10
+ // 调用后会注册到conf的deal上,用于扩展deals配置
11
+ deal字段deal:
12
+ {
13
+ id:id
14
+ type: deal
15
+ target: type
16
+ source: id # 要求source实现了方法__call__(self, edata:EncapeData)
17
+ }
18
+ 简写:
19
+ [[id, deal], target, source]
20
+ [deal, target, source]
21
+ 例:
22
+ [deal, target, source] //
23
+ """
24
+ def init(self, fp_lists=None, fp_defaults=None):
25
+ super().init("DealDeal", fp_lists, fp_defaults, join(dp, "conf", "deal_lists.js"), None)
26
+ def deal(self, edata:EncapeData):
27
+ data = edata.data
28
+ source = xf.g(data, source=None)
29
+ if source is None:
30
+ raise IOCError("not source in dealdeal")
31
+ target = xf.g(data, target=None)
32
+ if target is None:
33
+ raise IOCError("not target in dealdeal")
34
+ obj = edata.conf.get(source)
35
+ if obj is None:
36
+ raise IOCError("source object not found in dealdeal")
37
+ edata.conf.set_deal(target, obj)
38
+ return None
39
+
40
+ pass
@@ -1,5 +1,5 @@
1
1
  #
2
- from ..ioc.base import Base, EncapeData
2
+ from ..ioc.base import Base, EncapeData,IOCError
3
3
  from .base import FormatData,BaseDeal
4
4
  from buildz import xf, pyz
5
5
  import os
@@ -12,7 +12,9 @@ class ObjectDeal(BaseDeal):
12
12
  id: id
13
13
  type: object
14
14
  source: 导入路径+调用方法/类
15
- single: 1 //是否单例,默认是
15
+ single: 1 //是否单例,默认是,
16
+ //这里的单例是一个id对应一个实例,
17
+ //如果两个id用的同一个source,就是同一个source的两个对象
16
18
  // 构造函数
17
19
  construct:{
18
20
  args: [
@@ -24,6 +26,15 @@ class ObjectDeal(BaseDeal):
24
26
  ...
25
27
  }
26
28
  }
29
+ //construct和args+maps,不能同时存在
30
+ args: [
31
+ item_conf,
32
+ ...
33
+ ]
34
+ maps: {
35
+ key1: item_conf,
36
+ ...
37
+ }
27
38
  // sets之前调用方法
28
39
  prev_call: item_conf
29
40
  // 对象变量设置属性
@@ -98,13 +109,18 @@ class ObjectDeal(BaseDeal):
98
109
  if ids is not None:
99
110
  obj = xf.gets(self.singles, ids)
100
111
  if obj is not None:
112
+ #raise IOCError(f"null for {ids}")
101
113
  return obj
102
114
  source = xf.g(data, source=0)
103
115
  fc = xf.get(self.sources, source, None)
104
116
  if fc is None:
105
117
  fc = pyz.load(source)
106
118
  self.sources[source]=fc
107
- cst = xf.g(data, construct = [])
119
+ cst = xf.g(data, construct = None)
120
+ if cst is None:
121
+ _args = xf.g(data, args = [])
122
+ _maps = xf.g(data, maps = {})
123
+ cst = [_args, _maps]
108
124
  cst = self.fmt_cst(cst)
109
125
  args = xf.g(cst, args=[])
110
126
  maps = xf.g(cst, maps={})
@@ -0,0 +1,41 @@
1
+ #
2
+ from ..ioc.base import Base, EncapeData
3
+ from .base import FormatData,BaseDeal
4
+ from buildz import xf, pyz
5
+ import os
6
+ dp = os.path.dirname(__file__)
7
+ join = os.path.join
8
+ class XfileDeal(BaseDeal):
9
+ """
10
+ 配置文件载入xfile/xf:
11
+ {
12
+ id:id
13
+ type:xfile
14
+ filepath: fp
15
+ # or fp: fp
16
+ }
17
+ 简写:
18
+ [[id, xfile], fp]
19
+ [xfile, fp]
20
+ [xf, fp]
21
+ 例:
22
+ [xfile, test.js]
23
+ """
24
+ def init(self, fp_lists = None, fp_defaults = None):
25
+ self.singles = {}
26
+ self.sources = {}
27
+ super().init("XfileDeal", fp_lists, fp_defaults,
28
+ join(dp, "conf", "xfile_lists.js"),
29
+ join(dp, "conf", "xfile_defaults.js"))
30
+ def deal(self, edata:EncapeData):
31
+ sid = edata.sid
32
+ data = edata.data
33
+ conf = edata.conf
34
+ data = self.format(data)
35
+ fp = xf.g(data, filepath=None)
36
+ if fp is None:
37
+ fp = xf.g(data, fp = fp)
38
+ rst = xf.loads(xf.fread(fp))
39
+ return rst
40
+
41
+ pass
@@ -15,7 +15,7 @@ def load(md, fc = None):
15
15
  try:
16
16
  md = __import__(".".join(mds))
17
17
  break
18
- except:
18
+ except ModuleNotFoundError as exp:
19
19
  mds = mds[:-1]
20
20
  if len(mds)==0:
21
21
  raise Exception("can't import package from "+md)
@@ -1,11 +1,12 @@
1
1
  #coding=utf-8
2
2
  #author: Zzz, emails: 1174534295@qq.com, 1309458652@qq.com
3
3
 
4
- # 代码差异
4
+ # 文件差异
5
5
  from .myers_diff import update as m_update, myers as m_steps, encode as m_encode, decode as m_decode,count as m_count
6
6
 
7
7
  """
8
8
  工具模块
9
+ toolz简写成tz
9
10
 
10
11
  """
11
12
  __author__ = "Zzz, emails: 1174534295@qq.com, 1309458652@qq.com"
@@ -1,5 +1,5 @@
1
1
 
2
- from .read import loads, load
2
+ from .readz import loads, load
3
3
  from .write import dumps, dump
4
4
  from .file import *
5
5
  from .mapz import *
@@ -0,0 +1,6 @@
1
+ #coding=utf-8
2
+ from .xargs import test
3
+ if __name__=="__main__":
4
+ test()
5
+
6
+ pass
@@ -1,5 +1,9 @@
1
1
 
2
2
  class BaseDeal:
3
+ def has_prev(self):
4
+ return 1
5
+ def has_deal(self):
6
+ return 1
3
7
  def sp(self):
4
8
  return super(self.__class__, self)
5
9
  def regist(self, mgs):
@@ -83,3 +83,38 @@ class Buffer:
83
83
  self.buffer = self.buffer[:-size]
84
84
 
85
85
  pass
86
+
87
+ class StrBuffer:
88
+ def read(self, size = 1, pop = 0):
89
+ s = self.str[self.read_base:self.read_base+size]
90
+ if pop:
91
+ self.read_base+=size
92
+ return s
93
+ def pop_read(self, size=1):
94
+ self.read_base+=size
95
+ def init(self):
96
+ self.buffer_base = 0
97
+ self.buffer_size = 0
98
+ self.read_base = 0
99
+ self.read_size = 0
100
+ #self.buffer = None
101
+ #self.s_read = None
102
+ def __init__(self, s):
103
+ self.str = s
104
+ self.init()
105
+ def add(self, arr):
106
+ # x = self.str[self.buffer_base+self.buffer_size:self.buffer_base+self.buffer_size+len(arr)]
107
+ # if x!=arr:
108
+ # print(f"[ERROR] x:({x}), arr:({arr}), bb: {self.buffer_base}, bs:{self.buffer_size}, rb: {self.read_base}")
109
+ # print("[["+self.str[self.buffer_base:self.read_base+10]+"]]")
110
+ # raise Exception("")
111
+ self.buffer_size+=len(arr)
112
+ def size(self):
113
+ return self.buffer_size
114
+ def full(self):
115
+ return self.str[self.buffer_base:self.buffer_base+self.buffer_size]
116
+ def clean(self):
117
+ self.buffer_base = self.read_base
118
+ self.buffer_size = 0
119
+
120
+ pass
@@ -27,6 +27,7 @@ class LRDeal(base.BaseDeal):
27
27
  if len(rm.strip())>0:
28
28
  pos.update(rm)
29
29
  raise exp.FormatExp(self.err("unexcept char before <lr> left symbol"), pos.get(), rm)
30
+ buffer.clean()
30
31
  pos.update(cl)
31
32
  queue.append(item.PrevItem(cl, pos.get(), self.id(), left = 1))
32
33
  else:
@@ -4,6 +4,10 @@ from .. import exp
4
4
  from . import lr
5
5
  import re
6
6
  class ValDeal(base.BaseDeal):
7
+ def has_prev(self):
8
+ return 0
9
+ def has_deal(self):
10
+ return 1
7
11
  """
8
12
  正则表达式匹配
9
13
  """
@@ -2,6 +2,10 @@ from .. import base
2
2
 
3
3
 
4
4
  class PrevSpcDeal(base.BaseDeal):
5
+ def has_prev(self):
6
+ return 1
7
+ def has_deal(self):
8
+ return 0
5
9
  """
6
10
  去掉左空格
7
11
  """
@@ -13,6 +17,7 @@ class PrevSpcDeal(base.BaseDeal):
13
17
  return False
14
18
  if len(c.strip())==0:
15
19
  buffer.pop_read()
20
+ buffer.clean()
16
21
  return True
17
22
  return False
18
23
 
@@ -4,6 +4,10 @@ from .. import exp
4
4
  from ... import file
5
5
  import json
6
6
  class PrevStrDeal(base.BaseDeal):
7
+ def has_prev(self):
8
+ return 1
9
+ def has_deal(self):
10
+ return 0
7
11
  def init(self, left = '"', right= '"', single_line = False, note = False, translate = False):
8
12
  self.left = left
9
13
  self.right = right
@@ -71,6 +75,7 @@ class PrevStrDeal(base.BaseDeal):
71
75
  tmp += c
72
76
  continue
73
77
  ctmp+=c
78
+ buffer.clean()
74
79
  xtmp = tmp[:-self.lr]
75
80
  if not self.note and self.single_line and xtmp.find(self.like("\n", xtmp))>=0:
76
81
  print("left:",self.left, "right:", self.right)