buildz 0.4.5__tar.gz → 0.4.6__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 (164) hide show
  1. buildz-0.4.6/PKG-INFO +35 -0
  2. buildz-0.4.6/README.md +22 -0
  3. {buildz-0.4.5 → buildz-0.4.6}/buildz/argx.py +20 -4
  4. buildz-0.4.6/buildz/demo/ioc/deal.py +20 -0
  5. buildz-0.4.6/buildz/demo/ioc/help.py +42 -0
  6. {buildz-0.4.5 → buildz-0.4.6}/buildz/demo/res/conf/main.js +6 -2
  7. buildz-0.4.6/buildz/demo/res/conf/search.js +21 -0
  8. buildz-0.4.6/buildz/demo/res/help/default.js +20 -0
  9. buildz-0.4.6/buildz/demo/res/help/ioc.js +39 -0
  10. buildz-0.4.6/buildz/demo/res/help/search.js +38 -0
  11. buildz-0.4.6/buildz/demo/res/help/xf.js +34 -0
  12. buildz-0.4.6/buildz/demo/res/test.js +23 -0
  13. buildz-0.4.6/buildz/demo/search/deal.py +29 -0
  14. buildz-0.4.6/buildz/demo/search/help.py +16 -0
  15. {buildz-0.4.5 → buildz-0.4.6}/buildz/demo/test.py +16 -2
  16. {buildz-0.4.5 → buildz-0.4.6}/buildz/demo/xf/deal.py +1 -1
  17. buildz-0.4.6/buildz/demo/xf/help.py +16 -0
  18. {buildz-0.4.5 → buildz-0.4.6}/buildz/fz/lsf.py +6 -3
  19. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/__init__.py +1 -1
  20. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc/base.py +2 -1
  21. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc/conf.py +52 -7
  22. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc/confs.py +11 -5
  23. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/base.py +10 -3
  24. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/call.py +18 -10
  25. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/calls.py +15 -8
  26. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/deals.js +13 -0
  27. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +1 -0
  28. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/mcall_lists.js +2 -1
  29. buildz-0.4.6/buildz/ioc/ioc_deal/conf/obj_defaults.js +12 -0
  30. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/obj_lists.js +2 -2
  31. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/ovar_lists.js +1 -0
  32. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/ref_lists.js +4 -0
  33. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/env.py +13 -0
  34. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/ioc.py +14 -0
  35. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/join.py +14 -1
  36. buildz-0.4.6/buildz/ioc/ioc_deal/list.py +35 -0
  37. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/map.py +17 -1
  38. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/mcall.py +24 -12
  39. buildz-0.4.6/buildz/ioc/ioc_deal/obj.py +165 -0
  40. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/ovar.py +19 -8
  41. buildz-0.4.6/buildz/ioc/ioc_deal/ref.py +35 -0
  42. buildz-0.4.6/buildz/ioc/ioc_deal/val.py +29 -0
  43. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/var.py +11 -7
  44. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/mapz.py +38 -1
  45. buildz-0.4.6/buildz.egg-info/PKG-INFO +35 -0
  46. {buildz-0.4.5 → buildz-0.4.6}/buildz.egg-info/SOURCES.txt +4 -45
  47. {buildz-0.4.5 → buildz-0.4.6}/setup.py +2 -2
  48. buildz-0.4.5/PKG-INFO +0 -155
  49. buildz-0.4.5/README.md +0 -142
  50. buildz-0.4.5/buildz/demo/ioc/deal.py +0 -19
  51. buildz-0.4.5/buildz/demo/ioc/help.py +0 -7
  52. buildz-0.4.5/buildz/demo/res/help/default.js +0 -9
  53. buildz-0.4.5/buildz/demo/res/help/ioc.js +0 -165
  54. buildz-0.4.5/buildz/demo/res/help/xf.js +0 -35
  55. buildz-0.4.5/buildz/demo/res/test.js +0 -13
  56. buildz-0.4.5/buildz/demo/xf/help.py +0 -8
  57. buildz-0.4.5/buildz/demos/ioc/test.py +0 -43
  58. buildz-0.4.5/buildz/demos/ioc/test_conf/base.js +0 -9
  59. buildz-0.4.5/buildz/demos/ioc/test_conf/data1.js +0 -59
  60. buildz-0.4.5/buildz/demos/ioc/test_conf/data2.js +0 -21
  61. buildz-0.4.5/buildz/demos/ioc/test_conf/data3.js +0 -21
  62. buildz-0.4.5/buildz/demos/xf/test.js +0 -12
  63. buildz-0.4.5/buildz/demos/xf/test.py +0 -13
  64. buildz-0.4.5/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -8
  65. buildz-0.4.5/buildz/ioc/ioc_deal/list.py +0 -19
  66. buildz-0.4.5/buildz/ioc/ioc_deal/obj.py +0 -92
  67. buildz-0.4.5/buildz/ioc/ioc_deal/ref.py +0 -17
  68. buildz-0.4.5/buildz/ioc/ioc_deal/val.py +0 -16
  69. buildz-0.4.5/buildz/keys.py +0 -232
  70. buildz-0.4.5/buildz/old_version/__init__.py +0 -29
  71. buildz-0.4.5/buildz/old_version/__main__.py +0 -19
  72. buildz-0.4.5/buildz/old_version/base.py +0 -88
  73. buildz-0.4.5/buildz/old_version/build.py +0 -274
  74. buildz-0.4.5/buildz/old_version/confz.py +0 -501
  75. buildz-0.4.5/buildz/old_version/demo/x/demo.confz +0 -33
  76. buildz-0.4.5/buildz/old_version/demo/x/demo.py +0 -20
  77. buildz-0.4.5/buildz/old_version/demo/x/run.confz +0 -26
  78. buildz-0.4.5/buildz/old_version/demo/x/test.confz +0 -24
  79. buildz-0.4.5/buildz/old_version/demo/x/test.py +0 -15
  80. buildz-0.4.5/buildz/old_version/demo/x/testc.py +0 -18
  81. buildz-0.4.5/buildz/old_version/demo/x/testf.py +0 -46
  82. buildz-0.4.5/buildz/old_version/demo/x/testz.py +0 -90
  83. buildz-0.4.5/buildz/old_version/demo/x/value.confz +0 -19
  84. buildz-0.4.5/buildz/old_version/demo/x/x.py +0 -14
  85. buildz-0.4.5/buildz/old_version/dj.txt +0 -0
  86. buildz-0.4.5/buildz/old_version/keys.py +0 -232
  87. buildz-0.4.5/buildz/old_version/test_loader copy.py +0 -69
  88. buildz-0.4.5/buildz/old_version/test_loader.py +0 -26
  89. buildz-0.4.5/buildz/old_version/test_writer.py +0 -50
  90. buildz-0.4.5/buildz/old_version/tools.py +0 -39
  91. buildz-0.4.5/buildz/old_version/xconfz/__init__.py +0 -21
  92. buildz-0.4.5/buildz/old_version/xconfz/base.py +0 -222
  93. buildz-0.4.5/buildz/old_version/xconfz/buff.py +0 -57
  94. buildz-0.4.5/buildz/old_version/xconfz/fc.py +0 -8
  95. buildz-0.4.5/buildz/old_version/xconfz/fc_item.py +0 -88
  96. buildz-0.4.5/buildz/old_version/xconfz/fc_list.py +0 -85
  97. buildz-0.4.5/buildz/old_version/xconfz/fc_map.py +0 -91
  98. buildz-0.4.5/buildz/old_version/xconfz/fc_set.py +0 -60
  99. buildz-0.4.5/buildz/old_version/xconfz/fc_str.py +0 -80
  100. buildz-0.4.5/buildz/old_version/xconfz/fc_type.py +0 -100
  101. buildz-0.4.5/buildz/old_version/xconfz/fmt_base.py +0 -155
  102. buildz-0.4.5/buildz/old_version/xconfz/fmt_str.py +0 -50
  103. buildz-0.4.5/buildz/old_version/xconfz/fmt_type.py +0 -86
  104. buildz-0.4.5/buildz/old_version/xconfz/mg.py +0 -163
  105. buildz-0.4.5/buildz/old_version/xconfz/mg_fmt.py +0 -145
  106. buildz-0.4.5/buildz/xf/file.py +0 -41
  107. buildz-0.4.5/buildz.egg-info/PKG-INFO +0 -155
  108. {buildz-0.4.5 → buildz-0.4.6}/LICENSE +0 -0
  109. {buildz-0.4.5 → buildz-0.4.6}/MANIFEST.in +0 -0
  110. {buildz-0.4.5 → buildz-0.4.6}/buildz/__init__.py +0 -0
  111. {buildz-0.4.5 → buildz-0.4.6}/buildz/__main__.py +0 -0
  112. {buildz-0.4.5 → buildz-0.4.6}/buildz/demo/res/conf/ioc.js +0 -0
  113. {buildz-0.4.5 → buildz-0.4.6}/buildz/demo/res/conf/xf.js +0 -0
  114. {buildz-0.4.5 → buildz-0.4.6}/buildz/fz/__init__.py +0 -0
  115. {buildz-0.4.5 → buildz-0.4.6}/buildz/fz/dirz.py +0 -0
  116. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/init.py +0 -0
  117. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
  118. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
  119. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
  120. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
  121. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
  122. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
  123. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
  124. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
  125. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
  126. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
  127. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
  128. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
  129. {buildz-0.4.5 → buildz-0.4.6}/buildz/ioc/ioc_deal/demo.py +0 -0
  130. {buildz-0.4.5 → buildz-0.4.6}/buildz/pyz.py +0 -0
  131. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/__init__.py +0 -0
  132. {buildz-0.4.5/buildz/old_version/xconfz → buildz-0.4.6/buildz/xf}/file.py +0 -0
  133. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/base.py +0 -0
  134. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/buffer.py +0 -0
  135. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/listz.py +0 -0
  136. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/lr.py +0 -0
  137. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/lrval.py +0 -0
  138. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/mapz.py +0 -0
  139. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/nextz.py +0 -0
  140. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/reval.py +0 -0
  141. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/setz.py +0 -0
  142. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/spc.py +0 -0
  143. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/spt.py +0 -0
  144. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/deal/strz.py +0 -0
  145. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/exp.py +0 -0
  146. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/item.py +0 -0
  147. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/mg.py +0 -0
  148. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/loader/pos.py +0 -0
  149. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/read.py +0 -0
  150. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/test_write.py +0 -0
  151. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/write.py +0 -0
  152. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/writer/base.py +0 -0
  153. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/writer/conf.py +0 -0
  154. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/writer/deal/jsonval.py +0 -0
  155. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/writer/deal/listz.py +0 -0
  156. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/writer/deal/mapz.py +0 -0
  157. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/writer/deal/reval.py +0 -0
  158. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/writer/deal/strz.py +0 -0
  159. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/writer/itemz.py +0 -0
  160. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/writer/mg.py +0 -0
  161. {buildz-0.4.5 → buildz-0.4.6}/buildz/xf/xargs.py +0 -0
  162. {buildz-0.4.5 → buildz-0.4.6}/buildz.egg-info/dependency_links.txt +0 -0
  163. {buildz-0.4.5 → buildz-0.4.6}/buildz.egg-info/top_level.txt +0 -0
  164. {buildz-0.4.5 → buildz-0.4.6}/setup.cfg +0 -0
