buildz 0.5.2__tar.gz → 0.5.4__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 (138) hide show
  1. {buildz-0.5.2/buildz.egg-info → buildz-0.5.4}/PKG-INFO +6 -2
  2. {buildz-0.5.2 → buildz-0.5.4}/README.md +4 -0
  3. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/myers/deal.py +2 -2
  4. {buildz-0.5.2 → buildz-0.5.4}/buildz/fz/fio.py +2 -2
  5. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/env_lists.js +5 -0
  6. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/env.py +6 -1
  7. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/xfile.py +4 -2
  8. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/file.py +1 -1
  9. buildz-0.5.4/buildz/xf/loaderz/deal/listz.py +35 -0
  10. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/deal/lr.py +15 -6
  11. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/deal/mapz.py +18 -1
  12. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/deal/nextz.py +12 -4
  13. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/deal/reval.py +3 -0
  14. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/deal/strz.py +2 -0
  15. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/mg.py +27 -12
  16. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/test.py +2 -2
  17. buildz-0.5.4/buildz/xf/loaderz/test1.py +7 -0
  18. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/mapz.py +32 -0
  19. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/write.py +2 -2
  20. {buildz-0.5.2 → buildz-0.5.4/buildz.egg-info}/PKG-INFO +6 -2
  21. {buildz-0.5.2 → buildz-0.5.4}/buildz.egg-info/SOURCES.txt +1 -0
  22. {buildz-0.5.2 → buildz-0.5.4}/setup.py +2 -2
  23. buildz-0.5.2/buildz/xf/loaderz/deal/listz.py +0 -19
  24. {buildz-0.5.2 → buildz-0.5.4}/LICENSE +0 -0
  25. {buildz-0.5.2 → buildz-0.5.4}/MANIFEST.in +0 -0
  26. {buildz-0.5.2 → buildz-0.5.4}/buildz/__init__.py +0 -0
  27. {buildz-0.5.2 → buildz-0.5.4}/buildz/__main__.py +0 -0
  28. {buildz-0.5.2 → buildz-0.5.4}/buildz/argx.py +0 -0
  29. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/ioc/deal.py +0 -0
  30. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/ioc/help.py +0 -0
  31. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/myers/help.py +0 -0
  32. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/conf/ioc.js +0 -0
  33. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/conf/main.js +0 -0
  34. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/conf/myers.js +0 -0
  35. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/conf/search.js +0 -0
  36. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/conf/xf.js +0 -0
  37. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/help/default.js +0 -0
  38. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/help/ioc.js +0 -0
  39. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/help/myers.js +0 -0
  40. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/help/search.js +0 -0
  41. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/help/xf.js +0 -0
  42. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/res/test.js +0 -0
  43. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/search/deal.py +0 -0
  44. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/search/help.py +0 -0
  45. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/test.py +0 -0
  46. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/xf/deal.py +0 -0
  47. {buildz-0.5.2 → buildz-0.5.4}/buildz/demo/xf/help.py +0 -0
  48. {buildz-0.5.2 → buildz-0.5.4}/buildz/fz/__init__.py +0 -0
  49. {buildz-0.5.2 → buildz-0.5.4}/buildz/fz/dirz.py +0 -0
  50. {buildz-0.5.2 → buildz-0.5.4}/buildz/fz/lsf.py +0 -0
  51. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/__init__.py +0 -0
  52. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/base.py +0 -0
  53. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/init.py +0 -0
  54. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc/base.py +0 -0
  55. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc/conf.py +0 -0
  56. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc/confs.py +0 -0
  57. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/base.py +0 -0
  58. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/call.py +0 -0
  59. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/calls.py +0 -0
  60. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
  61. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
  62. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
  63. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
  64. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/deal_lists.js +0 -0
  65. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/deals.js +0 -0
  66. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
  67. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
  68. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
  69. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
  70. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
  71. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
  72. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
  73. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
  74. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
  75. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
  76. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
  77. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/ref_lists.js +0 -0
  78. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
  79. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/xfile_defaults.js +0 -0
  80. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/conf/xfile_lists.js +0 -0
  81. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/deal.py +0 -0
  82. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/demo.py +0 -0
  83. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/ioc.py +0 -0
  84. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/join.py +0 -0
  85. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/list.py +0 -0
  86. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/map.py +0 -0
  87. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/mcall.py +0 -0
  88. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/obj.py +0 -0
  89. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/ovar.py +0 -0
  90. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/ref.py +0 -0
  91. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/val.py +0 -0
  92. {buildz-0.5.2 → buildz-0.5.4}/buildz/ioc/ioc_deal/var.py +0 -0
  93. {buildz-0.5.2 → buildz-0.5.4}/buildz/pyz.py +0 -0
  94. {buildz-0.5.2 → buildz-0.5.4}/buildz/tz/__init__.py +0 -0
  95. {buildz-0.5.2 → buildz-0.5.4}/buildz/tz/myers_diff.py +0 -0
  96. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/__init__.py +0 -0
  97. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/__main__.py +0 -0
  98. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/base.py +0 -0
  99. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/buffer.py +0 -0
  100. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/listz.py +0 -0
  101. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/lr.py +0 -0
  102. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/lrval.py +0 -0
  103. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/mapz.py +0 -0
  104. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/nextz.py +0 -0
  105. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/reval.py +0 -0
  106. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/setz.py +0 -0
  107. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/spc.py +0 -0
  108. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/spt.py +0 -0
  109. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/deal/strz.py +0 -0
  110. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/exp.py +0 -0
  111. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/item.py +0 -0
  112. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/mg.py +0 -0
  113. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loader/pos.py +0 -0
  114. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/base.py +0 -0
  115. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/buffer.py +0 -0
  116. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/deal/lrval.py +0 -0
  117. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/deal/setz.py +0 -0
  118. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/deal/spc.py +0 -0
  119. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/deal/spt.py +0 -0
  120. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/exp.py +0 -0
  121. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/item.py +0 -0
  122. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/loaderz/pos.py +0 -0
  123. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/read.py +0 -0
  124. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/readz.py +0 -0
  125. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/stack.py +0 -0
  126. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/writer/base.py +0 -0
  127. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/writer/conf.py +0 -0
  128. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/writer/deal/jsonval.py +0 -0
  129. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/writer/deal/listz.py +0 -0
  130. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/writer/deal/mapz.py +0 -0
  131. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/writer/deal/reval.py +0 -0
  132. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/writer/deal/strz.py +0 -0
  133. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/writer/itemz.py +0 -0
  134. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/writer/mg.py +0 -0
  135. {buildz-0.5.2 → buildz-0.5.4}/buildz/xf/xargs.py +0 -0
  136. {buildz-0.5.2 → buildz-0.5.4}/buildz.egg-info/dependency_links.txt +0 -0
  137. {buildz-0.5.2 → buildz-0.5.4}/buildz.egg-info/top_level.txt +0 -0
  138. {buildz-0.5.2 → buildz-0.5.4}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: buildz
