buildz 0.5.3__tar.gz → 0.5.5__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 (139) hide show
  1. {buildz-0.5.3/buildz.egg-info → buildz-0.5.5}/PKG-INFO +6 -2
  2. {buildz-0.5.3 → buildz-0.5.5}/README.md +4 -0
  3. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/myers/deal.py +2 -2
  4. {buildz-0.5.3 → buildz-0.5.5}/buildz/fz/__init__.py +1 -1
  5. {buildz-0.5.3 → buildz-0.5.5}/buildz/fz/fio.py +14 -4
  6. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/deals.js +5 -0
  7. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/env_lists.js +5 -0
  8. buildz-0.5.3/buildz/ioc/ioc_deal/conf/ref_lists.js → buildz-0.5.5/buildz/ioc/ioc_deal/conf/iocf_lists.js +1 -5
  9. buildz-0.5.5/buildz/ioc/ioc_deal/conf/ref_lists.js +31 -0
  10. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/env.py +6 -1
  11. buildz-0.5.5/buildz/ioc/ioc_deal/iocf.py +59 -0
  12. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/map.py +1 -1
  13. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/obj.py +6 -3
  14. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/ref.py +4 -2
  15. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/xfile.py +4 -2
  16. {buildz-0.5.3 → buildz-0.5.5}/buildz/pyz.py +10 -0
  17. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/file.py +4 -2
  18. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/lr.py +1 -1
  19. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/strz.py +3 -1
  20. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/mg.py +1 -1
  21. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/mapz.py +52 -3
  22. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/write.py +2 -2
  23. {buildz-0.5.3 → buildz-0.5.5/buildz.egg-info}/PKG-INFO +6 -2
  24. {buildz-0.5.3 → buildz-0.5.5}/buildz.egg-info/SOURCES.txt +2 -0
  25. {buildz-0.5.3 → buildz-0.5.5}/setup.py +2 -2
  26. {buildz-0.5.3 → buildz-0.5.5}/LICENSE +0 -0
  27. {buildz-0.5.3 → buildz-0.5.5}/MANIFEST.in +0 -0
  28. {buildz-0.5.3 → buildz-0.5.5}/buildz/__init__.py +0 -0
  29. {buildz-0.5.3 → buildz-0.5.5}/buildz/__main__.py +0 -0
  30. {buildz-0.5.3 → buildz-0.5.5}/buildz/argx.py +0 -0
  31. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/ioc/deal.py +0 -0
  32. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/ioc/help.py +0 -0
  33. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/myers/help.py +0 -0
  34. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/conf/ioc.js +0 -0
  35. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/conf/main.js +0 -0
  36. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/conf/myers.js +0 -0
  37. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/conf/search.js +0 -0
  38. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/conf/xf.js +0 -0
  39. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/help/default.js +0 -0
  40. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/help/ioc.js +0 -0
  41. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/help/myers.js +0 -0
  42. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/help/search.js +0 -0
  43. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/help/xf.js +0 -0
  44. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/res/test.js +0 -0
  45. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/search/deal.py +0 -0
  46. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/search/help.py +0 -0
  47. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/test.py +0 -0
  48. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/xf/deal.py +0 -0
  49. {buildz-0.5.3 → buildz-0.5.5}/buildz/demo/xf/help.py +0 -0
  50. {buildz-0.5.3 → buildz-0.5.5}/buildz/fz/dirz.py +0 -0
  51. {buildz-0.5.3 → buildz-0.5.5}/buildz/fz/lsf.py +0 -0
  52. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/__init__.py +0 -0
  53. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/base.py +0 -0
  54. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/init.py +0 -0
  55. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc/base.py +0 -0
  56. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc/conf.py +0 -0
  57. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc/confs.py +0 -0
  58. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/base.py +0 -0
  59. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/call.py +0 -0
  60. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/calls.py +0 -0
  61. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
  62. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
  63. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
  64. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
  65. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/deal_lists.js +0 -0
  66. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
  67. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
  68. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
  69. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
  70. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
  71. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
  72. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
  73. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
  74. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
  75. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
  76. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
  77. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
  78. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/xfile_defaults.js +0 -0
  79. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/conf/xfile_lists.js +0 -0
  80. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/deal.py +0 -0
  81. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/demo.py +0 -0
  82. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/ioc.py +0 -0
  83. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/join.py +0 -0
  84. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/list.py +0 -0
  85. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/mcall.py +0 -0
  86. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/ovar.py +0 -0
  87. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/val.py +0 -0
  88. {buildz-0.5.3 → buildz-0.5.5}/buildz/ioc/ioc_deal/var.py +0 -0
  89. {buildz-0.5.3 → buildz-0.5.5}/buildz/tz/__init__.py +0 -0
  90. {buildz-0.5.3 → buildz-0.5.5}/buildz/tz/myers_diff.py +0 -0
  91. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/__init__.py +0 -0
  92. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/__main__.py +0 -0
  93. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/base.py +0 -0
  94. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/buffer.py +0 -0
  95. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/listz.py +0 -0
  96. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/lr.py +0 -0
  97. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/lrval.py +0 -0
  98. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/mapz.py +0 -0
  99. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/nextz.py +0 -0
  100. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/reval.py +0 -0
  101. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/setz.py +0 -0
  102. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/spc.py +0 -0
  103. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/spt.py +0 -0
  104. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/deal/strz.py +0 -0
  105. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/exp.py +0 -0
  106. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/item.py +0 -0
  107. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/mg.py +0 -0
  108. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loader/pos.py +0 -0
  109. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/base.py +0 -0
  110. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/buffer.py +0 -0
  111. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/listz.py +0 -0
  112. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/lrval.py +0 -0
  113. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/mapz.py +0 -0
  114. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/nextz.py +0 -0
  115. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/reval.py +0 -0
  116. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/setz.py +0 -0
  117. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/spc.py +0 -0
  118. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/deal/spt.py +0 -0
  119. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/exp.py +0 -0
  120. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/item.py +0 -0
  121. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/pos.py +0 -0
  122. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/test.py +0 -0
  123. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/loaderz/test1.py +0 -0
  124. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/read.py +0 -0
  125. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/readz.py +0 -0
  126. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/stack.py +0 -0
  127. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/writer/base.py +0 -0
  128. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/writer/conf.py +0 -0
  129. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/writer/deal/jsonval.py +0 -0
  130. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/writer/deal/listz.py +0 -0
  131. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/writer/deal/mapz.py +0 -0
  132. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/writer/deal/reval.py +0 -0
  133. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/writer/deal/strz.py +0 -0
  134. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/writer/itemz.py +0 -0
  135. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/writer/mg.py +0 -0
  136. {buildz-0.5.3 → buildz-0.5.5}/buildz/xf/xargs.py +0 -0
  137. {buildz-0.5.3 → buildz-0.5.5}/buildz.egg-info/dependency_links.txt +0 -0
  138. {buildz-0.5.3 → buildz-0.5.5}/buildz.egg-info/top_level.txt +0 -0
  139. {buildz-0.5.3 → buildz-0.5.5}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: buildz
3
- Version: 0.5.3
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.5
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}")
@@ -2,6 +2,6 @@
2
2
  #author:
3
3
  from .dirz import dirs, FileDeal
4
4
  from .lsf import lists, search
5
- from .fio import fread, freads, fwrite, fwrites, read,reads,write,writes
5
+ from .fio import fread, freads, fwrite, fwrites, read,reads,write,writes, makefdir
6
6
 
7
7
  __author__ = "Zzz, emails: 1174534295@qq.com, 1309458652@qq.com"
@@ -1,5 +1,5 @@
1
1
  #coding=utf-8
2
-
2
+ import os
3
3
  """
4
4
  读写文件再简化
5
5
  """
@@ -20,16 +20,26 @@ 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)
33
33
 
34
34
  pass
35
- writes = fwrites
35
+ writes = fwrites
36
+
37
+ def makefdir(fp):
38
+ fp = os.path.abspath(fp)
39
+ dp = os.path.dirname(fp)
40
+ if os.path.isdir(dp):
41
+ return
42
+ os.makedirs(dp)
43
+
44
+ pass
45
+
@@ -77,6 +77,11 @@
77
77
  type: deal,
78
78
  note: 扩展的自定义deal方法,
79
79
  build: buildz.ioc.ioc_deal.deal.DealDeal
