buildz 0.4.6__tar.gz → 0.4.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.
Files changed (111) hide show
  1. {buildz-0.4.6/buildz.egg-info → buildz-0.4.7}/PKG-INFO +11 -1
  2. {buildz-0.4.6 → buildz-0.4.7}/README.md +10 -0
  3. buildz-0.4.7/buildz/demo/myers/deal.py +54 -0
  4. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/res/conf/main.js +4 -0
  5. buildz-0.4.7/buildz/demo/res/conf/myers.js +21 -0
  6. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/res/help/default.js +4 -0
  7. buildz-0.4.7/buildz/demo/res/help/myers.js +36 -0
  8. buildz-0.4.7/buildz/demo/search/help.py +16 -0
  9. {buildz-0.4.6 → buildz-0.4.7}/buildz/fz/__init__.py +1 -0
  10. buildz-0.4.7/buildz/fz/fio.py +35 -0
  11. {buildz-0.4.6 → buildz-0.4.7}/buildz/pyz.py +35 -1
  12. buildz-0.4.7/buildz/tz/__init__.py +11 -0
  13. buildz-0.4.7/buildz/tz/myers_diff.py +219 -0
  14. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/write.py +1 -1
  15. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/writer/deal/strz.py +3 -1
  16. {buildz-0.4.6 → buildz-0.4.7/buildz.egg-info}/PKG-INFO +11 -1
  17. {buildz-0.4.6 → buildz-0.4.7}/buildz.egg-info/SOURCES.txt +7 -1
  18. {buildz-0.4.6 → buildz-0.4.7}/setup.py +1 -1
  19. buildz-0.4.6/buildz/xf/test_write.py +0 -73
  20. {buildz-0.4.6 → buildz-0.4.7}/LICENSE +0 -0
  21. {buildz-0.4.6 → buildz-0.4.7}/MANIFEST.in +0 -0
  22. {buildz-0.4.6 → buildz-0.4.7}/buildz/__init__.py +0 -0
  23. {buildz-0.4.6 → buildz-0.4.7}/buildz/__main__.py +0 -0
  24. {buildz-0.4.6 → buildz-0.4.7}/buildz/argx.py +0 -0
  25. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/ioc/deal.py +0 -0
  26. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/ioc/help.py +0 -0
  27. {buildz-0.4.6/buildz/demo/search → buildz-0.4.7/buildz/demo/myers}/help.py +0 -0
  28. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/res/conf/ioc.js +0 -0
  29. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/res/conf/search.js +0 -0
  30. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/res/conf/xf.js +0 -0
  31. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/res/help/ioc.js +0 -0
  32. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/res/help/search.js +0 -0
  33. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/res/help/xf.js +0 -0
  34. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/res/test.js +0 -0
  35. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/search/deal.py +0 -0
  36. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/test.py +0 -0
  37. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/xf/deal.py +0 -0
  38. {buildz-0.4.6 → buildz-0.4.7}/buildz/demo/xf/help.py +0 -0
  39. {buildz-0.4.6 → buildz-0.4.7}/buildz/fz/dirz.py +0 -0
  40. {buildz-0.4.6 → buildz-0.4.7}/buildz/fz/lsf.py +0 -0
  41. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/__init__.py +0 -0
  42. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/init.py +0 -0
  43. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc/base.py +0 -0
  44. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc/conf.py +0 -0
  45. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc/confs.py +0 -0
  46. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/base.py +0 -0
  47. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/call.py +0 -0
  48. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/calls.py +0 -0
  49. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
  50. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
  51. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
  52. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
  53. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/deals.js +0 -0
  54. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
  55. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
  56. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
  57. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
  58. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
  59. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
  60. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
  61. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
  62. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
  63. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
  64. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
  65. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
  66. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/ref_lists.js +0 -0
  67. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
  68. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/demo.py +0 -0
  69. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/env.py +0 -0
  70. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/ioc.py +0 -0
  71. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/join.py +0 -0
  72. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/list.py +0 -0
  73. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/map.py +0 -0
  74. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/mcall.py +0 -0
  75. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/obj.py +0 -0
  76. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/ovar.py +0 -0
  77. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/ref.py +0 -0
  78. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/val.py +0 -0
  79. {buildz-0.4.6 → buildz-0.4.7}/buildz/ioc/ioc_deal/var.py +0 -0
  80. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/__init__.py +0 -0
  81. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/file.py +0 -0
  82. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/base.py +0 -0
  83. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/buffer.py +0 -0
  84. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/listz.py +0 -0
  85. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/lr.py +0 -0
  86. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/lrval.py +0 -0
  87. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/mapz.py +0 -0
  88. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/nextz.py +0 -0
  89. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/reval.py +0 -0
  90. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/setz.py +0 -0
  91. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/spc.py +0 -0
  92. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/spt.py +0 -0
  93. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/deal/strz.py +0 -0
  94. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/exp.py +0 -0
  95. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/item.py +0 -0
  96. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/mg.py +0 -0
  97. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/loader/pos.py +0 -0
  98. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/mapz.py +0 -0
  99. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/read.py +0 -0
  100. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/writer/base.py +0 -0
  101. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/writer/conf.py +0 -0
  102. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/writer/deal/jsonval.py +0 -0
  103. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/writer/deal/listz.py +0 -0
  104. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/writer/deal/mapz.py +0 -0
  105. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/writer/deal/reval.py +0 -0
  106. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/writer/itemz.py +0 -0
  107. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/writer/mg.py +0 -0
  108. {buildz-0.4.6 → buildz-0.4.7}/buildz/xf/xargs.py +0 -0
  109. {buildz-0.4.6 → buildz-0.4.7}/buildz.egg-info/dependency_links.txt +0 -0
  110. {buildz-0.4.6 → buildz-0.4.7}/buildz.egg-info/top_level.txt +0 -0
  111. {buildz-0.4.6 → buildz-0.4.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: buildz
3
- Version: 0.4.6
3
+ Version: 0.4.7
4
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
5
  Home-page: https://github.com/buildCodeZ/buildz
6
6
  Author: Zzz
@@ -19,7 +19,12 @@ License-File: LICENSE
19
19
  buildz.fz: 文件夹查找
20
20
  buildz.pyz: 简化python __import__调用
21
21
  buildz.argx: 按格式读命令行参数
22
+ buildz.tz: 加些工具,目前只有myerse diff字符串比较算法
22
23
  buildz.demo: 使用参考,运行"python -m buildz"会用这个模块
24
+ 代码关系:
25
+ buildz.xf, buildz.pyz, buildz.argx, buildz.fz, buildz.tz都是独立的模块
26
+ buildz.ioc需要buildz.xf和buildz.pyz
27
+ buildz.demo需要其他全部模块
23
28
 
24
29
  运行python -m buildz查看帮助
25
30
 
@@ -30,6 +35,11 @@ License-File: LICENSE
30
35
  buildz.pyz: make it easier to use python's __import__ function
31
36
  buildz.argx: read command argument in special format
32
37
  buildz.demo: example codes to use buildz, run "python -m buildz" will use this module
38
+ code relationship:
39
+ buildz.xf, buildz.pyz, buildz.argx, buildz.fz, buildz.tz is independent
40
+ buildz.ioc use buildz.xf and buildz.pyz
41
+ buildz.tz: some tools, only contains "myerse diff algorithm" now
42
+ buildz.demo use all other modules
33
43
 
34
44
  run python -m buildz to see help
35
45
  ```
@@ -6,7 +6,12 @@
6
6
  buildz.fz: 文件夹查找
7
7
  buildz.pyz: 简化python __import__调用
8
8
  buildz.argx: 按格式读命令行参数
9
+ buildz.tz: 加些工具,目前只有myerse diff字符串比较算法
9
10
  buildz.demo: 使用参考,运行"python -m buildz"会用这个模块
11
+ 代码关系:
12
+ buildz.xf, buildz.pyz, buildz.argx, buildz.fz, buildz.tz都是独立的模块
13
+ buildz.ioc需要buildz.xf和buildz.pyz
14
+ buildz.demo需要其他全部模块
10
15
 
11
16
  运行python -m buildz查看帮助
12
17
 
@@ -17,6 +22,11 @@
17
22
  buildz.pyz: make it easier to use python's __import__ function
18
23
  buildz.argx: read command argument in special format
19
24
  buildz.demo: example codes to use buildz, run "python -m buildz" will use this module
25
+ code relationship:
26
+ buildz.xf, buildz.pyz, buildz.argx, buildz.fz, buildz.tz is independent
27
+ buildz.ioc use buildz.xf and buildz.pyz
28
+ buildz.tz: some tools, only contains "myerse diff algorithm" now
29
+ buildz.demo use all other modules
20
30
 
21
31
  run python -m buildz to see help
22
32
  ```
@@ -0,0 +1,54 @@
1
+ #coding=utf-8
2
+ from buildz import xf, argx, pyz, ioc, fz,tz
3
+
4
+ from ..test import text_sfx, args, maps
5
+ class Deal:
6
+ def deal(self):
7
+ if len(args)<5:
8
+ print("need opt, file1, file2, step_file")
9
+ return
10
+ opt = args[1]
11
+ fp1 = args[2]
12
+ fp2 = args[3]
13
+ fp_step = args[4]
14
+ mark_encode = argx.get(maps, 'e', 1)
15
+ mark_txt = argx.get(maps, 't', None)
16
+ if mark_txt:
17
+ mark_encode = 0
18
+ spt = argx.get(maps, 's', 1)
19
+ nspt = argx.get(maps, 'ns', 0)
20
+ if nspt:
21
+ spt = 0
22
+ print(f"SPT:{spt}")
23
+ if opt == 'diff':
24
+ bs1 = fz.read(fp1).decode("utf-8")
25
+ bs2 = fz.read(fp2).decode("utf-8")
26
+ #bs1 = b"text z xxxyzijsa"
27
+ #bs2 = b"test xxxx afzjcovijsax"
28
+ stps = tz.m_steps(bs1, bs2,split=spt)
29
+ if mark_encode:
30
+ stps = b"e"+tz.m_encode(stps)
31
+ else:
32
+ for stp in stps:
33
+ c = stp[-1]
34
+ if type(c)==bytes:
35
+ stp[-1] = c.decode()
36
+ stps = "t"+xf.dumps(stps)
37
+ stps = stps.encode()
38
+ fz.write(fp_step, stps)
39
+ elif opt == 'update':
40
+ bs1 = fz.read(fp1).decode("utf-8")
41
+ bs_step = fz.read(fp_step)
42
+ mark_encode = bs_step[:1] == b'e'
43
+ bs_step= bs_step[1:]
44
+ if mark_encode:
45
+ stps = tz.m_decode(bs_step)
46
+ else:
47
+ stps = xf.loads(bs_step.decode())
48
+ bs2 = tz.m_update(bs1, stps,split=spt).encode("utf-8")
49
+ fz.write(fp2, bs2)
50
+ else:
51
+ print(f"unexpect opt: {opt}")
52
+ pass
53
+
54
+ pass
@@ -38,6 +38,10 @@
38
38
  search: {
39
39
  deal: deal.search
40
40
  help: help.search
41
+ },
42
+ myers: {
43
+ deal: deal.myers
44
+ help: help.myers
41
45
  }
42
46
  }