3
- Version: 0.5.2
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
3
+ Version: 0.5.4
4
+ Summary: 配置读写(基于json格式进行简化),以及ioc。a json-base file format's read and write code by python, and codes to read and product object from configure file in such format(ioc)
5
5
  Home-page: https://github.com/buildCodeZ/buildz
6
6
  Author: Zzz
7
7
  Author-email: 1309458652@qq.com
@@ -28,6 +28,8 @@ License-File: LICENSE
28
28
 
29
29
  运行python -m buildz查看帮助
30
30
 
31
+ 持续更新中。。。
32
+
31
33
  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
34
 
33
35
  1, a profile file format base on json, make it easy to write profile file, module is in buildz.xf
@@ -45,5 +47,7 @@ code relationship:
45
47
 
46
48
  run python -m buildz to see help
47
49
 
50
+ continue updating...
51
+
48
52
  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)
49
53
  ```
@@ -15,6 +15,8 @@
15
15
 
16
16
  运行python -m buildz查看帮助
17
17
 
18
+ 持续更新中。。。
19
+
18
20
  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
21
 
20
22
  1, a profile file format base on json, make it easy to write profile file, module is in buildz.xf
@@ -32,5 +34,7 @@ code relationship:
32
34
 
33
35
  run python -m buildz to see help
34
36
 
37
+ continue updating...
38
+
35
39
  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)
36
40
  ```
@@ -41,7 +41,7 @@ class Deal:
41
41
  stp[-1] = c.decode()
42
42
  stps = "t"+xf.dumps(stps)
43
43
  stps = stps.encode()
44
- fz.write(fp_step, stps)
44
+ fz.write(stps, fp_step)
45
45
  print("done diff")