80
+ },
81
+ {
82
+ type: iocf,
83
+ note: 加配置文件,
84
+ build: buildz.ioc.ioc_deal.iocf.IOCFObjectDeal
80
85
  }
81
86
  ]
82
87
  }
@@ -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
  ]
@@ -16,11 +16,7 @@
16
16
  },
17
17
  {
18
18
  nullable: 0,
19
- key: key
20
- },
21
- {
22
- nullable: 1,
23
- key: info
19
+ key: filepath
24
20
  }
25
21
  ]
26
22
  }
@@ -0,0 +1,31 @@
1
+ // [[id, type], key]
2
+ // [type, key]
3
+ {
4
+ sort: 1
5
+ data: [
6
+ {
7
+ nullable: 0,
8
+ out: 1,
9
+ conf: {
10
+ sort: -1,
11
+ data:[
12
+ {key: id, default: null},
13
+ {key: type, default: null}
14
+ ]
15
+ }
16
+ },
17
+ {
18
+ nullable: 0,
19
+ key: key
20
+ },
21
+ {
22
+ nullable: 1,
23
+ key: info
24
+ conf: {
25
+ data: [
26
+ {key: lid, default: null}
27
+ ]
28
+ }
29
+ }
30
+ ]
31
+ }
@@ -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
@@ -0,0 +1,59 @@
1
+ #coding=utf-8
2
+ from ..ioc.base import Base, EncapeData
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 IOCFObjectDeal(FormatDeal):
9
+ """
10
+ iocf字段ioc:
11
+ {
12
+ id:id
13
+ type: iocf
14
+
15
+ filepath: item_conf
16
+ // or
17
+ folder: item_conf
18
+ pattern: item_conf
19
+ }
20
+ 简写:
21
+ [[id, ioc], filepath]
22
+ 例:
23
+ [iocf, filepath] //
24
+ """
25
+ def init(self, fp_lists=None, fp_defaults=None):
26
+ self.fps = set()
27
+ self.ids = set()
28
+ super().init("IOCFObjectDeal", fp_lists, fp_defaults, join(dp, "conf", "iocf_lists.js"), None)
29
+ def deal(self, edata:EncapeData):
30
+ data = edata.data
31
+ id = xf.g(data, id = None)
32
+ data = self.fill(data)
33
+ if id is not None:
34
+ if id in self.ids:
35
+ return None
36
+ else:
37
+ self.ids.add(id)
38
+ fp = xf.g(data, filepath = None)
39
+ fdir = xf.g(data, folder = None)
40
+ pt = xf.g(data, pattern = None)
41
+ if fp is None:
42
+ if fdir is None:
43
+ raise Exception("filepath can't be null")
44
+ else:
45
+ fdir = self.get_obj(fdir, edata.conf)
46
+ if pt is not None:
47
+ pt = self.get_obj(pt, edata.conf)
48
+ fps = fz.search(fdir, pt)
49
+ else:
50
+ fp = self.get_obj(fp, edata.conf)
51
+ fps = [fp]
52
+ fps = [k for k in fps if k not in self.fps]
53
+ if len(fps)==0:
54
+ return None
55
+ edata.conf.confs.add_fps(fps)
56
+ self.fps.update(fp)
57
+ return None
58
+
59
+ pass
@@ -29,7 +29,7 @@ class MapDeal(FormatDeal):
29
29
  conf = edata.conf
30
30
  data = self.fill(data)
31
31
  maps = xf.g(data, data={})
32
- rst = {k:self.get_obj(map[k], conf, edata.src, edata.info) for k in maps}
32
+ rst = {k:self.get_obj(maps[k], conf, edata.src, edata.info) for k in maps}
33
33
  return rst
34
34
 
35
35
  pass
@@ -102,16 +102,18 @@ class ObjectDeal(FormatDeal):
102
102
  single = 1
103
103
  ids = None
104
104
  if single or cid is not None:
105
- if single:
106
- ids = [sid, id]
105
+ if cid is not None:
106
+ ids = [sid, 'local_id', id, cid]
107
107
  else:
108
- ids = [sid, id, cid]
108
+ ids = [sid, 'single', id]
109
109
  if ids is not None:
110
110
  obj = xf.gets(self.singles, ids)
111
111
  if obj is not None:
112
112
  #raise IOCError(f"null for {ids}")
113
113
  return obj
114
114
  source = xf.g(data, source=0)
115
+ if source == 0:
116
+ raise Exception(f"define object without 'source' key, {data}")
115
117
  fc = xf.get(self.sources, source, None)
116
118
  if fc is None:
117
119
  fc = pyz.load(source)
@@ -131,6 +133,7 @@ class ObjectDeal(FormatDeal):
131
133
  xf.sets(self.singles, ids, obj)
132
134
  prev_call = xf.g(data, prev_call=None)
133
135
  if prev_call is not None:
136
+ # TODO: 这边info透传好像会有问题
134
137
  self.get_obj(prev_call, conf, obj, edata.info)
135
138
  sets = xf.g(data, sets=[])
136
139
  for kv in sets:
@@ -28,8 +28,10 @@ class RefDeal(FormatDeal):
28
28
  data = self.fill(data)
29
29
  key = data['key']
30
30
  info = xf.g(data, info=None)
31
- if info is not None:
32
- info = self.get_obj(info, src = edata.src)
31
+ if info is not None and type(info)==dict:
32
+ #info = {k:self.get_obj(info, edata.conf, src = edata.src) for k in info}
33
+ info = {'type':'map', 'data':info}
34
+ info = self.get_obj(info, edata.conf, src = edata.src)
33
35
  return edata.conf.get_obj(key, info = info, src = edata.src)
34
36
 
35
37
  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
 
@@ -1,6 +1,16 @@
1
1
 
2
2
  import sys
3
3
  import os
4
+ def test_current(fp, up = 1):
5
+ """
6
+ 将当前目录的上{up}层目录加入sys.path,这样可以在同层写测试代码,但是import还是要当在上{up}层做import
7
+ """
8
+ dp = os.path.dirname(os.path.abspath(fp))
9
+ for i in range(up):
10
+ dp = os.path.dirname(dp)
11
+ sys.path.insert(0, dp)
12
+
13
+ pass
4
14
  def load(md, fc = None):