43
47
  }
@@ -0,0 +1,21 @@
1
+ {
2
+ datas: [
3
+ {
4
+ id: help.myers
5
+ type: object
6
+ source: buildz.demo.myers.help.Help
7
+ construct: {
8
+ args: [
9
+ [ref, help.dir]
10
+ [val, myers.js]
11
+ ]
12
+ }
13
+ }
14
+ {
15
+ id: deal.myers
16
+ type: object
17
+ source: buildz.demo.myers.deal.Deal
18
+ construct: {}
19
+ }
20
+ ]
21
+ }
@@ -6,6 +6,8 @@ or
6
6
  python -m buildz ioc +h [+en]
7
7
  or
8
8
  python -m buildz search +h [+en]
9
+ or
10
+ python -m buildz myers opt f1 f2 f_stp [+e/+t]
9
11
  to see help
10
12
  """
11
13
  text.en=
@@ -15,6 +17,8 @@ or
15
17
  python -m buildz ioc +h [+en]
16
18
  or
17
19
  python -m buildz search +h [+en]
20
+ or
21
+ python -m buildz myers opt f1 f2 f_stp [+e/+t]
18
22
  to see help
19
23
  """
20
24
  }
@@ -0,0 +1,36 @@
1
+ {
2
+ text=
3
+ r"""
4
+ 文件比较(模仿git diff):
5
+ python -m buildz myers 操作 文件路径1 文件路径2 step文件 [+e/t/s/ns]
6
+ 操作:
7
+ diff: 计算文件1到文件2需要的步骤,保存到step文件
8
+ update: 文件1根据step文件修改,保存到文件2
9
+ 可选:
10
+ +e: step文件字节保存(默认)
11
+ +t: step文件字符串保存
12
+ +s: 字符串做切分(默认)
13
+ +ns: 字符串不做切分(更精准,但可能耗时很高)
14
+
15
+ 比如:
16
+ python -m buildz myers diff test.py curr_test.py step.dt
17
+
18
+ """
19
+ text.en=
20
+ r"""
21
+ file compare:
22
+ python -m buildz myers opt file1 file2 step_file
23
+ opt:
24
+ diff: calucate steps from file1 to fiel2, save into step_file
25
+ update: update file1 by step_file, save into file2
26
+ options:
27
+ +e: step_file save in bytes(default)
28
+ +t: step_file save by string
29
+ +s: cut string into pices(default)
30
+ +ns: not cut string(more precise but maybe more step_file size)
31
+
32
+ exp:
33
+ python -m buildz myers diff test.py curr_test.py step.dt
34
+
35
+ """
36
+ }
@@ -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
@@ -2,5 +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
6
 