46
46
  elif opt == 'update':
47
47
  bs1 = fz.read(fp1).decode("utf-8")
@@ -53,7 +53,7 @@ class Deal:
53
53
  else:
54
54
  stps = xf.loads(bs_step.decode())
55
55
  bs2 = tz.m_update(bs1, stps,split=spt).encode("utf-8")
56
- fz.write(fp2, bs2)
56
+ fz.write(bs2, fp2)
57
57
  print("done update")
58
58
  else:
59
59
  print(f"unexpect opt: {opt}")
@@ -20,13 +20,13 @@ def freads(fp, mode = 'rb', size=1024*1024):
20
20
  pass
21
21
  reads=freads
22
22
 
23
- def fwrite(fp, ct, mode = 'wb'):
23
+ def fwrite(ct, fp, mode = 'wb'):
24
24
  with open(fp, mode) as f:
25
25
  f.write(ct)
26
26
 
27
27
  pass
28
28
  write = fwrite
29
- def fwrites(fp, cts, mode = 'wb'):
29
+ def fwrites(cts, fp, mode = 'wb'):
30
30
  with open(fp, mode) as f:
31
31
  for ct in cts:
32
32
  f.write(ct)
@@ -14,5 +14,10 @@
14
14
  {
15
15
  nullable: 0,
16
16
  key: key
17
+ },
18
+ {
19
+ nullable: 1,
20
+ key: default
21
+ default: null
17
22
  }
18
23
  ]
@@ -12,6 +12,7 @@ class EnvDeal(FormatDeal):
12
12
  id: id
13
13
  type: env
14
14
  key: 环境变量key
15
+ default: item_conf //可选
15
16
  }
16
17
  简写:
17
18
  [[id, env], key]
@@ -25,6 +26,10 @@ class EnvDeal(FormatDeal):
25
26
  data = edata.data
26
27
  data = self.fill(data)
27
28
  key = data['key']
28
- return edata.conf.get_env(key)
29
+ val = edata.conf.get_env(key)
30
+ default = xf.g(data, default=None)
31
+ if val is None and default is not None:
32
+ val = self.get_obj(default, edata.conf)
33
+ return val
29
34
 
30
35
  pass
@@ -11,8 +11,8 @@ class XfileDeal(FormatDeal):
11
11
  {
12
12
  id:id
13
13
  type:xfile
14
- filepath: fp
15
- # or fp: fp
14
+ filepath: item_conf(fp)
15
+ # or fp: item_conf(fp)
16
16
  }
17
17
  简写:
18
18
  [[id, xfile], fp]
@@ -20,6 +20,7 @@ class XfileDeal(FormatDeal):
20
20
  [xf, fp]
21
21
  例:
22
22
  [xfile, test.js]
