buildz 0.4.4__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.
- buildz-0.4.6/PKG-INFO +35 -0
- buildz-0.4.6/README.md +22 -0
- buildz-0.4.6/buildz/__init__.py +7 -0
- buildz-0.4.6/buildz/__main__.py +6 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/argx.py +26 -2
- buildz-0.4.6/buildz/demo/ioc/deal.py +20 -0
- buildz-0.4.6/buildz/demo/ioc/help.py +42 -0
- buildz-0.4.6/buildz/demo/res/conf/ioc.js +20 -0
- buildz-0.4.6/buildz/demo/res/conf/main.js +58 -0
- buildz-0.4.6/buildz/demo/res/conf/search.js +21 -0
- buildz-0.4.6/buildz/demo/res/conf/xf.js +21 -0
- buildz-0.4.6/buildz/demo/res/help/default.js +20 -0
- buildz-0.4.6/buildz/demo/res/help/ioc.js +39 -0
- buildz-0.4.6/buildz/demo/res/help/search.js +38 -0
- buildz-0.4.6/buildz/demo/res/help/xf.js +34 -0
- buildz-0.4.6/buildz/demo/res/test.js +23 -0
- buildz-0.4.6/buildz/demo/search/deal.py +29 -0
- buildz-0.4.6/buildz/demo/search/help.py +16 -0
- buildz-0.4.6/buildz/demo/test.py +56 -0
- buildz-0.4.6/buildz/demo/xf/deal.py +16 -0
- buildz-0.4.6/buildz/demo/xf/help.py +16 -0
- buildz-0.4.6/buildz/fz/__init__.py +6 -0
- buildz-0.4.6/buildz/fz/dirz.py +46 -0
- buildz-0.4.6/buildz/fz/lsf.py +65 -0
- buildz-0.4.6/buildz/ioc/__init__.py +5 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc/base.py +2 -1
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc/conf.py +52 -7
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc/confs.py +80 -5
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/base.py +12 -4
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/call.py +18 -10
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/calls.py +16 -8
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/deals.js +25 -0
- buildz-0.4.6/buildz/ioc/ioc_deal/conf/join_lists.js +17 -0
- buildz-0.4.6/buildz/ioc/ioc_deal/conf/list_lists.js +17 -0
- buildz-0.4.6/buildz/ioc/ioc_deal/conf/map_lists.js +17 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +1 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/mcall_lists.js +2 -1
- buildz-0.4.6/buildz/ioc/ioc_deal/conf/obj_defaults.js +12 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/obj_lists.js +2 -2
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/ovar_lists.js +1 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/ref_lists.js +4 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/env.py +13 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/ioc.py +14 -0
- buildz-0.4.6/buildz/ioc/ioc_deal/join.py +32 -0
- buildz-0.4.6/buildz/ioc/ioc_deal/list.py +35 -0
- buildz-0.4.6/buildz/ioc/ioc_deal/map.py +35 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/mcall.py +24 -12
- buildz-0.4.6/buildz/ioc/ioc_deal/obj.py +165 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/ovar.py +19 -8
- buildz-0.4.6/buildz/ioc/ioc_deal/ref.py +35 -0
- buildz-0.4.6/buildz/ioc/ioc_deal/val.py +29 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/var.py +11 -7
- buildz-0.4.6/buildz/xf/__init__.py +8 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/strz.py +11 -1
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/mapz.py +38 -1
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/read.py +9 -1
- buildz-0.4.6/buildz.egg-info/PKG-INFO +35 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz.egg-info/SOURCES.txt +26 -45
- {buildz-0.4.4 → buildz-0.4.6}/setup.py +2 -2
- buildz-0.4.4/PKG-INFO +0 -155
- buildz-0.4.4/README.md +0 -142
- buildz-0.4.4/buildz/__init__.py +0 -4
- buildz-0.4.4/buildz/demo/ioc/test.py +0 -43
- buildz-0.4.4/buildz/demo/ioc/test_conf/base.js +0 -9
- buildz-0.4.4/buildz/demo/ioc/test_conf/data1.js +0 -59
- buildz-0.4.4/buildz/demo/ioc/test_conf/data2.js +0 -21
- buildz-0.4.4/buildz/demo/ioc/test_conf/data3.js +0 -21
- buildz-0.4.4/buildz/demo/xf/test.js +0 -12
- buildz-0.4.4/buildz/demo/xf/test.py +0 -13
- buildz-0.4.4/buildz/dj.txt +0 -0
- buildz-0.4.4/buildz/ioc/__init__.py +0 -3
- buildz-0.4.4/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -8
- buildz-0.4.4/buildz/ioc/ioc_deal/obj.py +0 -92
- buildz-0.4.4/buildz/ioc/ioc_deal/ref.py +0 -17
- buildz-0.4.4/buildz/ioc/ioc_deal/val.py +0 -16
- buildz-0.4.4/buildz/keys.py +0 -232
- buildz-0.4.4/buildz/old_version/__init__.py +0 -29
- buildz-0.4.4/buildz/old_version/__main__.py +0 -19
- buildz-0.4.4/buildz/old_version/base.py +0 -88
- buildz-0.4.4/buildz/old_version/build.py +0 -274
- buildz-0.4.4/buildz/old_version/confz.py +0 -501
- buildz-0.4.4/buildz/old_version/demo/x/demo.confz +0 -33
- buildz-0.4.4/buildz/old_version/demo/x/demo.py +0 -20
- buildz-0.4.4/buildz/old_version/demo/x/run.confz +0 -26
- buildz-0.4.4/buildz/old_version/demo/x/test.confz +0 -24
- buildz-0.4.4/buildz/old_version/demo/x/test.py +0 -15
- buildz-0.4.4/buildz/old_version/demo/x/testc.py +0 -18
- buildz-0.4.4/buildz/old_version/demo/x/testf.py +0 -46
- buildz-0.4.4/buildz/old_version/demo/x/testz.py +0 -90
- buildz-0.4.4/buildz/old_version/demo/x/value.confz +0 -19
- buildz-0.4.4/buildz/old_version/demo/x/x.py +0 -14
- buildz-0.4.4/buildz/old_version/keys.py +0 -232
- buildz-0.4.4/buildz/old_version/xconfz/__init__.py +0 -21
- buildz-0.4.4/buildz/old_version/xconfz/base.py +0 -222
- buildz-0.4.4/buildz/old_version/xconfz/buff.py +0 -57
- buildz-0.4.4/buildz/old_version/xconfz/fc.py +0 -8
- buildz-0.4.4/buildz/old_version/xconfz/fc_item.py +0 -88
- buildz-0.4.4/buildz/old_version/xconfz/fc_list.py +0 -85
- buildz-0.4.4/buildz/old_version/xconfz/fc_map.py +0 -91
- buildz-0.4.4/buildz/old_version/xconfz/fc_set.py +0 -60
- buildz-0.4.4/buildz/old_version/xconfz/fc_str.py +0 -80
- buildz-0.4.4/buildz/old_version/xconfz/fc_type.py +0 -100
- buildz-0.4.4/buildz/old_version/xconfz/fmt_base.py +0 -155
- buildz-0.4.4/buildz/old_version/xconfz/fmt_str.py +0 -50
- buildz-0.4.4/buildz/old_version/xconfz/fmt_type.py +0 -86
- buildz-0.4.4/buildz/old_version/xconfz/mg.py +0 -163
- buildz-0.4.4/buildz/old_version/xconfz/mg_fmt.py +0 -145
- buildz-0.4.4/buildz/test_loader copy.py +0 -69
- buildz-0.4.4/buildz/test_loader.py +0 -26
- buildz-0.4.4/buildz/test_writer.py +0 -50
- buildz-0.4.4/buildz/tools.py +0 -39
- buildz-0.4.4/buildz/xf/__init__.py +0 -6
- buildz-0.4.4/buildz/xf/file.py +0 -41
- buildz-0.4.4/buildz.egg-info/PKG-INFO +0 -155
- {buildz-0.4.4 → buildz-0.4.6}/LICENSE +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/MANIFEST.in +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/init.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/ioc/ioc_deal/demo.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/pyz.py +0 -0
- {buildz-0.4.4/buildz/old_version/xconfz → buildz-0.4.6/buildz/xf}/file.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/base.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/buffer.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/listz.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/lr.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/lrval.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/mapz.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/nextz.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/reval.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/setz.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/spc.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/deal/spt.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/exp.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/item.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/mg.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/loader/pos.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/test_write.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/write.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/writer/base.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/writer/conf.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/writer/deal/jsonval.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/writer/deal/listz.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/writer/deal/mapz.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/writer/deal/reval.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/writer/deal/strz.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/writer/itemz.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/writer/mg.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz/xf/xargs.py +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz.egg-info/dependency_links.txt +0 -0
- {buildz-0.4.4 → buildz-0.4.6}/buildz.egg-info/top_level.txt +0 -0
- {buildz-0.4.4 → 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]=="-":
|
@@ -26,21 +28,43 @@ def fetch(argv = None):
|
|
26
28
|
x = kv.split("=")
|
27
29
|
key = x[0]
|
28
30
|
val = "=".join(x[1:])
|
31
|
+
if len(val)==0:
|
32
|
+
val = 1
|
29
33
|
else:
|
30
34
|
key = v[1]
|
31
35
|
if len(v)>2:
|
32
|
-
val =
|
36
|
+
val = v[2:]
|
33
37
|
else:
|
34
38
|
if i+1>=len(argv):
|
35
39
|
val = 1
|
36
40
|
else:
|
37
41
|
val = argv[i+1]
|
38
42
|
i+=1
|
39
|
-
|
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)
|
40
51
|
i+=1
|
52
|
+
for k in maps:
|
53
|
+
v = maps[k]
|
54
|
+
if len(v)==1:
|
55
|
+
maps[k] = v[0]
|
41
56
|
return lists, maps
|
42
57
|
|
43
58
|
pass
|
44
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
|
45
69
|
|
46
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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
datas: [
|
3
|
+
{
|
4
|
+
id: help.ioc
|
5
|
+
type: object
|
6
|
+
source: buildz.demo.ioc.help.Help
|
7
|
+
construct: {
|
8
|
+
maps: {
|
9
|
+
dp: [ref, help.dir]
|
10
|
+
fp: [val, ioc.js]
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
14
|
+
{
|
15
|
+
id: deal.ioc
|
16
|
+
type: object
|
17
|
+
source: buildz.demo.ioc.deal.Deal
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
{
|
2
|
+
datas: [
|
3
|
+
{
|
4
|
+
id: help.dir
|
5
|
+
type: join
|
6
|
+
data: [
|
7
|
+
[var, buildz.demo.test.dp]
|
8
|
+
res/help
|
9
|
+
]
|
10
|
+
}
|
11
|
+
{
|
12
|
+
id: help.default, type: object, source: buildz.demo.test.Help
|
13
|
+
construct: {
|
14
|
+
args: [(ref, help.dir), default.js]
|
15
|
+
}
|
16
|
+
}
|
17
|
+
{
|
18
|
+
id: demo, type: object, source: buildz.demo.test.Deal
|
19
|
+
construct: {
|
20
|
+
//args: []
|
21
|
+
maps: {
|
22
|
+
conf: {
|
23
|
+
type: ioc
|
24
|
+
key: conf
|
25
|
+
}
|
26
|
+
deals: {
|
27
|
+
type: val
|
28
|
+
// 这里让test.Deal自己查id对应的object,也可以写成在配置里直接映射好,但写起来比较麻烦
|
29
|
+
data: {
|
30
|
+
ioc: {
|
31
|
+
deal: deal.ioc
|
32
|
+
help: help.ioc
|
33
|
+
},
|
34
|
+
xf: {
|
35
|
+
deal: deal.xf
|
36
|
+
help: help.xf
|
37
|
+
},
|
38
|
+
search: {
|
39
|
+
deal: deal.search
|
40
|
+
help: help.search
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
default: {
|
45
|
+
type: ref
|
46
|
+
key: help.default
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
{
|
52
|
+
id: run
|
53
|
+
type: mcall
|
54
|
+
source: demo
|
55
|
+
method: run
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
@@ -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,21 @@
|
|
1
|
+
{
|
2
|
+
datas: [
|
3
|
+
{
|
4
|
+
id: help.xf
|
5
|
+
type: object
|
6
|
+
source: buildz.demo.xf.help.Help
|
7
|
+
construct: {
|
8
|
+
args: [
|
9
|
+
[ref, help.dir]
|
10
|
+
[val, xf.js]
|
11
|
+
]
|
12
|
+
}
|
13
|
+
}
|
14
|
+
{
|
15
|
+
id: deal.xf
|
16
|
+
type: object
|
17
|
+
source: buildz.demo.xf.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
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
from buildz import xf, argx, pyz, ioc, fz
|
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"
|
7
|
+
class Help:
|
8
|
+
def __init__(self, dp, fp):
|
9
|
+
fp = join(dp, fp)
|
10
|
+
self.obj = xf.loads(xf.fread(fp))
|
11
|
+
self.text = self.obj['text'+text_sfx]
|
12
|
+
def deal(self):
|
13
|
+
print(self.text)
|
14
|
+
|
15
|
+
pass
|
16
|
+
class Deal:
|
17
|
+
def __init__(self, conf, deals, default):
|
18
|
+
self.deals = {}
|
19
|
+
self.default = default
|
20
|
+
for md in deals:
|
21
|
+
self.deals[md] = {}
|
22
|
+
refs = deals[md]
|
23
|
+
for key in refs:
|
24
|
+
ref = refs[key]
|
25
|
+
obj = conf.get(ref)
|
26
|
+
self.deals[md][key] = obj
|
27
|
+
def run(self):
|
28
|
+
if len(args)==0:
|
29
|
+
return self.default.deal()
|
30
|
+
md = args[0]
|
31
|
+
help = "h" in maps or "help" in maps
|
32
|
+
key = "deal" if not help else "help"
|
33
|
+
if md not in self.deals:
|
34
|
+
return self.default.deal()
|
35
|
+
obj = self.deals[md][key]
|
36
|
+
obj.deal()
|
37
|
+
|
38
|
+
pass
|
39
|
+
dp = dirname(__file__)
|
40
|
+
import time
|
41
|
+
def test():
|
42
|
+
print(f"start\n{'='*30}")
|
43
|
+
args, maps = argx.fetch()
|
44
|
+
curr = time.time()
|
45
|
+
fps = fz.search(join(dp, 'res', 'conf'), ".*\.js")
|
46
|
+
confs = ioc.build()
|
47
|
+
confs.add_fps(fps)
|
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)
|
54
|
+
|
55
|
+
pass
|
56
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
from buildz import xf, argx, pyz, ioc
|
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 filepath")
|
9
|
+
return
|
10
|
+
fp = args[1]
|
11
|
+
obj = xf.loads(xf.fread(fp))
|
12
|
+
s = xf.dumps(obj, format=1, deep=1)
|
13
|
+
print(s)
|
14
|
+
pass
|
15
|
+
|
16
|
+
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 ..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
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#coding=utf-8
|
2
|
+
import os
|
3
|
+
#列出文件夹下所有文件和文件更新时间
|
4
|
+
#文件访问处理方法
|
5
|
+
#建议visit读取文件
|
6
|
+
#catch处理目录访问异常
|
7
|
+
class FileDeal:
|
8
|
+
def __init__(self, *argv, **maps):
|
9
|
+
self.init(*argv, **maps)
|
10
|
+
def result(self):
|
11
|
+
return None
|
12
|
+
def init(self, *argv, **maps):
|
13
|
+
pass
|
14
|
+
def work(self, *argv, **maps):
|
15
|
+
return self.dirs(*argv, **maps)
|
16
|
+
def dirs(self, filepath, depth = 0):
|
17
|
+
dirs(filepath, self, depth)
|
18
|
+
return self.result()
|
19
|
+
def visit(self, filepath, isdir, depth):
|
20
|
+
return True
|
21
|
+
def catch(self, filepath, isdir, depth, exp):
|
22
|
+
pass
|
23
|
+
def deal(self, filepath, isdir, depth, exp = None):
|
24
|
+
if exp is None:
|
25
|
+
return self.visit(filepath, isdir, depth)
|
26
|
+
else:
|
27
|
+
return self.catch(filepath, isdir, depth, exp)
|
28
|
+
def __call__(self, *argv, **maps):
|
29
|
+
return self.deal(*argv, **maps)
|
30
|
+
|
31
|
+
pass
|
32
|
+
#遍历文件/文件夹filepath
|
33
|
+
def dirs(filepath, fc=FileDeal(), depth = 0):
|
34
|
+
isdir = os.path.isdir(filepath)
|
35
|
+
visit = fc(filepath, isdir, depth)
|
36
|
+
if isdir and visit:
|
37
|
+
try:
|
38
|
+
files = os.listdir(filepath)
|
39
|
+
except Exception as exp:
|
40
|
+
fc(filepath, isdir, depth, exp)
|
41
|
+
return
|
42
|
+
files = [os.path.join(filepath, file) for file in files]
|
43
|
+
[dirs(fp, fc, depth+1) for fp in files]
|
44
|
+
|
45
|
+
pass
|
46
|
+
|