buildz-0.4.6/PKG-INFO ADDED
@@ -0,0 +1,35 @@
1
+ Metadata-Version: 2.1
2
+ Name: buildz
3
+ Version: 0.4.6
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
+ Home-page: https://github.com/buildCodeZ/buildz
6
+ Author: Zzz
7
+ Author-email: 1309458652@qq.com
8
+ License: Apache License 2.0
9
+ Keywords: buildz
10
+ Platform: any
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+
14
+ # buildz
15
+ ```
16
+ 1,在json格式基础上加了点东西,让配置文件写起来更简单,模块在buildz.xf下
17
+ 2,基于xf格式写了个ioc控制反转配置文件读取的程序,模块在buildz.ioc下
18
+ 3,其他工具模块:
19
+ buildz.fz: 文件夹查找
20
+ buildz.pyz: 简化python __import__调用
21
+ buildz.argx: 按格式读命令行参数
22
+ buildz.demo: 使用参考,运行"python -m buildz"会用这个模块
23
+
24
+ 运行python -m buildz查看帮助
25
+
26
+ 1, a profile file format base on json, make it easy to write profile file, module is in buildz.xf
27
+ 2, a ioc profile file read function base on xf format, module is in buildz.ioc
28
+ 3, other tools module:
29
+ buildz.fz: file search
30
+ buildz.pyz: make it easier to use python's __import__ function
31
+ buildz.argx: read command argument in special format
32
+ buildz.demo: example codes to use buildz, run "python -m buildz" will use this module
33
+
34
+ run python -m buildz to see help
35
+ ```
buildz-0.4.6/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # buildz
2
+ ```
3
+ 1,在json格式基础上加了点东西,让配置文件写起来更简单,模块在buildz.xf下
4
+ 2,基于xf格式写了个ioc控制反转配置文件读取的程序,模块在buildz.ioc下
5
+ 3,其他工具模块:
6
+ buildz.fz: 文件夹查找
7
+ buildz.pyz: 简化python __import__调用
8
+ buildz.argx: 按格式读命令行参数
9
+ buildz.demo: 使用参考,运行"python -m buildz"会用这个模块
10
+
11
+ 运行python -m buildz查看帮助
12
+
13
+ 1, a profile file format base on json, make it easy to write profile file, module is in buildz.xf
14
+ 2, a ioc profile file read function base on xf format, module is in buildz.ioc
15
+ 3, other tools module:
16
+ buildz.fz: file search
17
+ buildz.pyz: make it easier to use python's __import__ function
18
+ buildz.argx: read command argument in special format
19
+ buildz.demo: example codes to use buildz, run "python -m buildz" will use this module
20
+
21
+ run python -m buildz to see help
22
+ ```
@@ -13,12 +13,14 @@ def fetch(argv = None):
13
13
  i = 0