23
+ [xfile, [val, test.js]]
23
24
  """
24
25
  def init(self, fp_lists = None, fp_defaults = None):
25
26
  self.singles = {}
@@ -35,6 +36,7 @@ class XfileDeal(FormatDeal):
35
36
  fp = xf.g(data, filepath=None)
36
37
  if fp is None:
37
38
  fp = xf.g(data, fp = fp)
39
+ fp = self.get_obj(fp, conf)
38
40
  rst = xf.loads(xf.fread(fp))
39
41
  return rst
40
42
 
@@ -40,7 +40,7 @@ def fread_c(filepath, coding = 'utf-8'):
40
40
 
41
41
  pass
42
42
 
43
- def fwrite(filepath, content, mode = 'w'):
43
+ def fwrite(content, filepath, mode = 'w'):
44
44
  with open(filepath, mode) as f:
45
45
  f.write(content)
46
46
 
@@ -0,0 +1,35 @@
1
+ from .. import base
2
+ from .. import item
3
+ from .. import exp
4
+ from . import lr
5
+ class ListDeal(lr.LRDeal):
6
+ """
7
+ 分隔符,有分隔符后将缓存的数据当作字符串
8
+ """
9
+ def init(self, left, right):
10
+ super().init(left, right, 'list')
11
+ def types(self):
12
+ return ['']
13
+ def build(self, obj):
14
+ val = obj.val
15
+ if type(val)!=list:
16
+ obj.is_val = 1
17
+ return obj
18
+ if len(val)==0:
19
+ obj.val = ''
20
+ obj.is_val = 1
21
+ return obj
22
+ if len(val)>1:
23
+ opt = val[1]
24
+ if opt.type=='kv':
25
+ return None
26
+ return self.build_arr(val)
27
+ def build_arr(self, arr):
28
+ rst = []
29
+ for _item in arr:
30
+ if not _item.is_val:
31
+ raise Exception(f"error in list:{_item}")
32
+ rst.append(_item.val)
33
+ return item.Item(rst, type='list', is_val = 1)
34
+
35
+ pass
@@ -14,7 +14,7 @@ class LRDeal(base.BaseDeal):
14
14
  rm = buffer.full().strip()
15
15
  buffer.clean2read(self.ll)
16
16
  if len(rm)>0:
17
- arr.append(item.Item(rm, type="", is_val=False))
17
+ _arr.append(item.Item(rm, type="", is_val=False))
18
18
  while True:
19
19
  cr = buffer.read(self.lr)
20
20
  if cr == self.right:
@@ -26,17 +26,26 @@ class LRDeal(base.BaseDeal):
26
26
  buffer.clean()
27
27
  if len(rm)>0:
28
28
  _arr.append(item.Item(rm ,type = '', is_val=False))
29
+ # dts = []
30
+ # for k in _arr:
31
+ # _k = mg.build(k)
32
+ # if item.is_null(_k):
33
+ # continue
34
+ # dts.append(_k)
35
+ #dts = [mg.build(k) for k in _arr]
36
+ dts = mg.build_arr(_arr)
37
+ obj = self.build_arr(dts)
38
+ rst.append(obj)
39
+ return True
40
+ def to_vals(self, _arr, mg):
29
41
  dts = []
30
42
  for k in _arr:
31
43
  _k = mg.build(k)
32
44
  if item.is_null(_k):
33
45
  continue
34
46
  dts.append(_k)
35
- #dts = [mg.build(k) for k in _arr]
36
- obj = self.build(dts)
37
- rst.append(obj)
38
- return True
39
- def build(self, obj):
47
+ return dts
48
+ def build_arr(self, obj):
40
49
  return item.Item(obj, type = self.type, is_val=True)
41
50
  """
42
51
  分隔符,有分隔符后将缓存的数据当作字符串
@@ -8,7 +8,24 @@ class MapDeal(lr.LRDeal):
8
8
  """
9
9
  def init(self, left, right):
10
10
  super().init(left, right, "map")
11
- def build(self, arr):
11
+ def types(self):
12
+ return ['']
13
+ def build(self, obj):
14
+ val = obj.val
15
+ if type(val)!=list:
16
+ obj.is_val = 1
17
+ return obj
18
+ if len(val)==0:
19
+ obj.val = ''
20
+ obj.is_val = 1
21
+ return obj
22
+ if len(val)%3!=0:
23
+ return None
24
+ opt = val[1]
25
+ if opt.type!='kv':
26
+ return None
27
+ return self.build_arr(val)
28
+ def build_arr(self, arr):
12
29
  rst = {}
13
30
  if len(arr)%3!=0:
14
31
  raise Exception(f"u f in map: {arr}")
@@ -1,21 +1,29 @@
1
1
  from .. import base
2
-
2
+ from .. import item
3
3
 
4
4
  class PrevNextDeal(base.BaseDeal):
5
5
  def labels(self):
6
6
  return ['']
7
7
  def types(self):
8
8
  return [""]
9
- def build(self, obj):
10
- obj.is_val = 1
11
- return obj
12
9
  """
13
10
  读取下一个字符放缓存里,应放最低优先级
14
11
  """
15
12
  def deal(self, buffer, arr, mg):
16
13
  c = buffer.read_cache(1)
17
14
  if len(c)==0:
15
+ rm = buffer.full().strip()
16
+ buffer.clean()
17
+ if len(rm)==0:
18
+ return False
19
+ obj = item.Item(rm, type = '', is_val = 0)
20
+ arr.append(obj)
18
21
  return False
19
22
  return True
23
+ def build(self, obj):
24
+ if type(obj.val)==list:
25
+ return None
26
+ obj.is_val = 1
27
+ return obj
20
28
 
21
29
  pass
@@ -6,6 +6,7 @@ import re
6
6
  class ValDeal(base.BaseDeal):
7
7
  def prepare(self,mg):
8
8
  self.pt = mg.like(self.pt)
9
+ self.type = mg.type
9
10
  def types(self):
10
11
  return [""]
11
12
  """