6
7
  __author__ = "Zzz, emails: 1174534295@qq.com, 1309458652@qq.com"
@@ -0,0 +1,35 @@
1
+ #coding=utf-8
2
+
3
+ """
4
+ 读写文件再简化
5
+ """
6
+ def fread(fp, mode='rb'):
7
+ with open(fp, mode) as f:
8
+ return f.read()
9
+
10
+ pass
11
+ read=fread
12
+ def freads(fp, mode = 'rb', size=1024*1024):
13
+ with open(fp, mode) as f:
14
+ while True:
15
+ bs = f.read(size)
16
+ if len(bs)==0:
17
+ break
18
+ yield bs
19
+
20
+ pass
21
+ reads=freads
22
+
23
+ def fwrite(fp, ct, mode = 'wb'):
24
+ with open(fp, mode) as f:
25
+ f.write(ct)
26
+
27
+ pass
28
+ write = fwrite
29
+ def fwrites(fp, cts, mode = 'wb'):
30
+ with open(fp, mode) as f:
31
+ for ct in cts:
32
+ f.write(ct)
33
+
34
+ pass
35
+ writes = fwrites
@@ -1,4 +1,6 @@
1
1
 
2
+ import sys
3
+ import os
2
4
  def load(md, fc = None):
3
5
  """
4
6
  import object(whether module or others) from md(or md.fc)
@@ -26,11 +28,11 @@ def load(md, fc = None):
26
28
  return fc
27
29
 
28
30
  pass
29
- import sys
30
31
  def pyexe():
31
32
  return sys.executable
32
33
 
33
34
  pass
35
+ exe=pyexe
34
36
  is_windows = sys.platform.lower()=='win32'
35
37
  def pypkg():
36
38
  """
@@ -45,3 +47,35 @@ def pypkg():
45
47
  return fpath
46
48
 
47
49
  pass
50
+ pkg = pypkg
51
+ pth = pypkg
52
+
53
+ class Pth:
54
+ def __init__(self, fp = "build.pth"):
55
+ self.fp = os.path.join(pth(), fp)
56
+ def read(self):
57
+ fp = self.fp
58
+ if not os.path.isfile(fp):
59
+ return []
60
+ with open(fp, 'rb') as f:
61
+ s = f.read().decode()
62
+ return s.split("\n")
63
+ def add(self, path):
64
+ arr = self.read()
65
+ if path in arr:
66
+ print("alread add")
67
+ return
68
+ arr.append(path)
69
+ self.write(arr)
70
+ def write(self, paths = []):
71
+ if type(paths) not in [list, tuple]:
72
+ paths = [paths]
73
+ s = "\n".join(paths)
74
+ with open(self.fp, 'wb') as f:
75
+ f.write(s.encode())
76
+ def remove(self):
77
+ os.remove(self.fp)
78
+
79
+ pass
80
+
81
+ _pth = Pth()
@@ -0,0 +1,11 @@
1
+ #coding=utf-8
2
+ #author: Zzz, emails: 1174534295@qq.com, 1309458652@qq.com
3
+
4
+ # 代码差异
5
+ from .myers_diff import update as m_update, myers as m_steps, encode as m_encode, decode as m_decode
6
+
7
+ """
8
+ 工具模块
9
+
10
+ """
11
+ __author__ = "Zzz, emails: 1174534295@qq.com, 1309458652@qq.com"
@@ -0,0 +1,219 @@
1
+ #codig=utf-8
2
+ import os
3
+ import re
4
+ import numpy as np
5
+ import base64
6
+ ACT_ADD = "add_prev"
7
+ ACT_DEL = "del_curr"
8
+ import struct
9
+ def encode(steps, as_str = False):
10
+ """
11
+ 步骤列表转bytes/str
12
+ """
13
+ rst = b""
14
+ for step in steps:
15
+ if step[0] == ACT_ADD:
16
+ bs = step[2]
17
+ if type(bs) == str:
18
+ bs = bs.encode("utf-8")
19
+ obj = struct.pack(">BII", 1, step[1], len(bs))+bs
20
+ else:
21
+ obj = struct.pack(">BII", 0, step[1], step[2])
22
+ rst+=obj
23
+ if as_str:
24
+ rst = base64.b64encode(rst).decode()
25
+ return rst
26
+
27
+ pass
28
+ def decode(obj):
29
+ """
30
+ bytes/str转步骤列表
31
+ """
32
+ if type(obj) == str:
33
+ obj = base64.b64decode(obj)
34
+ ni = 1+4+4
35
+ rst = []
36
+ while len(obj)>0:
37
+ bs = obj[:ni]
38
+ obj = obj[ni:]
39
+ act, base, c = struct.unpack(">BII", bs)
40
+ if act == 1:
41
+ bs = obj[:c]
42
+ obj = obj[c:]
43
+ s = bs.decode("utf-8")
44
+ tmp = [ACT_ADD, base, s]
45
+ else:
46
+ tmp = [ACT_DEL, base, c]
47
+ rst.append(tmp)
48
+ return rst
49
+
50
+ pass
51
+ def steps(vs, n, m, d, stra, strb):
52
+ k = n-m
53
+ rst = []
54
+ for step in range(d, 0, -1):
55
+ v = vs[step]
56
+ x = v[k]
57
+ y = x-k
58
+ prev_v = vs[step-1]
59
+ down = ((k == -step) or ((k != step) and prev_v[k + 1] > prev_v[k - 1]))
60
+ prev_k = k+1 if down else k-1
61
+ prev_x = prev_v[prev_k]
62
+ prev_y = prev_x-prev_k
63
+ if down:
64
+ #加字符
65
+ act = [ACT_ADD, prev_x, strb[prev_y]]
66
+ else:
67
+ #删字符
68
+ act = [ACT_DEL, prev_x, prev_x, stra[prev_x]]
69
+ rst.append(act)
70
+ k = prev_k
71
+ rst.reverse()
72
+ rst = combine(rst)
73
+ return rst
74
+
75
+ pass
76
+ def combine(steps):
77
+ base = None
78
+ rst = []
79
+ for step in steps:
80
+ if len(rst)>0 and rst[-1][0] == step[0]:
81
+ prev = rst[-1]
82
+ if step[0] == ACT_ADD:
83
+ if prev[1]==step[1]:
84
+ prev[2]+=step[2]
85
+ continue
86
+ elif step[0] == ACT_DEL:
87
+ if prev[2] == step[1]-1:
88
+ prev[2] = step[2]
89
+ continue
90
+ else:
91
+ raise Exception("test")
92
+ rst.append(step)
93
+ return rst
94
+
95
+ pass
96
+ def update(s, steps, split=1):
97
+ """
98
+ 按照steps更新s
99
+ """
100
+ if split:
101
+ if type(s)!=list:
102
+ s = spt(s)
103
+ if type(s)==bytes:
104
+ s = [s[i:i+1] for i in range(len(s))]
105
+ updated = -1
106
+ rst = []
107
+ spc = ""
108
+ if type(s)==bytes or type(s[0])==bytes:
109
+ spc = b""
110
+ for step in steps:
111
+ act = step[0]
112
+ x = step[1]
113
+ c = step[2]
114
+ if updated+1<x:
115
+ tmp = s[updated+1:x]
116
+ rst.append(tmp)
117
+ if act == ACT_ADD:
118
+ rst.append(c)
119
+ updated = x-1
120
+ elif act == ACT_DEL:
121
+ updated = c
122
+ else:
123
+ raise Exception("test")
124
+ if updated+1 < len(s):
125
+ rst.append(s[updated+1:])
126
+ rst = [k if type(k)!=list else spc.join(k) for k in rst]
127
+ rs = spc.join(rst)
128
+ return rs
129
+
130
+ pass
131
+ def spt(s, spts = "\n'\" `~!@#$%^&*()_+-={}[]:;<>,.?/|"):
132
+ arr = [s]
133
+ spts = list(spts)
134
+ if type(s)==bytes:
135
+ spts = [k.encode() for k in spts]
136
+ for _spt in spts:
137
+ tmp = []
138
+ for s in arr:
139
+ s = s.split(_spt)
140
+ # r = []
141
+ # for k in s:
142
+ # r.append(k)
143
+ # r.append(_spt)
144
+ # s = r[:-1]
145
+ s = [k+_spt for k in s[:-1]]+[s[-1]]
146
+ tmp+=s
147
+ arr = tmp
148
+ return arr
149
+
150
+ pass
151
+ def myers(stra, strb, split = 1):
152
+ import time
153
+ curr = time.time()
154
+ if split:
155
+ if type(stra)!=list:
156
+ stra = spt(stra)
157
+ if type(strb)!=list:
158
+ strb = spt(strb)
159
+ if type(stra)==bytes:
160
+ stra = [stra[i:i+1] for i in range(len(stra))]
161
+ if type(stra)==bytes:
162
+ strb = [strb[i:i+1] for i in range(len(strb))]
163
+ n = len(stra)
164
+ m = len(strb)
165
+ v = {
166
+ 1:0
167
+ }
168
+ vs = {
169
+ 0: {1:0}
170
+ }
171
+ index = 0
172
+ total=0
173
+ for d in range(n+m+1):
174
+ tmp = {}
175
+ for k in range(-d, d+1, 2):
176
+ # k == -d, 左边界,没法从左边来,只能是上边往下,k==d,上边界,只能从左边过来,
177
+ # v[k-1]是上一轮迭代,k-1线上的步数,从上一步的k-1到这一步的k,是向右,删字符,
178
+ # 因为上一步算了k从-d+1到d-1,所以除了边界可能没有左右值,中间的k都能查到上一步的k+1和k-1
179
+ # v[k+1]>v[k-1],表示向下(加字符)的x比向右(删字符)的x大
180
+ # 可以看图,k+1和k-1是k旁边的两条线,如果v[k+1]<=v[k-1],说明k-1的点在k+1的下方或右边,看图会发现k-1这个点更接近k这条线的终点
181
+ down = ((k == -d) or ((k != d) and v[k + 1] > v[k - 1]))
182
+ kPrev = k+1 if down else k-1
183
+ xStart = v[kPrev]
184
+ yStart = xStart - kPrev
185
+ # 完全没啥用的两个中间变量。。。
186
+ xMid = xStart if down else xStart + 1
187
+ yMid = xMid - k
188
+ xEnd = xMid
189
+ yEnd = yMid
190
+ while xEnd < n and yEnd < m and stra[xEnd] == strb[yEnd]:
191
+ xEnd+=1
192
+ yEnd+=1
193
+ total+=1
194
+ v[k] = xEnd
195
+ tmp[k] = xEnd
196
+ index+=1
197
+ total+=1
198
+ if xEnd == n and yEnd == m:
199
+ vs[d] = tmp
200
+ sec = time.time()-curr
201
+ stps = steps(vs, n,m,d,stra, strb)
202
+ return stps
203
+ vs[d] = tmp
204
+
205
+ pass
206
+
207
+ """
208
+
209
+ python -m buildz myers
210
+
211
+
212
+ python -m buildz myers diff "D:\rootz\python\gits\buildz_upd\buildz\tz\myers_diff.py" "D:\rootz\python\wk\test\myers_diff.py" "D:\rootz\python\wk\test\stp.txt" +e
213
+
214
+
215
+ python -m buildz myers update "D:\rootz\python\gits\buildz_upd\buildz\tz\myers_diff.py" "D:\rootz\python\wk\test\myers_diff_.py" "D:\rootz\python\wk\test\stp.txt" +e
216
+
217
+ python -m buildz myers diff "D:\rootz\python\wk\test\myers_diff.py" "D:\rootz\python\wk\test\myers_diff_.py" "D:\rootz\python\wk\test\df.txt" +t
218
+
219
+ """
@@ -8,7 +8,7 @@ pts = [
8
8
  "null",
9
9
  "true",
10
10
  "false",
11
- "[\s\S]*[\n\r\t\:\[\]\{\}][\s\S]*"
11
+ "[\s\S]*[\n\r\t\:\[\]\{\}\(\)\,\:\=\'\<\>\" \|\#\;\/][\s\S]*"
12
12
  ]
13
13
  def build(json_format=False):
14
14
  mgs = mg.Manager()
@@ -23,7 +23,9 @@ class StrDeal(base.BaseDeal):
23
23
  return None
24
24
  et = self.like("\n", val)
25
25
  need_ep = 0
26
- if val.find(et)>=0:
26
+ if len(val)==0:
27
+ need_ep = 1
28
+ elif val.find(et)>=0:
27
29
  need_ep = 1
28
30
  else:
29
31
  for pt in self.pts:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: buildz
3
- Version: 0.4.6
3
+ Version: 0.4.7
4
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
5
  Home-page: https://github.com/buildCodeZ/buildz
6
6
  Author: Zzz
@@ -19,7 +19,12 @@ License-File: LICENSE
19
19
  buildz.fz: 文件夹查找
20
20
  buildz.pyz: 简化python __import__调用
21
21
  buildz.argx: 按格式读命令行参数
22
+ buildz.tz: 加些工具,目前只有myerse diff字符串比较算法
22
23
  buildz.demo: 使用参考,运行"python -m buildz"会用这个模块
24
+ 代码关系:
25
+ buildz.xf, buildz.pyz, buildz.argx, buildz.fz, buildz.tz都是独立的模块
26
+ buildz.ioc需要buildz.xf和buildz.pyz
27
+ buildz.demo需要其他全部模块
23
28
 
24
29
  运行python -m buildz查看帮助
25
30
 
@@ -30,6 +35,11 @@ License-File: LICENSE
30
35
  buildz.pyz: make it easier to use python's __import__ function
31
36
  buildz.argx: read command argument in special format
32
37
  buildz.demo: example codes to use buildz, run "python -m buildz" will use this module
38
+ code relationship:
39
+ buildz.xf, buildz.pyz, buildz.argx, buildz.fz, buildz.tz is independent
40
+ buildz.ioc use buildz.xf and buildz.pyz
41
+ buildz.tz: some tools, only contains "myerse diff algorithm" now
42
+ buildz.demo use all other modules
33
43
 
34
44
  run python -m buildz to see help
35
45
  ```
@@ -13,13 +13,17 @@ buildz.egg-info/top_level.txt
13
13
  buildz/demo/test.py
14
14
  buildz/demo/ioc/deal.py
15
15
  buildz/demo/ioc/help.py
16
+ buildz/demo/myers/deal.py
17
+ buildz/demo/myers/help.py
16
18
  buildz/demo/res/test.js
17
19
  buildz/demo/res/conf/ioc.js
18
20
  buildz/demo/res/conf/main.js
21
+ buildz/demo/res/conf/myers.js
19
22
  buildz/demo/res/conf/search.js
20
23
  buildz/demo/res/conf/xf.js
21
24
  buildz/demo/res/help/default.js
22
25
  buildz/demo/res/help/ioc.js
26
+ buildz/demo/res/help/myers.js
23
27
  buildz/demo/res/help/search.js
24
28
  buildz/demo/res/help/xf.js
25
29
  buildz/demo/search/deal.py
@@ -28,6 +32,7 @@ buildz/demo/xf/deal.py
28
32
  buildz/demo/xf/help.py
29
33
  buildz/fz/__init__.py
30
34
  buildz/fz/dirz.py
35
+ buildz/fz/fio.py
31
36
  buildz/fz/lsf.py
32
37
  buildz/ioc/__init__.py
33
38
  buildz/ioc/init.py
@@ -68,11 +73,12 @@ buildz/ioc/ioc_deal/conf/obj_set_lists.js
68
73
  buildz/ioc/ioc_deal/conf/ovar_lists.js
69
74
  buildz/ioc/ioc_deal/conf/ref_lists.js
70
75
  buildz/ioc/ioc_deal/conf/var_lists.js
76
+ buildz/tz/__init__.py
77
+ buildz/tz/myers_diff.py
71
78
  buildz/xf/__init__.py
72
79
  buildz/xf/file.py
73
80
  buildz/xf/mapz.py
74
81
  buildz/xf/read.py
75
- buildz/xf/test_write.py
76
82
  buildz/xf/write.py
77
83
  buildz/xf/xargs.py
78
84
  buildz/xf/loader/base.py
@@ -7,7 +7,7 @@ from setuptools import setup, find_packages
7
7
 
8
8
  setup(
9
9
  name = 'buildz',
10
- version = '0.4.6',
10
+ version = '0.4.7',
11
11
  keywords='buildz',
12
12
  long_description=open('README.md', 'r', encoding="utf-8").read(),
13
13
  long_description_content_type='text/markdown',
@@ -1,73 +0,0 @@
1
-
2
- from writer import mg, itemz, base, conf
3
- from writer.deal import listz, mapz, strz, reval
4
- pts = [
5
- "[\+\-]?\d+",
6
- "[\+\-]?\d+\.\d+",
7
- "[\+\-]?\d+e[\+\-]?\d+",
8
- "null",
9
- "true",
10
- "false",
11
- ".*[\n\r\t\:\[\]\{\}].*"
12
- ]
13
- def build():
14
- mgs = mg.Manager()
15
- mgs.add(strz.StrDeal('"','"', pts))
16
- mgs.add(reval.ValDeal(float, lambda x:str(x)))
17
- mgs.add(reval.ValDeal(int, lambda x:str(x)))
18
- mgs.add(reval.ValDeal(type(None), lambda x:'null'))
19
- mgs.add(reval.ValDeal(bool, lambda x:'true' if x else 'false'))
20
- mgs.add(listz.ListDeal('[',']',','))
21
- mgs.add(mapz.MapDeal('{','}',':',','))
22
- return mgs
23
-
24
- pass
25
- def dumps(obj):
26
- cf = conf.Conf()
27
- cf.set(bytes=0, format=1, deep=0)
28
- mgs = build()
29
- return mgs.dump(obj, cf)
30
-
31
- pass
32
-
33
- from buildz import xconfz as xf
34
- s = r"""
35
- {
36
- a:b,
37
- test: ???
38
- id: 123
39
- cid: '123'
40
- content: '''hehe
41
- hehehe
42
- '''
43
- b:xx,
44
- int: <1,i>
45
- null: <null, null>
46
- a:[1,2,3,]
47
- v:{
48
- a:r"xx\n"
49
- b:"\n"
50
- c:d
51
- url:"http://test.com.cn"
52
- }
53
- }
54
- """
55
- def test():
56
- obj = xf.loads(s)
57
- rs = dumps(obj)
58
- print(obj)
59
- print(rs)
60
-
61
- pass
62
- test()
63
-
64
-
65
- r"""
66
-
67
- cd D:\rootz\python\gits\buildz_upd\buildz\xf
68
-
69
- python test_write.py
70
-
71
-
72
-
73
- """
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