5
15
  """
6
16
  import object(whether module or others) from md(or md.fc)
@@ -1,7 +1,9 @@
1
1
  #coding=utf-8
2
-
2
+ import os
3
3
  coding="utf-8"
4
4
  def bread(filepath):
5
+ if type(filepath) not in [str, bytes, os.PathLike]:
6
+ raise Exception(f"error filepath: {filepath}")
5
7
  with open(filepath, 'rb') as file:
6
8
  s = file.read()
7
9
  return s
@@ -40,7 +42,7 @@ def fread_c(filepath, coding = 'utf-8'):
40
42
 
41
43
  pass
42
44
 
43
- def fwrite(filepath, content, mode = 'w'):
45
+ def fwrite(content, filepath, mode = 'w'):
44
46
  with open(filepath, mode) as f:
45
47
  f.write(content)
46
48
 
@@ -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:
@@ -52,7 +52,7 @@ class PrevStrDeal(lr.LRDeal):
52
52
  return False
53
53
  rm = buffer.full().strip()
54
54
  buffer.clean2read(self.ll)
55
- if len(rm)>0 and not self.note:
55
+ if len(rm)>0:
56
56
  if not self.note:
57
57
  print("left:", self.left, rm)
58
58
  print(f"rst: [{rst}]")
@@ -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:
@@ -63,7 +63,7 @@ class Manager:
63
63
  rst = deal.build(obj)
64
64
  if rst is not None:
65
65
  return rst
66
- raise Exception("unspt deal type:"+_type)
66
+ raise Exception(f"unspt deal type:[{obj}]")
67
67
  def deal(self, buffer, arr):
68
68
  c = buffer.read()
69
69
  if len(c)==0 and buffer.size()==0:
@@ -1,9 +1,43 @@
1
1
 
2
- def get(obj, key, default=None):
2
+ def get(obj, key, default=None, set = False):
3
3
  if key not in obj:
4
+ if set:
5
+ obj[key] = default
4
6
  return default
5
7
  return obj[key]
6
8
 
9
+ pass
10
+ def getf(obj, key, fc):
11
+ if key not in obj:
12
+ return fc()
13
+ return obj[key]
14
+
15
+ pass
16
+ def gfn(obj, **maps):
17
+ rst = []
18
+ for k in maps:
19
+ if k in obj and obj[k] is not None:
20
+ v = obj[k]
21
+ else:
22
+ v = maps[k]()
23
+ rst.append(v)
24
+ if len(rst)==1:
25
+ rst = rst[0]
26
+ return rst
27
+
28
+ pass
29
+ def gf(obj, **maps):
30
+ rst = []
31
+ for k in maps:
32
+ if k in obj:
33
+ v = obj[k]
34
+ else:
35
+ v = maps[k]()
36
+ rst.append(v)
37
+ if len(rst)==1:
38
+ rst = rst[0]
39
+ return rst
40
+
7
41
  pass
8
42
  def g(obj, **maps):
9
43
  rst = []
@@ -16,6 +50,20 @@ def g(obj, **maps):
16
50
  rst = rst[0]
17
51
  return rst
18
52
 
53
+ pass
54
+ def gs(obj, **maps):
55
+ rst = []
56
+ for k in maps:
57
+ v = maps[k]
58
+ if k in obj:
59
+ v = obj[k]
60
+ else:
61
+ obj[k] = v
62
+ rst.append(v)
63
+ if len(rst)==1:
64
+ rst = rst[0]
65
+ return rst
66
+
19
67
  pass
20
68
  def s(obj, **maps):
21
69
  for k in maps:
@@ -78,7 +126,7 @@ pass
78
126
  def deep_update(target, src, replace=1):
79
127
  """
80
128
  dict深层更新,src[key]是dict就深入更新,否则:
81
- src有而maps没有就替换,否则:
129
+ src有而target没有就替换,否则:
82
130
  replace=1就替换
83
131
  """
84
132
  for k in src:
@@ -93,4 +141,5 @@ def deep_update(target, src, replace=1):
93
141
  if replace:
94
142
  target[k] = val
95
143
 
96
- pass
144
+ pass
145
+ update = deep_update
@@ -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.3
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.5
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
  ```
@@ -47,6 +47,7 @@ buildz/ioc/ioc_deal/deal.py
47
47
  buildz/ioc/ioc_deal/demo.py
48
48
  buildz/ioc/ioc_deal/env.py
49
49
  buildz/ioc/ioc_deal/ioc.py
50
+ buildz/ioc/ioc_deal/iocf.py
50
51
  buildz/ioc/ioc_deal/join.py
51
52
  buildz/ioc/ioc_deal/list.py
52
53
  buildz/ioc/ioc_deal/map.py
@@ -65,6 +66,7 @@ buildz/ioc/ioc_deal/conf/deal_lists.js
65
66
  buildz/ioc/ioc_deal/conf/deals.js
66
67
  buildz/ioc/ioc_deal/conf/env_lists.js
67
68
  buildz/ioc/ioc_deal/conf/ioc_lists.js
69
+ buildz/ioc/ioc_deal/conf/iocf_lists.js
68
70
  buildz/ioc/ioc_deal/conf/join_lists.js
69
71
  buildz/ioc/ioc_deal/conf/list_lists.js
70
72
  buildz/ioc/ioc_deal/conf/map_lists.js
@@ -7,11 +7,11 @@ from setuptools import setup, find_packages
7
7
 
8
8
  setup(
9
9
  name = 'buildz',
10
- version = '0.5.3',
10
+ version = '0.5.5',
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',
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