@@ -22,6 +23,8 @@ class ValDeal(base.BaseDeal):
22
23
  self.fc = fc
23
24
  def build(self, obj):
24
25
  val = obj.val
26
+ if type(val) != self.type:
27
+ return None
25
28
  if re.match(self.pt, val) is None:
26
29
  return None
27
30
  val = self.fc(val)
@@ -71,6 +71,8 @@ class PrevStrDeal(lr.LRDeal):
71
71
  if do_judge and c == self.label_et:
72
72
  mark_et += 1
73
73
  if len(c)==0:
74
+ if self.single_line and self.note:
75
+ break
74
76
  raise Exception(f"unexcept string end while reading str")
75
77
  do_judge = 1
76
78
  if c == self.label_l2:
@@ -3,6 +3,7 @@ from . import buffer
3
3
  from . import base
4
4
  from . import pos
5
5
  from . import exp
6
+ from . import item
6
7
  from ..stack import Stack
7
8
  class Manager:
8
9
  def __init__(self, as_bytes = False):
@@ -65,7 +66,7 @@ class Manager:
65
66
  raise Exception("unspt deal type:"+_type)
66
67
  def deal(self, buffer, arr):
67
68
  c = buffer.read()
68
- if len(c)==0:
69
+ if len(c)==0 and buffer.size()==0:
69
70
  return False
70
71
  deals = self.get_deals(c)
71
72
  find = False
@@ -77,21 +78,35 @@ class Manager:
77
78
  if deal.deal(buffer, arr, self):
78
79
  return True
79
80
  return False
81
+ def build_arr(self, _arr):
82
+ dts = []
83
+ for k in _arr:
84
+ _k = self.build(k)
85
+ if item.is_null(_k):
86
+ continue
87
+ dts.append(_k)
88
+ return dts
80
89
  def load(self, buffer):
81
90
  arr = []
82
91
  while self.deal(buffer, arr):
83
92
  pass
84
- arr = [k.val for k in arr]
85
- rst = []
86
- for k in arr:
87
- if type(k) == self.type:
88
- if len(k.strip())==0:
89
- continue
90
- rst.append(k)
91
- arr = rst
92
- if len(arr)==1:
93
- arr = arr[0]
94
- return arr
93
+ #arr = [k.val for k in arr]
94
+ #rst = []
95
+ # for k in arr:
96
+ # if type(k) == self.type:
97
+ # if len(k.strip())==0:
98
+ # continue
99
+ # rst.append(k)
100
+ arr = self.build_arr(arr)
101
+ obj = item.Item(arr, type = "", is_val = 0)
102
+ obj = self.build(obj)
103
+ #arr = rst
104
+ #if len(arr)==1:
105
+ # arr = arr[0]
106
+ val = obj.val
107
+ if type(val)==list and len(val)==1:
108
+ val = val[0]
109
+ return val
95
110
  def loads(self, reader):
96
111
  if type(reader) == self.type:
97
112
  #print(f"try str, {len(reader)}")
@@ -55,7 +55,7 @@ print("test E")
55
55
  json.dumps(_map)
56
56
  print("test F")
57
57
  js = json.dumps(rst)
58
- js = "\n\n"+js+"\n"
58
+ #js = "\n\n"+js+"\n"
59
59
  #js = xf.dumps(rst, json_format=1)
60
60
  # js = r"""
61
61
  # [
@@ -66,7 +66,7 @@ print("start")
66
66
  jv = cost("json.loads", json.loads,js)
67
67
  xv = cost("rz.loads",rz.loads,js)
68
68
  print(f"judge: {jv==xv}")
69
- _xv = cost("rd.loads",rd.loads, js)
69
+ #_xv = cost("rd.loads",rd.loads, js)
70
70
  #with open("test.json", 'w') as f:
71
71
  # f.write(js)
72
72
  if n>3 or m>3 or l > 3:
@@ -0,0 +1,7 @@
1
+
2
+
3
+ from buildz import xf
4
+ a = xf.loads("1,2,3")
5
+ b = xf.loads("{a=0,b=1}")
6
+ print(a)
7
+ print(b)
@@ -4,6 +4,38 @@ def get(obj, key, default=None):
4
4
  return default