14
14
  while i<len(argv):
15
15
  v = argv[i]
16
+ make_plus = 0
16
17
  if v in ["-", "--", "+"]or v[0] not in "+-":
17
18
  lists.append(v)
18
19
  i+=1
19
20
  continue
20
21
  if v[0] == "+":
21
22
  key = v[1:]
23
+ make_plus = 1
22
24
  val = 1
23
25
  else:
24
26
  if v[1]=="-":
@@ -31,16 +33,21 @@ def fetch(argv = None):
31
33
  else:
32
34
  key = v[1]
33
35
  if len(v)>2:
34
- val = argv[2:]
36
+ val = v[2:]
35
37
  else:
36
38
  if i+1>=len(argv):
37
39
  val = 1
38
40
  else:
39
41
  val = argv[i+1]
40
42
  i+=1
41
- if key not in maps:
42
- maps[key] = []
43
- maps[key].append(val)
43
+ if make_plus:
44
+ keys = key.split(",")
45
+ else:
46
+ keys = [key]
47
+ for key in keys:
48
+ if key not in maps:
49
+ maps[key] = []
50
+ maps[key].append(val)
44
51
  i+=1
45
52
  for k in maps:
46
53
  v = maps[k]
@@ -50,5 +57,14 @@ def fetch(argv = None):
50
57
 
