buildz 0.5.6__tar.gz → 0.5.8__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 (146) hide show
  1. {buildz-0.5.6/buildz.egg-info → buildz-0.5.8}/PKG-INFO +1 -1
  2. {buildz-0.5.6 → buildz-0.5.8}/buildz/argx.py +21 -0
  3. buildz-0.5.8/buildz/cmd.py +78 -0
  4. {buildz-0.5.6 → buildz-0.5.8}/buildz/fz/__init__.py +3 -2
  5. buildz-0.5.8/buildz/fz/dirz.py +74 -0
  6. buildz-0.5.8/buildz/fz/fhs.py +17 -0
  7. {buildz-0.5.6 → buildz-0.5.8}/buildz/fz/fio.py +30 -3
  8. buildz-0.5.8/buildz/fz/lsf.py +113 -0
  9. buildz-0.5.8/buildz/ioc/base.py +5 -0
  10. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc/base.py +12 -8
  11. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc/conf.py +11 -0
  12. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc/confs.py +5 -1
  13. buildz-0.5.8/buildz/ioc/ioc/single.py +56 -0
  14. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/base.py +11 -0
  15. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/calls.py +1 -1
  16. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/var_lists.js +1 -1
  17. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/env.py +1 -1
  18. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/ioc.py +1 -1
  19. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/join.py +1 -1
  20. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/list.py +1 -1
  21. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/map.py +1 -1
  22. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/obj.py +11 -6
  23. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/ref.py +1 -1
  24. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/val.py +2 -2
  25. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/var.py +4 -4
  26. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/listz.py +1 -0
  27. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/mapz.py +1 -0
  28. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/nextz.py +3 -2
  29. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/spc.py +1 -1
  30. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/strz.py +99 -3
  31. buildz-0.5.8/buildz/xf/loaderz/test1.py +7 -0
  32. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/mapz.py +39 -0
  33. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/readz.py +3 -1
  34. {buildz-0.5.6 → buildz-0.5.8/buildz.egg-info}/PKG-INFO +1 -1
  35. {buildz-0.5.6 → buildz-0.5.8}/buildz.egg-info/SOURCES.txt +3 -0
  36. {buildz-0.5.6 → buildz-0.5.8}/setup.py +1 -1
  37. buildz-0.5.6/buildz/fz/dirz.py +0 -46
  38. buildz-0.5.6/buildz/fz/lsf.py +0 -65
  39. buildz-0.5.6/buildz/ioc/base.py +0 -4
  40. buildz-0.5.6/buildz/xf/loaderz/test1.py +0 -7
  41. {buildz-0.5.6 → buildz-0.5.8}/LICENSE +0 -0
  42. {buildz-0.5.6 → buildz-0.5.8}/MANIFEST.in +0 -0
  43. {buildz-0.5.6 → buildz-0.5.8}/README.md +0 -0
  44. {buildz-0.5.6 → buildz-0.5.8}/buildz/__init__.py +0 -0
  45. {buildz-0.5.6 → buildz-0.5.8}/buildz/__main__.py +0 -0
  46. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/ioc/deal.py +0 -0
  47. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/ioc/help.py +0 -0
  48. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/myers/deal.py +0 -0
  49. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/myers/help.py +0 -0
  50. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/conf/ioc.js +0 -0
  51. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/conf/main.js +0 -0
  52. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/conf/myers.js +0 -0
  53. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/conf/search.js +0 -0
  54. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/conf/xf.js +0 -0
  55. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/help/default.js +0 -0
  56. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/help/ioc.js +0 -0
  57. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/help/myers.js +0 -0
  58. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/help/search.js +0 -0
  59. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/help/xf.js +0 -0
  60. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/res/test.js +0 -0
  61. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/search/deal.py +0 -0
  62. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/search/help.py +0 -0
  63. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/test.py +0 -0
  64. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/xf/deal.py +0 -0
  65. {buildz-0.5.6 → buildz-0.5.8}/buildz/demo/xf/help.py +0 -0
  66. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/__init__.py +0 -0
  67. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/init.py +0 -0
  68. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/call.py +0 -0
  69. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
  70. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
  71. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
  72. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
  73. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/deal_lists.js +0 -0
  74. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/deals.js +0 -0
  75. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
  76. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
  77. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/iocf_lists.js +0 -0
  78. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
  79. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
  80. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
  81. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
  82. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
  83. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
  84. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
  85. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
  86. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
  87. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
  88. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/ref_lists.js +0 -0
  89. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/xfile_defaults.js +0 -0
  90. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/conf/xfile_lists.js +0 -0
  91. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/deal.py +0 -0
  92. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/demo.py +0 -0
  93. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/iocf.py +0 -0
  94. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/mcall.py +0 -0
  95. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/ovar.py +0 -0
  96. {buildz-0.5.6 → buildz-0.5.8}/buildz/ioc/ioc_deal/xfile.py +0 -0
  97. {buildz-0.5.6 → buildz-0.5.8}/buildz/pyz.py +0 -0
  98. {buildz-0.5.6 → buildz-0.5.8}/buildz/tz/__init__.py +0 -0
  99. {buildz-0.5.6 → buildz-0.5.8}/buildz/tz/myers_diff.py +0 -0
  100. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/__init__.py +0 -0
  101. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/__main__.py +0 -0
  102. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/file.py +0 -0
  103. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/base.py +0 -0
  104. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/buffer.py +0 -0
  105. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/listz.py +0 -0
  106. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/lr.py +0 -0
  107. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/lrval.py +0 -0
  108. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/mapz.py +0 -0
  109. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/nextz.py +0 -0
  110. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/reval.py +0 -0
  111. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/setz.py +0 -0
  112. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/spc.py +0 -0
  113. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/spt.py +0 -0
  114. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/deal/strz.py +0 -0
  115. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/exp.py +0 -0
  116. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/item.py +0 -0
  117. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/mg.py +0 -0
  118. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loader/pos.py +0 -0
  119. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/base.py +0 -0
  120. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/buffer.py +0 -0
  121. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/lr.py +0 -0
  122. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/lrval.py +0 -0
  123. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/reval.py +0 -0
  124. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/setz.py +0 -0
  125. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/deal/spt.py +0 -0
  126. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/exp.py +0 -0
  127. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/item.py +0 -0
  128. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/mg.py +0 -0
  129. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/pos.py +0 -0
  130. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/loaderz/test.py +0 -0
  131. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/read.py +0 -0
  132. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/stack.py +0 -0
  133. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/write.py +0 -0
  134. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/writer/base.py +0 -0
  135. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/writer/conf.py +0 -0
  136. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/writer/deal/jsonval.py +0 -0
  137. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/writer/deal/listz.py +0 -0
  138. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/writer/deal/mapz.py +0 -0
  139. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/writer/deal/reval.py +0 -0
  140. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/writer/deal/strz.py +0 -0
  141. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/writer/itemz.py +0 -0
  142. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/writer/mg.py +0 -0
  143. {buildz-0.5.6 → buildz-0.5.8}/buildz/xf/xargs.py +0 -0
  144. {buildz-0.5.6 → buildz-0.5.8}/buildz.egg-info/dependency_links.txt +0 -0
  145. {buildz-0.5.6 → buildz-0.5.8}/buildz.egg-info/top_level.txt +0 -0
  146. {buildz-0.5.6 → buildz-0.5.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: buildz
3
- Version: 0.5.6
3
+ Version: 0.5.8
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
@@ -15,8 +15,24 @@ class Fetch:
15
15
  就是对引号不太适用
16
16
  """
17
17
  def __init__(self, args = [], maps ={}):
18
+ args = [maps[k] if k in maps else k for k in args]
18
19
  self.args = args
19
20
  self.maps = maps
21
+ def des(self):
22
+ cmd = " ".join(self.args)
23
+ adds = []
24
+ for k, val in self.maps.items():
25
+ tmp = f" [-{k} param] [--{val}=param]"
26
+ adds.append(tmp)
27
+ adds = [cmd]+adds
28
+ rs = "\n".join(adds)
29
+ return rs
30
+ def check(self, args, ks):
31
+ rst = []
32
+ for k in ks:
33
+ if k not in args:
34
+ rst.append(k)
35
+ return rst
20
36
  def __call__(self, argv = None):
21
37
  args, maps = fetch(argv)
22
38
  rst = {}
@@ -35,6 +51,11 @@ class Fetch:
35
51
  del rst[key]
36
52
  return rst
37
53
 
54
+ pass
55
+ class FetchX(Fetch):
56
+ def __init__(self, *a, **b):
57
+ super().__init__(a,b)
58
+
38
59
  pass
39
60
  def fetch(argv = None):
40
61
  r"""
@@ -0,0 +1,78 @@
1
+ #coding=utf-8
2
+ from . import xf
3
+ class Cmd:
4
+ def close(self):
5
+ self.running = False
6
+ def __init__(self, obj):
7
+ self.running = False
8
+ self.obj = obj
9
+ self.tmp = None
10
+ self.exits = "exit,close,quit".split(",")
11
+ def __call__(self):
12
+ self.run()
13
+ def doc(self, *arr):
14
+ if len(arr)>0:
15
+ rfc = getattr(self.obj, arr[0])
16
+ else:
17
+ rfc = self.obj
18
+ return rfc.__doc__
19
+ def help(self, *arr):
20
+ if len(arr)>0:
21
+ rfc = getattr(self.obj, arr[0])
22
+ else:
23
+ rfc = self.obj
24
+ help(rfc)
25
+ def dir(self, *arr):
26
+ if len(arr)>0:
27
+ rfc = getattr(self.obj, arr[0])
28
+ else:
29
+ rfc = self.obj
30
+ arr = rfc.__dir__()
31
+ arr = [k for k in arr if k[:2]!="__"]
32
+ return arr
33
+ def dict(self, *arr):
34
+ if len(arr)>0:
35
+ rfc = getattr(self.obj, arr[0])
36
+ else:
37
+ rfc = self.obj
38
+ return rfc.__dict__
39
+ def get(self, *arr):
40
+ if len(arr)>0:
41
+ return getattr(self.obj, arr[0])
42
+ return self.obj
43
+ def set(self, key, val):
44
+ setattr(self.obj,key, val)
45
+ return getattr(self.obj, key)
46
+ def run(self):
47
+ self.running = True
48
+ while self.running:
49
+ s = input(":").strip()
50
+ if s.strip()=="":
51
+ continue
52
+ if s in self.exits:
53
+ break
54
+ try:
55
+ arr = xf.loads(s)
56
+ if type(arr)!=list:
57
+ if type(arr)==dict:
58
+ rst = []
59
+ for k,v in arr.items():
60
+ rst+=[k,v]
61
+ arr = rst
62
+ else:
63
+ arr = [arr]
64
+ fc = arr[0]
65
+ if not hasattr(self.obj, fc):
66
+ fc = fc.split(".")[-1]
67
+ fc = getattr(self, fc)
68
+ else:
69
+ fc = getattr(self.obj, fc)
70
+ params = arr[1:]
71
+ tmp = fc(*params)
72
+ print(tmp)
73
+ except Exception as exp:
74
+ import traceback
75
+ print(f"error:{exp}")
76
+ traceback.print_exc()
77
+
78
+ pass
@@ -1,7 +1,8 @@
1
1
  #coding=utf-8
2
2
  #author:
3
3
  from .dirz import dirs, FileDeal
4
- from .lsf import lists, search
5
- from .fio import fread, freads, fwrite, fwrites, read,reads,write,writes, makefdir
4
+ from .lsf import lists, search, searchd,searchs,_search
5
+ from .fio import fread, freads, fwrite, fwrites, read,reads,write,writes, makefdir, dirpath,makedir,removes
6
+ from .fhs import fhash
6
7
 
7
8
  __author__ = "Zzz, emails: 1174534295@qq.com, 1309458652@qq.com"
@@ -0,0 +1,74 @@
1
+ #coding=utf-8
2
+ import os
3
+ class FileInfo:
4
+ def __repr__(self):
5
+ return self.__str__()
6
+ def __str__(self):
7
+ return f"<path='{self.path}', rpath='{self.rpath}' isdir={self.isdir}>"
8
+ def __init__(self, path, rpath, base_dir, isdir, empty_dir=False, visit_dir = False):
9
+ self.path = path
10
+ self.rpath = rpath
11
+ self.base_dir = base_dir
12
+ self.isdir = isdir
13
+ self.empty_dir = empty_dir
14
+ self.visit_dir = visit_dir
15
+
16
+ pass
17
+ #列出文件夹下所有文件和文件更新时间
18
+ #文件访问处理方法
19
+ #建议visit读取文件
20
+ #catch处理目录访问异常
21
+ class FileDeal:
22
+ def __init__(self, *argv, **maps):
23
+ self.init(*argv, **maps)
24
+ def result(self):
25
+ return None
26
+ def init(self, *argv, **maps):
27
+ pass
28
+ def work(self, *argv, **maps):
29
+ return self.dirs(*argv, **maps)
30
+ def dirs(self, filepath, depth = 0):
31
+ dirs(filepath, self, depth)
32
+ return self.result()
33
+ def visit(self, fileinfo, depth):
34
+ return True
35
+ def catch(self, filepinfo, depth, exp):
36
+ pass
37
+ def deal(self, filepinfo, depth, exp = None):
38
+ if exp is None:
39
+ return self.visit(filepinfo, depth)
40
+ else:
41
+ return self.catch(filepinfo, depth, exp)
42
+ def __call__(self, *argv, **maps):
43
+ return self.deal(*argv, **maps)
44
+
45
+ pass
46
+ #遍历文件/文件夹filepath
47
+ def dirs(filepath, fc=FileDeal(), depth = 0, base_dir = None, rpath = None):
48
+ if base_dir is None:
49
+ base_dir = filepath
50
+ if rpath is None:
51
+ rpath = ""
52
+ isdir = os.path.isdir(filepath)
53
+ finfo = FileInfo(filepath, rpath, base_dir, isdir)
54
+ visit = fc(finfo, depth)
55
+ if isdir and visit:
56
+ try:
57
+ files = os.listdir(filepath)
58
+ except Exception as exp:
59
+ finfo = FileInfo(filepath, rpath, base_dir, isdir, False, True)
60
+ fc(finfo, depth, exp)
61
+ return
62
+ if len(files)==0:
63
+ finfo = FileInfo(filepath, rpath, base_dir, isdir, True, True)
64
+ fc(finfo, depth)
65
+ files = [
66
+ [
67
+ os.path.join(filepath, file),
68
+ os.path.join(rpath, file)
69
+ ]
70
+ for file in files]
71
+ [dirs(fp[0], fc, depth+1, base_dir, fp[1]) for fp in files]
72
+
73
+ pass
74
+
@@ -0,0 +1,17 @@
1
+ #coding=utf-8
2
+
3
+ import hashlib
4
+
5
+ #计算文件hash值
6
+ def fhash(fp, hm="sha256", blk_sz = 10240):
7
+ if type(hm) == str:
8
+ hm = getattr(hashlib, hm)()
9
+ with open(fp, 'rb') as f:
10
+ while True:
11
+ bs = f.read(blk_sz)
12
+ if len(bs)==0:
13
+ break
14
+ hm.update(bs)
15
+ return hm.hexdigest()
16
+
17
+ pass
@@ -34,12 +34,39 @@ def fwrites(cts, fp, mode = 'wb'):
34
34
  pass
35
35
  writes = fwrites
36
36
 
37
- def makefdir(fp):
38
- fp = os.path.abspath(fp)
39
- dp = os.path.dirname(fp)
37
+ def makedir(dp):
40
38
  if os.path.isdir(dp):
41
39
  return
42
40
  os.makedirs(dp)
43
41
 
44
42
  pass
43
+ def makefdir(fp):
44
+ fp = os.path.abspath(fp)
45
+ dp = os.path.dirname(fp)
46
+ makedir(dp)
47
+
48
+ pass
49
+
50
+ def dirpath(fp, n=1):
51
+ for i in range(n):
52
+ fp = os.path.dirname(fp)
53
+ return fp
54
+
55
+ pass
56
+
57
+ dirname = dirpath
58
+
59
+ def removes(fp):
60
+ if not os.path.exists(fp):
61
+ return
62
+ if os.path.isfile(fp):
63
+ #print(f"remove file '{fp}'")
64
+ os.remove(fp)
65
+ return
66
+ fps = os.listdir(fp)
67
+ fps = [os.path.join(fp, f) for f in fps]
68
+ [removes(f) for f in fps]
69
+ #print(f"removedirs '{fp}'")
70
+ os.rmdir(fp)
45
71
 
72
+ pass
@@ -0,0 +1,113 @@
1
+ #coding=utf-8
2
+
3
+ from . import dirz
4
+
5
+ import re
6
+ class ListsDeal(dirz.FileDeal):
7
+ def result(self):
8
+ return self.fps, self.errors
9
+ def init(self):
10
+ super().init()
11
+ self.fps = []
12
+ self.errors = []
13
+ def visit(self, finfo, depth):
14
+ fp, isdir = finfo.path, finfo.isdir
15
+ self.fps.append([fp, isdir])
16
+ return True
17
+ def catch(self, finfo, depth, exp):
18
+ fp, isdir = finfo.path, finfo.isdir
19
+ self.errors.append([fp, isdir, exp])
20
+
21
+ pass
22
+
23
+ class SearchDeal(dirz.FileDeal):
24
+ def init(self, pt_fp=None, pt = None, pt_dp = None, depth = None, relative = False):
25
+ super().init()
26
+ self.pt_fp = pt_fp
27
+ self.pt_dp = pt_dp
28
+ if type(pt) == str:
29
+ pt = pt.encode()
30
+ self.pt = pt
31
+ self.rst = []
32
+ self.errs = []
33
+ self.depth = depth
34
+ self.relative = relative
35
+ def fps(self, keep_dir = False, relative = None, fp_only = True):
36
+ if relative is None:
37
+ relative = self.relative
38
+ rst = self.rst
39
+ if relative:
40
+ rst = [[i.rpath, i.isdir] for i in rst]
41
+ else:
42
+ rst = [[i.path, i.isdir] for i in rst]
43
+ if not keep_dir:
44
+ rst = [k for k in rst if not k[1]]
45
+ if fp_only:
46
+ rst = [k[0] for k in rst]
47
+ return rst
48
+ def result(self):
49
+ return self.rst
50
+ def visit(self, finfo, depth):
51
+ if self.depth is not None and depth > self.depth:
52
+ return False
53
+ filepath = finfo.path
54
+ isdir = finfo.isdir
55
+ if self.relative:
56
+ filepath = finfo.rpath
57
+ if isdir:
58
+ if finfo.empty_dir or depth==self.depth:
59
+ if self.pt_dp is not None and len(re.findall(self.pt_dp, filepath))==0:
60
+ return True
61
+ self.rst.append(finfo)
62
+ return True
63
+ if self.pt_fp is not None and len(re.findall(self.pt_fp, filepath))==0:
64
+ return False
65
+ if self.pt is not None:
66
+ try:
67
+ with open(filepath, 'rb') as f:
68
+ s = f.read()
69
+ except Exception as exp:
70
+ self.catch(finfo, depth, exp)
71
+ return False
72
+ if len(re.findall(self.pt, s))==0:
73
+ return False
74
+ self.rst.append(finfo)
75
+ return False
76
+ def catch(self, finfo, depth, exp):
77
+ filepath = finfo.path
78
+ if self.relative:
79
+ filepath = finfo.rpath
80
+ print(f"exp in {finfo}: {exp}")
81
+ self.errs.append([finfo, exp])
82
+ pass
83
+
84
+ pass
85
+
86
+ def lists(fp):
87
+ return ListsDeal().dirs(fp)
88
+
89
+ pass
90
+ def _search(dp, pt_fp = None, pt = None, pt_dp = None, depth=None, relative = False):
91
+ deal = SearchDeal(pt_fp, pt, pt_dp, depth,relative)
92
+ return deal.dirs(dp)
93
+
94
+ pass
95
+ def searchs(dp, pt_fp = None, pt = None, pt_dp = None, depth=None, relative = False):
96
+ deal = SearchDeal(pt_fp, pt, pt_dp, depth,relative)
97
+ deal.dirs(dp)
98
+ return deal.fps(keep_dir=True, fp_only=False)
99
+
100
+ pass
101
+ def searchd(dp, pt_fp = None, pt = None, pt_dp = None, depth=None, relative = False):
102
+ deal = SearchDeal(pt_fp, pt, pt_dp, depth,relative)
103
+ deal.dirs(dp)
104
+ return deal.fps(keep_dir=True, fp_only=True)
105
+
106
+ pass
107
+
108
+ def search(dp, pt_fp = None, pt = None, depth=None, relative = False):
109
+ deal = SearchDeal(pt_fp, pt, None, depth,relative)
110
+ deal.dirs(dp)
111
+ return deal.fps(keep_dir=False, fp_only=True)
112
+
113
+ pass
@@ -0,0 +1,5 @@
1
+ #coding=utf-8
2
+
3
+ from .ioc.base import *
4
+ from .ioc_deal.base import BaseDeal, FormatDeal
5
+ from .ioc.single import Single
@@ -37,17 +37,21 @@ class EncapeData(Base):
37
37
  info: 额外的调用信息,目前只有object会用到里面的id字段,作为单例额外输入
38
38
  """
39
39
  if typez(data)==dict:
40
- pid = xf.g(data, parent=None)
40
+ pid = xf.g1(data, parent=None)
41
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
42
  data = dict(data)
49
- self.update_maps(data, pdt, replace=0)
50
43
  del data['parent']
44
+ pids = pid
45
+ if typez(pids)!=list:
46
+ pids = [pid]
47
+ for pid in pids:
48
+ pedt = conf.get_data(pid, local=True, search_confs = True,src = src, info = info)
49
+ if pedt is None:
50
+ raise IOCError("unfind parend: "+pid)
51
+ pdt = pedt.data
52
+ if typez(pdt)!=dict:
53
+ raise IOCError("only dict can be a parent: "+pid)
54
+ self.update_maps(data, pdt, replace=0)
51
55
  self.data = data
52
56
  self.sid = conf.id
53
57
  self.src = src
@@ -133,8 +133,19 @@ class Conf(Base):
133
133
  if not search_confs:
134
134
  return None
135
135
  return self.confs.get_deal(type, self.id)
136
+ def get_data_conf(self, data, src = None, info = None):
137
+ if type(data) not in [list, dict, tuple]:
138
+ i = self.confs.data_index_type[0]
139
+ data = [self.default_type(), data]
140
+ if i != 0:
141
+ data.reverse()
142
+ _type = self.confs.get_data_type(data, 1, self.default_type())
143
+ edata = EncapeData(data, self, local=True, type=_type, src = src, info = info)
144
+ return edata
136
145
  def get_data(self, id, local = True, search_confs = True, src = None, info = None):
137
146
  self.do_init()
147
+ if type(id) in [list, tuple, dict]:
148
+ return self.get_data_conf(id, src, info)
138
149
  if id in self.datas:
139
150
  obj = self.datas[id]
140
151
  edata = EncapeData(obj, self, local = False, src=src, info = info)
@@ -285,7 +285,11 @@ class Confs(Base):
285
285
  for fp in fps:
286
286
  self.add_fp(fp)
287
287
  def add_fp(self, fp):
288
- conf = self.loads(xf.fread(fp))
288
+ try:
289
+ conf = self.loads(xf.fread(fp))
290
+ except:
291
+ print(f'error in loads: {fp}')
292
+ raise
289
293
  return self.add(conf)
290
294
  def adds(self, confs):
291
295
  for conf in confs:
@@ -0,0 +1,56 @@
1
+ #coding=utf-8
2
+ from .base import Base, EncapeData,IOCError
3
+ from buildz import xf, pyz
4
+ import os
5
+ dp = os.path.dirname(__file__)
6
+ join = os.path.join
7
+
8
+ class Single(Base):
9
+ """
10
+ virtual deal
11
+ {
12
+ single=1/0
13
+ info: {
14
+ cid: ??
15
+ }
16
+ }
17
+ """
18
+ def init(self, single="single", cid = "id", default=1):
19
+ self.k_cid = cid
20
+ self.k_single = single
21
+ self.default = default
22
+ self.singles = {}
23
+ def get_ids(self, edata: EncapeData):
24
+ sid = edata.sid
25
+ data = edata.data
26
+ info = edata.info
27
+ if type(info) == dict:
28
+ cid = xf.get(info, self.cid, None)
29
+ else:
30
+ cid = None
31
+ id = xf.g(data, id = None)
32
+ single = xf.get(data, self.k_single, None)
33
+ if id is None:
34
+ single = 0
35
+ if single is None:
36
+ single = self.default
37
+ ids = None
38
+ if single or cid is not None:
39
+ if cid is not None:
40
+ ids = [sid, 'local_id', id, cid]
41
+ else:
42
+ ids = [sid, 'single', id]
43
+ return ids
44
+ def get(self, edata:EncapeData):
45
+ ids = self.get_ids(edata)
46
+ if ids is None:
47
+ return None
48
+ obj = xf.gets(self.singles, ids)
49
+ return obj
50
+ def set(self, obj, edata:EncapeData):
51
+ ids = self.get_ids(edata)
52
+ if ids is None:
53
+ return
54
+ xf.sets(self.singles, ids, obj)
55
+
56
+ pass
@@ -123,7 +123,18 @@ class BaseDeal(Base):
123
123
  自己实现的处理类,要实现两个方法:__call__(self, edata:EncapeData)和remove(self, edata:EncapeData)
124
124
  其中remove可以只写个空方法
125
125
  """
126
+ def get_data(self, data, conf, src = None, info = None):
127
+ if type(data) not in [list, dict, tuple]:
128
+ i = conf.confs.data_index_type[0]
129
+ data = [conf.default_type(), data]
130
+ if i != 0:
131
+ data.reverse()
132
+ _type = conf.confs.get_data_type(data, 1, conf.default_type())
133
+ edata = EncapeData(data, conf, local=True, type=_type, src = src, info = info)
134
+ return edata
126
135
  def get_obj(self, data, conf, src = None, info = None):
136
+ edata = self.get_data(data, conf, src, info)
137
+ return edata()
127
138
  if type(data) not in [list, dict, tuple]:
128
139
  i = conf.confs.data_index_type[0]
129
140
  data = [conf.default_type(), data]
@@ -35,7 +35,7 @@ class CallsDeal(FormatDeal):
35
35
  conf = edata.conf
36
36
  data = self.format(data)
37
37
  src = edata.src
38
- calls = xf.g(data, calls=[])
38
+ calls = xf.g1(data, calls=[], data = [])
39
39
  rst = None
40
40
  for call in calls:
41
41
  rst = self.get_obj(call, conf, src)
@@ -13,6 +13,6 @@
13
13
  },
14
14
  {
15
15
  nullable: 0,
16
- key: key
16
+ key: data
17
17
  }
18
18
  ]
@@ -25,7 +25,7 @@ class EnvDeal(FormatDeal):
25
25
  def deal(self, edata:EncapeData):
26
26
  data = edata.data
27
27
  data = self.fill(data)
28
- key = data['key']
28
+ key = xf.get_first(data, 'env', 'key')
29
29
  val = edata.conf.get_env(key)
30
30
  default = xf.g(data, default=None)
31
31
  if val is None and default is not None:
@@ -25,7 +25,7 @@ class IOCObjectDeal(FormatDeal):
25
25
  def deal(self, edata:EncapeData):
26
26
  data = edata.data
27
27
  data = self.fill(data)
28
- key = data['key']
28
+ key = xf.get_first(data, 'ioc', 'key')
29
29
  if not hasattr(edata, key):
30
30
  return None
31
31
  return getattr(edata, key)
@@ -24,7 +24,7 @@ class JoinDeal(FormatDeal):
24
24
  def deal(self, edata:EncapeData):
25
25
  data = edata.data
26
26
  data = self.fill(data)
27
- lists = xf.g(data, data=[])
27
+ lists = xf.g1(data, join = [], data=[])
28
28
  conf = edata.conf
29
29
  rst = [self.get_obj(k, conf, edata.src, edata.info) for k in lists]
30
30
  return join(*rst)
@@ -27,7 +27,7 @@ class ListDeal(FormatDeal):
27
27
  def deal(self, edata:EncapeData):
28
28
  data = edata.data
29
29
  data = self.fill(data)
30
- lists = xf.g(data, data=[])
30
+ lists = xf.g1(data, list = [], data=[])
31
31
  conf = edata.conf
32
32
  rst = [self.get_obj(k, conf, edata.src, edata.info) for k in lists]
33
33
  return rst
@@ -28,7 +28,7 @@ class MapDeal(FormatDeal):
28
28
  data = edata.data
29
29
  conf = edata.conf
30
30
  data = self.fill(data)
31
- maps = xf.g(data, data={})
31
+ maps = xf.g1(data, map = {}, data={})
32
32
  rst = {k:self.get_obj(maps[k], conf, edata.src, edata.info) for k in maps}
33
33
  return rst
34
34
 
@@ -136,12 +136,17 @@ class ObjectDeal(FormatDeal):
136
136
  # TODO: 这边info透传好像会有问题
137
137
  self.get_obj(prev_call, conf, obj, edata.info)
138
138
  sets = xf.g(data, sets=[])
139
- for kv in sets:
140
- kv = self.fmt_set(kv)
141
- k = kv['key']
142
- v = kv['data']
143
- v = self.get_obj(v, conf, obj, edata.info)
144
- setattr(obj, k, v)
139
+ if type(sets)==list:
140
+ for kv in sets:
141
+ kv = self.fmt_set(kv)
142
+ k = kv['key']
143
+ v = xf.get_first(kv, "val", "data")
144
+ v = self.get_obj(v, conf, obj, edata.info)
145
+ setattr(obj, k, v)
146
+ else:
147
+ for k,v in sets.items():
148
+ v = self.get_obj(v, conf, obj, edata.info)
149
+ setattr(obj, k, v)
145
150
  call = xf.g(data, call=None)