5
5
  return obj[key]
6
6
 
7
+ pass
8
+ def getf(obj, key, fc):
9
+ if key not in obj:
10
+ return fc()
11
+ return obj[key]
12
+
13
+ pass
14
+ def gfn(obj, **maps):
15
+ rst = []
16
+ for k in maps:
17
+ if k in obj and obj[k] is not None:
18
+ v = obj[k]
19
+ else:
20
+ v = maps[k]()
21
+ rst.append(v)
22
+ if len(rst)==1:
23
+ rst = rst[0]
24
+ return rst
25
+
26
+ pass
27
+ def gf(obj, **maps):
28
+ rst = []
29
+ for k in maps:
30
+ if k in obj:
31
+ v = obj[k]
32
+ else:
33
+ v = maps[k]()
34
+ rst.append(v)
35
+ if len(rst)==1:
36
+ rst = rst[0]
37
+ return rst
38
+
7
39
  pass
8
40
  def g(obj, **maps):
9
41
  rst = []
@@ -38,9 +38,9 @@ def dumps(obj, bytes = 0, format = 0, deep = 0, json_format= 0):
38
38
 
39
39
  pass
40
40
 
41
- def dumpf(filepath, obj, bytes = 0, format = 0, deep = 0, json_format= 0, mode = 'w'):
41
+ def dumpf(obj, filepath, bytes = 0, format = 0, deep = 0, json_format= 0, mode = 'w'):
42
42
  s = dumps(obj, bytes = bytes, format = format, deep = deep, json_format= json_format)
43
- file.fwrite(filepath, s, mode)
43
+ file.fwrite(s, filepath, mode)
44
44
 
45
45
  pass
46
46
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: buildz
3
- Version: 0.5.2
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
3
+ Version: 0.5.4
4
+ Summary: 配置读写(基于json格式进行简化),以及ioc。a json-base file format's read and write code by python, and codes to read and product object from configure file in such format(ioc)
5
5
  Home-page: https://github.com/buildCodeZ/buildz
6
6
  Author: Zzz
7
7
  Author-email: 1309458652@qq.com
@@ -28,6 +28,8 @@ License-File: LICENSE
28
28
 
29
29
  运行python -m buildz查看帮助
30
30
 
31
+ 持续更新中。。。
32
+
31
33
  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
34
 
33
35
  1, a profile file format base on json, make it easy to write profile file, module is in buildz.xf
@@ -45,5 +47,7 @@ code relationship:
45
47
 
46
48
  run python -m buildz to see help
47
49
 
50
+ continue updating...
51
+
48
52
  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)
49
53
  ```
@@ -113,6 +113,7 @@ buildz/xf/loaderz/item.py
113
113
  buildz/xf/loaderz/mg.py
114
114
  buildz/xf/loaderz/pos.py
115
115
  buildz/xf/loaderz/test.py
116
+ buildz/xf/loaderz/test1.py
116
117
  buildz/xf/loaderz/deal/listz.py
117
118
  buildz/xf/loaderz/deal/lr.py
118
119
  buildz/xf/loaderz/deal/lrval.py
@@ -7,11 +7,11 @@ from setuptools import setup, find_packages
7
7
 
8
8
  setup(
9
9
  name = 'buildz',
10
- version = '0.5.2',
10
+ version = '0.5.4',
11
11
  keywords='buildz',
12
12
  long_description=open('README.md', 'r', encoding="utf-8").read(),
13
13
  long_description_content_type='text/markdown',
14
- description = "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",
14
+ description = "配置读写(基于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)",
15
15
  license = 'Apache License 2.0',
16
16
  url = 'https://github.com/buildCodeZ/buildz',
17
17
  author = 'Zzz',
@@ -1,19 +0,0 @@
1
- from .. import base
2
- from .. import item
3
- from .. import exp
4
- from . import lr
5
- class ListDeal(lr.LRDeal):
6
- """
7
- 分隔符,有分隔符后将缓存的数据当作字符串
8
- """
9
- def init(self, left, right):
10
- super().init(left, right, 'list')
11
- def build(self, arr):
12
- rst = []
13
- for _item in arr:
14
- if not _item.is_val:
15
- raise Exception("error in list:"+_item)
16
- rst.append(_item.val)
17
- return item.Item(rst, type='list', is_val = 1)
18
-
19
- pass
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes