buildz 0.5.5__tar.gz → 0.5.7__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.5.5/buildz.egg-info → buildz-0.5.7}/PKG-INFO +1 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz/fz/__init__.py +2 -2
- buildz-0.5.7/buildz/fz/dirz.py +74 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/fz/fio.py +14 -3
- buildz-0.5.7/buildz/fz/lsf.py +113 -0
- buildz-0.5.7/buildz/ioc/base.py +5 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc/base.py +12 -8
- buildz-0.5.7/buildz/ioc/ioc/single.py +56 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/calls.py +1 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/env.py +1 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/ioc.py +1 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/join.py +1 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/list.py +1 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/map.py +1 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/obj.py +11 -6
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/ref.py +1 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/val.py +2 -2
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/lrval.py +3 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/mapz.py +24 -0
- {buildz-0.5.5 → buildz-0.5.7/buildz.egg-info}/PKG-INFO +1 -1
- {buildz-0.5.5 → buildz-0.5.7}/buildz.egg-info/SOURCES.txt +1 -0
- {buildz-0.5.5 → buildz-0.5.7}/setup.py +1 -1
- buildz-0.5.5/buildz/fz/dirz.py +0 -46
- buildz-0.5.5/buildz/fz/lsf.py +0 -65
- buildz-0.5.5/buildz/ioc/base.py +0 -4
- {buildz-0.5.5 → buildz-0.5.7}/LICENSE +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/MANIFEST.in +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/README.md +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/__init__.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/__main__.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/argx.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/ioc/deal.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/ioc/help.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/myers/deal.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/myers/help.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/conf/ioc.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/conf/main.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/conf/myers.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/conf/search.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/conf/xf.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/help/default.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/help/ioc.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/help/myers.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/help/search.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/help/xf.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/res/test.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/search/deal.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/search/help.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/test.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/xf/deal.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/demo/xf/help.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/__init__.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/init.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc/conf.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc/confs.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/base.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/call.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/deal_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/deals.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/iocf_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/ref_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/xfile_defaults.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/conf/xfile_lists.js +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/deal.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/demo.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/iocf.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/mcall.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/ovar.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/var.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/ioc/ioc_deal/xfile.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/pyz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/tz/__init__.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/tz/myers_diff.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/__init__.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/__main__.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/file.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/base.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/buffer.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/listz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/lr.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/lrval.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/mapz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/nextz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/reval.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/setz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/spc.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/spt.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/deal/strz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/exp.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/item.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/mg.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loader/pos.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/base.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/buffer.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/listz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/lr.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/mapz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/nextz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/reval.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/setz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/spc.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/spt.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/deal/strz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/exp.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/item.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/mg.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/pos.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/test.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/loaderz/test1.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/read.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/readz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/stack.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/write.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/writer/base.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/writer/conf.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/writer/deal/jsonval.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/writer/deal/listz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/writer/deal/mapz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/writer/deal/reval.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/writer/deal/strz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/writer/itemz.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/writer/mg.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz/xf/xargs.py +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz.egg-info/dependency_links.txt +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/buildz.egg-info/top_level.txt +0 -0
- {buildz-0.5.5 → buildz-0.5.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: buildz
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.7
|
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
|
@@ -1,7 +1,7 @@
|
|
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
|
6
6
|
|
7
7
|
__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
|
+
|
@@ -34,12 +34,23 @@ def fwrites(cts, fp, mode = 'wb'):
|
|
34
34
|
pass
|
35
35
|
writes = fwrites
|
36
36
|
|
37
|
-
def
|
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
|
|
42
|
+
pass
|
43
|
+
def makefdir(fp):
|
44
|
+
fp = os.path.abspath(fp)
|
45
|
+
dp = os.path.dirname(fp)
|
46
|
+
makedir(dp)
|
47
|
+
|
44
48
|
pass
|
45
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
|
+
dirname = dirpath
|
@@ -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
|
@@ -37,17 +37,21 @@ class EncapeData(Base):
|
|
37
37
|
info: 额外的调用信息,目前只有object会用到里面的id字段,作为单例额外输入
|
38
38
|
"""
|
39
39
|
if typez(data)==dict:
|
40
|
-
pid = xf.
|
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
|
@@ -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
|
@@ -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
|
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:
|
@@ -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.
|
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.
|
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.
|
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
|
-
|
140
|
-
kv
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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
|
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
|
27
|
+
return xf.get_first(data, "val", "data")
|
28
28
|
|
29
29
|
pass
|
@@ -32,9 +32,11 @@ class LRValDeal(lr.LRDeal):
|
|
32
32
|
rst.append(_item.val)
|
33
33
|
try:
|
34
34
|
val = self.fc(rst[0], rst[1])
|
35
|
-
except
|
35
|
+
except Exceptin as exp1:
|
36
36
|
print("exp:", exp1)
|
37
37
|
raise Exception(f"error in lrval fc: {self.fc}({rst}): {exp1} ")
|
38
38
|
return item.Item(val, type='val', is_val = 1)
|
39
|
+
def build_arr(self, obj):
|
40
|
+
return self.build(obj)
|
39
41
|
|
40
42
|
pass
|
@@ -38,6 +38,30 @@ def gf(obj, **maps):
|
|
38
38
|
rst = rst[0]
|
39
39
|
return rst
|
40
40
|
|
41
|
+
pass
|
42
|
+
def get_first(obj, *keys):
|
43
|
+
for k in keys:
|
44
|
+
if k in obj:
|
45
|
+
return obj[k]
|
46
|
+
raise KeyError(keys[0])
|
47
|
+
|
48
|
+
pass
|
49
|
+
def get_one(obj, keys, default = None):
|
50
|
+
for k in keys:
|
51
|
+
if k in obj:
|
52
|
+
return obj[k]
|
53
|
+
return default
|
54
|
+
|
55
|
+
pass
|
56
|
+
def g1(obj, **maps):
|
57
|
+
v = None
|
58
|
+
for k in maps:
|
59
|
+
v = maps[k]
|
60
|
+
if k in obj:
|
61
|
+
v = obj[k]
|
62
|
+
return v
|
63
|
+
return v
|
64
|
+
|
41
65
|
pass
|
42
66
|
def g(obj, **maps):
|
43
67
|
rst = []
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: buildz
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.7
|
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
|
buildz-0.5.5/buildz/fz/dirz.py
DELETED
@@ -1,46 +0,0 @@
|
|
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
|
-
|
buildz-0.5.5/buildz/fz/lsf.py
DELETED
@@ -1,65 +0,0 @@
|
|
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, fp, isdir, depth):
|
14
|
-
self.fps.append([fp, isdir])
|
15
|
-
return True
|
16
|
-
def catch(self, fp, isdir, depth, exp):
|
17
|
-
self.errors.append([fp, isdir, exp])
|
18
|
-
|
19
|
-
pass
|
20
|
-
|
21
|
-
class FileSearchDeal(dirz.FileDeal):
|
22
|
-
def init(self, pt_fp=None, pt = None, depth = None):
|
23
|
-
super().init()
|
24
|
-
self.pt_fp = pt_fp
|
25
|
-
if type(pt) == str:
|
26
|
-
pt = pt.encode()
|
27
|
-
self.pt = pt
|
28
|
-
self.rst = []
|
29
|
-
self.depth = depth
|
30
|
-
def result(self):
|
31
|
-
return self.rst
|
32
|
-
def visit(self, filepath, isdir, depth):
|
33
|
-
if self.depth is not None and depth > self.depth:
|
34
|
-
return False
|
35
|
-
if isdir:
|
36
|
-
return True
|
37
|
-
if self.pt_fp is not None and len(re.findall(self.pt_fp, filepath))==0:
|
38
|
-
return False
|
39
|
-
if self.pt is not None:
|
40
|
-
try:
|
41
|
-
with open(filepath, 'rb') as f:
|
42
|
-
s = f.read()
|
43
|
-
except Exception as exp:
|
44
|
-
print("fread exp in :", filepath, "exp:", exp)
|
45
|
-
return False
|
46
|
-
if len(re.findall(self.pt, s))==0:
|
47
|
-
return False
|
48
|
-
#print("find:", filepath)
|
49
|
-
self.rst.append(filepath)
|
50
|
-
return False
|
51
|
-
def catch(self, filepath, isdir, depth, exp):
|
52
|
-
print(f"exp in {filepath} isdir={isdir}: {exp}")
|
53
|
-
pass
|
54
|
-
|
55
|
-
pass
|
56
|
-
|
57
|
-
|
58
|
-
def lists(fp):
|
59
|
-
return ListsDeal().dirs(fp)
|
60
|
-
|
61
|
-
pass
|
62
|
-
def search(dp, pt_fp = None, pt = None, depth = None):
|
63
|
-
return FileSearchDeal(pt_fp, pt, depth).dirs(dp)
|
64
|
-
|
65
|
-
pass
|
buildz-0.5.5/buildz/ioc/base.py
DELETED
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
|
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
|
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
|