51
58
  pass
52
59
 
60
+ def get(maps, keys, default=None):
61
+ if type(keys) not in [list, tuple]:
62
+ keys = [keys]
63
+ for key in keys:
64
+ if key in maps:
65
+ return maps[key]
66
+ return default
67
+
68
+ pass
53
69
 
54
70
 
@@ -0,0 +1,20 @@
1
+ #coding=utf-8
2
+ from buildz import xf, argx, pyz, ioc, fz
3
+
4
+ from ..test import text_sfx, args, maps
5
+ class Deal:
6
+ def deal(self):
7
+ if len(args)<2:
8
+ print("need params 1 to be dirpath")
9
+ return
10
+ dp = args[1]
11
+ sfx = argx.get(maps, ("s", "suffix"), "js")
12
+ fps = fz.search(dp, f".*\.{sfx}$")
13
+ confs = ioc.build()
14
+ confs.add_fps(fps)
15
+ id = argx.get(maps, ("i", "id"), "main")
16
+ rst = confs.get(id)
17
+ print(f"get {id}: {rst}")
18
+ return rst
19
+
20
+ pass
@@ -0,0 +1,42 @@
1
+ #coding=utf-8
2
+ from buildz import xf, argx, pyz, ioc
3
+ from buildz.ioc.ioc.conf import Conf
4
+ from ..test import Help as BaseHelp
5
+ from os.path import dirname, join
6
+ from ..test import text_sfx, args, maps, en
7
+ class Help(BaseHelp):
8
+ def __init__(self, dp, fp):
9
+ fp = join(dp, fp)
10
+ self.helps = xf.loads(xf.fread(fp))
11
+ self.text = self.helps['text'+text_sfx]
12
+ def deal(self):
13
+ self._deal()
14
+ if en:
15
+ print("remarks isn't fully translated into English yet.")
16
+ def _deal(self):
17
+ if xf.g(maps, doc=0):
18
+ print(Conf.__doc__)
19
+ return
20
+ fp = argx.get(maps, ('f', 'file'))
21
+ if fp is None:
22
+ fp = ioc.default_deals
23
+ deals = xf.g(xf.loads(xf.fread(fp)), deals=[])
24
+ types = [f"{k['type']}({xf.g(k, note='???')})" for k in deals]
25
+ deals = {k['type']:k for k in deals}
26
+ notes = []
27
+ stypes = ", ".join(types)
28
+ self.text = self.text.replace("{items}",stypes)
29
+ var = argx.get(maps, ('h', 'help'))
30
+ if var == True:
31
+ print(self.text)
32
+ return
33
+ if var not in deals:
34
+ print(f"unknown type: {var}")
35
+ return
36
+ build = deals[var]['build']
37
+ c = pyz.load(build)
38
+ doc = c.__doc__
39
+ if doc is None:
40
+ doc = "没有注释"
41
+ print(doc)
42
+ pass
@@ -5,13 +5,13 @@
5
5
  type: join