146
151
  if call is not None:
147
152
  self.get_obj(call, conf, obj, edata.info)
@@ -26,7 +26,7 @@ class RefDeal(FormatDeal):
26
26
  def deal(self, edata:EncapeData):
27
27
  data = edata.data
28
28
  data = self.fill(data)
29
- key = data['key']
29
+ key = xf.get_first(data, 'ref', 'key')
30
30
  info = xf.g(data, info=None)
31
31
  if info is not None and type(info)==dict:
32
32
  #info = {k:self.get_obj(info, edata.conf, src = edata.src) for k in info}
@@ -1,6 +1,6 @@
1
1
  #
2
2
  from ..ioc.base import Base, EncapeData
3
-
3
+ from buildz import xf
4
4
  class ValDeal(Base):
5
5
  """
6
6
  数据val:
@@ -24,6 +24,6 @@ class ValDeal(Base):
24
24
  data = edata.data
25
25
  if type(data)==list:
26
26
  return data[-1]
27
- return data['data']
27
+ return xf.get_first(data, "val", "data")
28
28
 
29
29
  pass
@@ -11,11 +11,11 @@ class VarDeal(FormatDeal):
11
11
  {
12
12
  id:id
13
13
  type: var
14
- key: string
14
+ data: string
15
15
  }
16
16
  简写:
17
- [[id, var], key]
18
- [var, key]
17
+ [[id, var], data]
18
+ [var, data]
19
19
  例:
20
20
  [var, buildz.pyz.is_windows] // 返回buildz.pyz下的is_windows
21
21
  """
@@ -30,7 +30,7 @@ class VarDeal(FormatDeal):
30
30
  conf = edata.conf
31
31
  data = self.format(data)
32
32
  src = edata.src
33
- key = xf.g(data, key=0)
33
+ key = xf.get_first(data, "var", "data")
34
34
  key = pyz.load(key)
35
35
  return key
36
36