6
6
  data: [
7
7
  [var, buildz.demo.test.dp]
8
- [val, res/help]
8
+ res/help
9
9
  ]
10
10
  }
11
11
  {
12
12
  id: help.default, type: object, source: buildz.demo.test.Help
13
13
  construct: {
14
- args: [(ref, help.dir), (val, default.js)]
14
+ args: [(ref, help.dir), default.js]
15
15
  }
16
16
  }
17
17
  {
@@ -34,6 +34,10 @@
34
34
  xf: {
35
35
  deal: deal.xf
36
36
  help: help.xf
37
+ },
38
+ search: {
39
+ deal: deal.search
40
+ help: help.search
37
41
  }
38
42
  }
39
43
  }
@@ -0,0 +1,21 @@
1
+ {
2
+ datas: [
3
+ {
4
+ id: help.search
5
+ type: object
6
+ source: buildz.demo.search.help.Help
7
+ construct: {
8
+ args: [
9
+ [ref, help.dir]
10
+ [val, search.js]
11
+ ]
12
+ }
13
+ }
14
+ {
15
+ id: deal.search
16
+ type: object
17
+ source: buildz.demo.search.deal.Deal
18
+ construct: {}
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ text=
3
+ r"""run
4
+ python -m buildz xf +h [+en]
5
+ or
6
+ python -m buildz ioc +h [+en]
7
+ or
8
+ python -m buildz search +h [+en]
9
+ to see help
10
+ """
11
+ text.en=
12
+ r"""run
13
+ python -m buildz xf +h [+en]
14
+ or
15
+ python -m buildz ioc +h [+en]
16
+ or
17
+ python -m buildz search +h [+en]
18
+ to see help
19
+ """
20
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ text=
3
+ r"""
4
+ xf格式的ioc控制反转配置文件的文件读取和生成对象
5
+ 预设的数据项(item_conf)格式:
6
+ {items}
7
+ 查看预设数据类型格式:
8
+ python -m buildz ioc -h 类型 [--file=预设数据处理配置文件] [-f 预设数据处理配置文件]
9
+ 查看配置文件书写格式:
10
+ python -m buildz ioc +h,doc
11
+ 比如:
12
+ python -m buildz ioc -h val
13
+
14
+ 测试执行ioc:
15
+ python -m buildz ioc 文件夹路径 [-s 配置文件后缀,默认js] [-i 数据id,默认main]
16
+ 例:
17
+ python -m buildz ioc /root/test -i obj.test
18
+ """;
19
+ text.en=
20
+ r"""
21
+ xf format ioc profile file's reading and object build
22
+ preset data item(item_conf)format:
23
+
24
+ {items}
25
+
26
+ to see preset data item format:
27
+ python -m buildz ioc -h type [--file="filepath contain deal func to deal item_conf"] [-f "same to --file"]
28
+
29
+ to see profile file write format:
30
+ python -m buildz ioc +h,doc
31
+ exp:
32
+ python -m buildz ioc -h val
33
+
34
+ test run ioc:
35
+ python -m buildz ioc dirpath [-s profile file suffix, default js] [-i "data id,default 'main'"]
36
+ exp:
37
+ python -m buildz ioc /root/test -i obj.test
38
+ """;
39
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ text=
3
+ r"""
4
+ 文件查找,运行:
5
+ python -m buildz search 文件夹路径
6
+ 可选参数:
7
+ -f 文件路径正则
8
+ --file=文件路径正则
9
+ -c 文件内容正则
10
+ --content=文件内容正则
11
+ -o 输出文件
12
+ --output=输出文件
13
+ -d 最深路径
14
+ --depth=最深路径
15
+
16
+ 比如:
17
+ python -m buildz search {default} -f ".*\.js" -c "ioc" -d 3
18
+
19
+ """
20
+ text.en=
21
+ r"""
22
+ file search, run by:
23
+ python -m buildz search dirpath
24
+ options:
25
+ -f "regex on filepath"
26
+ --file="regex on filepath"
27
+ -c "regex on file content"
28
+ --content="regex on file content"
29
+ -o "output filepath"
30
+ --output="output filepath"
31
+ -d "max-depth"
32
+ --depth="max-depth"
33
+
34
+ exp:
35
+ python -m buildz search {default} -f ".*\.js" -c "ioc" -d 3
36
+
37
+ """
38
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ text=
3
+ r"""在json格式基础上加了些其他东西,让配置写起来更简单:
4
+ 1,字符串可以不用引号括起来,程序判断字段不是整数,小数,布尔型等类型后,当字段是字符串
5
+ 2,可以写注释,//,#,/**/, ###...###,其中/*note*/和###note###是多行注释
6
+ 3,分号;和逗号,和换行\n等价,等于号=和冒号:等价,括号()和中括号[]等价
7
+ 4,加了python的字符串书写方式:"...", '...', r"...",r'...', r'''...'''
8
+ 5,输出格式化
9
+ 6,可配置化(但没太多注释)
10
+
11
+ 运行以下命令会打印文件格式化后的样式:
12
+ python -m buildz xf 文件名
13
+
14
+ 比如:
15
+ python -m buildz xf {default}
16
+
17
+ """
18
+ text.en=
19
+ r"""add something base on json format, make it eaisier to write profile file:
20
+ 1, string can write without ' or ", codes will regard item as string if not in int, float, boolean, list, map, ... format
21
+ 2, can write note on file, support note type: //note1 #note2 /*note3*/ ###note4###, /*note*/ and ###note### support multi-line notes
22
+ 3, ';' and '\n' used equal to ',' in json, '=' used equal to ':', '()' used equals to '[]'
23
+ 4, string can write like python format: "string1", 'string2', r"string3", r'string4', '''multi-line string1''', r'''multi-line string2'''
24
+ 5, codes to make format output string on data
25
+ 6, configurable(but has few notes on code)
26
+
27
+ output format string on input file:
28
+ python -m buildz xf filepath
29
+
30
+ exp:
31
+ python -m buildz xf {default}
32
+
33
+ """
34
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ /*
3
+ 这里有三行注释
4
+ 这里有三行注释
5
+ 这里有三行注释
6
+ */
7
+ name: 测试配置
8
+ ###
9
+ 还是注释
10
+ steal is note
11
+ ###
12
+ data: [
13
+ (1,.2,.03,4e-4,500)
14
+ {
15
+ // 中文当key
16
+ 代号=嘿嘿
17
+ age = ???
18
+ # 字符串里有特殊符合,还是要用引号括起来
19
+ # if special charater is contained in string, use '' or "" to wrap string
20
+ 'a:b':"{c,d,e,f}"
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,29 @@
1
+ #coding=utf-8
2
+ from buildz import xf, argx, pyz, ioc, fz
3
+
4
+ from ..test import text_sfx, args, maps
5
+ class Deal:
6
+ def deal(self):
7
+ if len(args)<2:
8
+ print("need params 1 to be dirpath")
9
+ return
10
+ dp = args[1]
11
+ ct_fp = argx.get(maps, "f,file".split(","), None)
12
+ ct = argx.get(maps, "c,content".split(","), None)
13
+ depth = argx.get(maps, "d,depth".split(","), None)
14
+ out_fp = argx.get(maps, "o,output".split(","), None)
15
+ if depth is not None:
16
+ depth = int(depth)
17
+ rst = fz.search(dp, ct_fp, ct, depth)
18
+ l = len(rst)
19
+ rs = "\n".join(rst)
20
+ if out_fp is not None:
21
+ with open(out_fp, 'w') as f:
22
+ f.write(rs)
23
+ print(f"result save in {out_fp}")
24
+ else:
25
+ print(rs)
26
+ print(f"done search, find files: {l}")
27
+ pass
28
+
29
+ pass
@@ -0,0 +1,16 @@
1
+ #coding=utf-8
2
+ from buildz import xf, argx, pyz, ioc
3
+ from ..test import Help as BaseHelp
4
+ from os.path import dirname, join
5
+ from ..test import text_sfx, args, maps
6
+ dp = dirname(dirname(__file__))
7
+ default_fp = join(dp, "res")
8
+ class Help(BaseHelp):
9
+ def __init__(self, dp, fp):
10
+ fp = join(dp, fp)
11
+ self.text = xf.loads(xf.fread(fp))['text'+text_sfx]
12
+ self.text = self.text.replace("{default}", default_fp)
13
+ def deal(self):
14
+ print(self.text)
15
+
16
+ pass
@@ -1,10 +1,14 @@
1
1
  #coding=utf-8
2
2
  from buildz import xf, argx, pyz, ioc, fz
3
3
  from os.path import dirname, join
4
+ args, maps = argx.fetch()
5
+ en = argx.get(maps, 'en', 0)
6
+ text_sfx = "" if not en else ".en"
4
7
  class Help:
5
8
  def __init__(self, dp, fp):
6
9
  fp = join(dp, fp)
7
- self.text = xf.loads(xf.fread(fp))['text']
10
+ self.obj = xf.loads(xf.fread(fp))
11
+ self.text = self.obj['text'+text_sfx]
8
12
  def deal(self):
9
13
  print(self.text)
10
14
 
@@ -21,22 +25,32 @@ class Deal:
21
25
  obj = conf.get(ref)
22
26
  self.deals[md][key] = obj
23
27
  def run(self):
24
- args, maps = argx.fetch()
25
28
  if len(args)==0:
26
29
  return self.default.deal()
27
30
  md = args[0]
28
31
  help = "h" in maps or "help" in maps
29
32
  key = "deal" if not help else "help"
33
+ if md not in self.deals:
34
+ return self.default.deal()
30
35
  obj = self.deals[md][key]
31
36
  obj.deal()
32
37
 
33
38
  pass
34
39
  dp = dirname(__file__)
40
+ import time
35
41
  def test():
42
+ print(f"start\n{'='*30}")
43
+ args, maps = argx.fetch()
44
+ curr = time.time()
36
45
  fps = fz.search(join(dp, 'res', 'conf'), ".*\.js")
37
46
  confs = ioc.build()
38
47
  confs.add_fps(fps)
39
48
  confs.get("run")
49
+ sec = time.time()-curr
50
+ ps = f"{'='*30}\nPS: 这只是个使用展示demo,代码在buildz.demo里,可供参考,运行耗时: {sec}"
51
+ if en:
52
+ ps = f"{'='*30}\nPS: just an demo show used of buildz module, demo codes is in buildz.demo, run time cost: {sec}"
53
+ print(ps)
40
54
 
41
55
  pass
42
56
 
@@ -1,9 +1,9 @@
1
1
  #coding=utf-8
2
2
  from buildz import xf, argx, pyz, ioc
3
3
 
4
+ from ..test import text_sfx, args, maps
4
5
  class Deal:
5
6
  def deal(self):
6
- args, maps = argx.fetch()
7
7
  if len(args)<2:
8
8
  print("need params 1 to be filepath")
9
9
  return
@@ -0,0 +1,16 @@
1
+ #coding=utf-8
2
+ from buildz import xf, argx, pyz, ioc
3
+ from ..test import Help as BaseHelp
4
+ from ..test import text_sfx, args, maps
5
+ from os.path import dirname, join
6
+ dp = dirname(dirname(__file__))
7
+ default_fp = join(dp, "res", "test.js")
8
+ class Help(BaseHelp):
9
+ def __init__(self, dp, fp):
10
+ fp = join(dp, fp)
11
+ self.text = xf.loads(xf.fread(fp))['text'+text_sfx]
12
+ self.text = self.text.replace("{default}", default_fp)
13
+ def deal(self):
14
+ print(self.text)
15
+
16
+ pass
@@ -19,16 +19,19 @@ class ListsDeal(dirz.FileDeal):
19
19
  pass
20
20
 
21
21
  class FileSearchDeal(dirz.FileDeal):
22
- def init(self, pt_fp=None, pt = None):
22
+ def init(self, pt_fp=None, pt = None, depth = None):
23
23
  super().init()
24
24
  self.pt_fp = pt_fp
25
25
  if type(pt) == str:
26
26
  pt = pt.encode()
27
27
  self.pt = pt
28
28
  self.rst = []
29
+ self.depth = depth
29
30
  def result(self):
30
31
  return self.rst
31
32
  def visit(self, filepath, isdir, depth):
33
+ if self.depth is not None and depth > self.depth:
34
+ return False
32
35
  if isdir:
33
36
  return True
34
37
  if self.pt_fp is not None and len(re.findall(self.pt_fp, filepath))==0:
@@ -56,7 +59,7 @@ def lists(fp):
56
59
  return ListsDeal().dirs(fp)
57
60
 
58
61
  pass
59
- def search(dp, pt_fp = None, pt = None):
60
- return FileSearchDeal(pt_fp, pt).dirs(dp)
62
+ def search(dp, pt_fp = None, pt = None, depth = None):
63
+ return FileSearchDeal(pt_fp, pt, depth).dirs(dp)
61
64
 
62
65
  pass
@@ -1,5 +1,5 @@
1
1
  #coding=utf-8
2
2
 
3
- from .init import build
3
+ from .init import build,default_deals
4
4
 
5
5
  __author__ = "Zzz, emails: 1174534295@qq.com, 1309458652@qq.com"
@@ -20,7 +20,7 @@ class EncapeData(Base):
20
20
  包含data id对应的配置,配置文件id,配置文件对象
21
21
  [object.test, call, ]
22
22
  """
23
- def __init__(self, data, conf, local = False, type = None, src = None):
23
+ def __init__(self, data, conf, local = False, type = None, src = None, info = None):
24
24
  self.data = data
25
25
  self.sid = conf.id
26
26
  self.src = src
@@ -30,5 +30,6 @@ class EncapeData(Base):
30
30
  if type is None:
31
31
  type = conf.confs.get_data_type(data, 0, conf.default_type())
32
32
  self.type = type
33
+ self.info = info
33
34
 
34
35
  pass
@@ -4,6 +4,43 @@ from buildz.xf import g as xg
4
4
  import json
5
5
  from .base import Base, EncapeData
6
6
  class Conf(Base):
7
+ """
8
+ 配置文件格式:
9
+ {
10
+ id: 配置文件id,默认null
11
+ //在配置文件配置的环境变量
12
+ envs: {
13
+ id: val
14
+ ...
15
+ }
16
+ // 数据配置项处理逻辑,一般不用管
17
+ deals: {
18
+ {
19
+ type: 要处理的数据类型
20
+ build: 函数import的路径
21
+ args: [] // 列表入参
22
+ maps: {} // 字典入参
23
+ }
24
+ }
25
+ namespace: 命名空间,默认null
26
+ //本地数据配置项
27
+ locals: [
28
+ item_conf,
29
+ ...
30
+ ]
31
+ //全局数据配置项
32
+ datas: [
33
+ item_conf,
34
+ ...
35
+ ]
36
+ }
37
+ 如果只有全局数据配置项,可以只写datas里的东西:
38
+ [
39
+ //全局数据配置项
40
+ item_conf,
41
+ ...
42
+ ]
43
+ """
7
44
  def get_key(self, obj, key = 'id', index=0):
8
45
  if type(obj)==dict:
9
46
  return obj[key]
@@ -25,6 +62,8 @@ class Conf(Base):
25
62
  default_type: default null
26
63
  }
27
64
  """
65
+ if type(conf)!=dict:
66
+ conf = {'data':conf}
28
67
  id = xf.g(conf, id=None)
29
68
  if id is None:
30
69
  id = confs.conf_id()
@@ -85,34 +124,40 @@ class Conf(Base):
85
124
  if not search_confs:
86
125
  return None
87
126
  return self.confs.get_deal(type, self.id)
88
- def get_data(self, id, local = True, search_confs = True):
127
+ def get_data(self, id, local = True, search_confs = True, src = None, info = None):
89
128
  if id in self.datas:
90
129
  obj = self.datas[id]
91
- return EncapeData(obj, self, local = False)
130
+ return EncapeData(obj, self, local = False, src=src, info = info)
92
131
  if not local:
93
132
  return None
94
133
  if id in self.locals:
95
134
  obj = self.locals[id]
96
- return EncapeData(obj, self, local = True)
135
+ return EncapeData(obj, self, local = True, src=src, info = info)
97
136
  if not search_confs:
98
137
  return None
99
- return self.confs.get_data(id, self.id)
138
+ return self.confs.get_data(id, self.id, src=src, info = info)
100
139
  def get(self, *args, **maps):
101
140
  return self.get_obj(*args, **maps)
102
141
  def default_type(self):
103
142
  if self._default_type is None:
104
143
  return self.confs.default_type
105
144
  return self._default_type
106
- def get_obj(self, id):
145
+ def get_obj(self, id, src = None, info=None, remove = False):
107
146
  """
108
147
  根据data id获取data对象,处理逻辑:根据data id查配置,根据配置的type查deal,返回deal处理过的配置
109
148
  """
110
- conf = self.get_data(id)
149
+ conf = self.get_data(id, src = src, info = info)
111
150
  if conf is None:
112
151
  return None
113
152
  deal = self.get_deal(conf.type)
114
153
  if deal is None:
115
154
  return None
116
- return deal(conf)
155
+ if not remove:
156
+ obj = deal(conf)
157
+ else:
158
+ obj = deal.remove(conf)
159
+ return obj
160
+ def remove(self, id):
161
+ return self.get_obj(id, remove=True)
117
162
 
118
163
  pass