pyxllib 0.3.197__py3-none-any.whl → 3.201.1__py3-none-any.whl

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 (127) hide show
  1. pyxllib/__init__.py +14 -21
  2. pyxllib/algo/__init__.py +8 -8
  3. pyxllib/algo/disjoint.py +54 -54
  4. pyxllib/algo/geo.py +537 -541
  5. pyxllib/algo/intervals.py +964 -964
  6. pyxllib/algo/matcher.py +389 -389
  7. pyxllib/algo/newbie.py +166 -166
  8. pyxllib/algo/pupil.py +629 -629
  9. pyxllib/algo/shapelylib.py +67 -67
  10. pyxllib/algo/specialist.py +241 -241
  11. pyxllib/algo/stat.py +494 -494
  12. pyxllib/algo/treelib.py +145 -149
  13. pyxllib/algo/unitlib.py +62 -66
  14. pyxllib/autogui/__init__.py +5 -5
  15. pyxllib/autogui/activewin.py +246 -246
  16. pyxllib/autogui/all.py +9 -9
  17. pyxllib/autogui/autogui.py +846 -852
  18. pyxllib/autogui/uiautolib.py +362 -362
  19. pyxllib/autogui/virtualkey.py +102 -102
  20. pyxllib/autogui/wechat.py +827 -827
  21. pyxllib/autogui/wechat_msg.py +421 -421
  22. pyxllib/autogui/wxautolib.py +84 -84
  23. pyxllib/cv/__init__.py +5 -5
  24. pyxllib/cv/expert.py +267 -267
  25. pyxllib/cv/imfile.py +159 -159
  26. pyxllib/cv/imhash.py +39 -39
  27. pyxllib/cv/pupil.py +9 -9
  28. pyxllib/cv/rgbfmt.py +1525 -1525
  29. pyxllib/cv/slidercaptcha.py +137 -137
  30. pyxllib/cv/trackbartools.py +251 -251
  31. pyxllib/cv/xlcvlib.py +1040 -1040
  32. pyxllib/cv/xlpillib.py +423 -423
  33. pyxllib/data/echarts.py +236 -240
  34. pyxllib/data/jsonlib.py +85 -89
  35. pyxllib/data/oss.py +72 -72
  36. pyxllib/data/pglib.py +1111 -1127
  37. pyxllib/data/sqlite.py +568 -568
  38. pyxllib/data/sqllib.py +297 -297
  39. pyxllib/ext/JLineViewer.py +505 -505
  40. pyxllib/ext/__init__.py +6 -6
  41. pyxllib/ext/demolib.py +251 -246
  42. pyxllib/ext/drissionlib.py +277 -277
  43. pyxllib/ext/kq5034lib.py +12 -12
  44. pyxllib/ext/qt.py +449 -449
  45. pyxllib/ext/robustprocfile.py +493 -497
  46. pyxllib/ext/seleniumlib.py +76 -76
  47. pyxllib/ext/tk.py +173 -173
  48. pyxllib/ext/unixlib.py +821 -827
  49. pyxllib/ext/utools.py +345 -351
  50. pyxllib/ext/webhook.py +124 -119
  51. pyxllib/ext/win32lib.py +40 -40
  52. pyxllib/ext/wjxlib.py +91 -88
  53. pyxllib/ext/wpsapi.py +124 -124
  54. pyxllib/ext/xlwork.py +9 -9
  55. pyxllib/ext/yuquelib.py +1110 -1105
  56. pyxllib/file/__init__.py +17 -17
  57. pyxllib/file/docxlib.py +757 -761
  58. pyxllib/file/gitlib.py +309 -309
  59. pyxllib/file/libreoffice.py +165 -165
  60. pyxllib/file/movielib.py +144 -148
  61. pyxllib/file/newbie.py +10 -10
  62. pyxllib/file/onenotelib.py +1469 -1469
  63. pyxllib/file/packlib/__init__.py +330 -330
  64. pyxllib/file/packlib/zipfile.py +2441 -2441
  65. pyxllib/file/pdflib.py +422 -426
  66. pyxllib/file/pupil.py +185 -185
  67. pyxllib/file/specialist/__init__.py +681 -685
  68. pyxllib/file/specialist/dirlib.py +799 -799
  69. pyxllib/file/specialist/download.py +193 -193
  70. pyxllib/file/specialist/filelib.py +2825 -2829
  71. pyxllib/file/xlsxlib.py +3122 -3131
  72. pyxllib/file/xlsyncfile.py +341 -341
  73. pyxllib/prog/__init__.py +5 -5
  74. pyxllib/prog/cachetools.py +58 -64
  75. pyxllib/prog/deprecatedlib.py +233 -233
  76. pyxllib/prog/filelock.py +42 -42
  77. pyxllib/prog/ipyexec.py +253 -253
  78. pyxllib/prog/multiprogs.py +940 -940
  79. pyxllib/prog/newbie.py +451 -451
  80. pyxllib/prog/pupil.py +1208 -1197
  81. pyxllib/prog/sitepackages.py +33 -33
  82. pyxllib/prog/specialist/__init__.py +348 -391
  83. pyxllib/prog/specialist/bc.py +203 -203
  84. pyxllib/prog/specialist/browser.py +497 -497
  85. pyxllib/prog/specialist/common.py +347 -347
  86. pyxllib/prog/specialist/datetime.py +198 -198
  87. pyxllib/prog/specialist/tictoc.py +240 -240
  88. pyxllib/prog/specialist/xllog.py +180 -180
  89. pyxllib/prog/xlosenv.py +110 -108
  90. pyxllib/stdlib/__init__.py +17 -17
  91. pyxllib/stdlib/tablepyxl/__init__.py +10 -10
  92. pyxllib/stdlib/tablepyxl/style.py +303 -303
  93. pyxllib/stdlib/tablepyxl/tablepyxl.py +130 -130
  94. pyxllib/text/__init__.py +8 -8
  95. pyxllib/text/ahocorasick.py +36 -39
  96. pyxllib/text/airscript.js +754 -744
  97. pyxllib/text/charclasslib.py +121 -121
  98. pyxllib/text/jiebalib.py +267 -267
  99. pyxllib/text/jinjalib.py +27 -32
  100. pyxllib/text/jsa_ai_prompt.md +271 -271
  101. pyxllib/text/jscode.py +922 -922
  102. pyxllib/text/latex/__init__.py +158 -158
  103. pyxllib/text/levenshtein.py +303 -303
  104. pyxllib/text/nestenv.py +1215 -1215
  105. pyxllib/text/newbie.py +300 -300
  106. pyxllib/text/pupil/__init__.py +8 -8
  107. pyxllib/text/pupil/common.py +1121 -1121
  108. pyxllib/text/pupil/xlalign.py +326 -326
  109. pyxllib/text/pycode.py +47 -47
  110. pyxllib/text/specialist/__init__.py +8 -8
  111. pyxllib/text/specialist/common.py +112 -112
  112. pyxllib/text/specialist/ptag.py +186 -186
  113. pyxllib/text/spellchecker.py +172 -172
  114. pyxllib/text/templates/echart_base.html +10 -10
  115. pyxllib/text/templates/highlight_code.html +16 -16
  116. pyxllib/text/templates/latex_editor.html +102 -102
  117. pyxllib/text/vbacode.py +17 -17
  118. pyxllib/text/xmllib.py +741 -747
  119. pyxllib/xl.py +42 -39
  120. pyxllib/xlcv.py +17 -17
  121. pyxllib-3.201.1.dist-info/METADATA +296 -0
  122. pyxllib-3.201.1.dist-info/RECORD +125 -0
  123. {pyxllib-0.3.197.dist-info → pyxllib-3.201.1.dist-info}/licenses/LICENSE +190 -190
  124. pyxllib/ext/old.py +0 -663
  125. pyxllib-0.3.197.dist-info/METADATA +0 -48
  126. pyxllib-0.3.197.dist-info/RECORD +0 -126
  127. {pyxllib-0.3.197.dist-info → pyxllib-3.201.1.dist-info}/WHEEL +0 -0
pyxllib/algo/treelib.py CHANGED
@@ -1,149 +1,145 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2022/04/07 15:45
6
-
7
- """
8
- 树形结构相关的处理
9
- """
10
-
11
- from pyxllib.prog.pupil import check_install_package
12
-
13
- check_install_package('anytree')
14
-
15
- import re
16
-
17
- from anytree import Node
18
-
19
-
20
- class XlNode(Node):
21
-
22
- def sign_node(self, check_func, *, flag_name='_flag', child_depth=-1, reset_flag=False):
23
- """ 遍历所有结点
24
-
25
- :param check_func: 检查node是否符合要求
26
- True,自身打上标记2,其余父节点、子结点全部打上1 (这里处理方式后续可以再扩展更灵活)
27
-
28
- 不是那么通用,但也可能存在复用的功能,做了个封装
29
- """
30
- from anytree import PreOrderIter
31
-
32
- if child_depth == -1:
33
- child_depth = None
34
- else:
35
- child_depth += 1
36
-
37
- if reset_flag:
38
- for x in PreOrderIter(self):
39
- setattr(x, flag_name, 0)
40
-
41
- def set_flag(node, flag):
42
- # 结点没有值或者flag小余当前值时,才标记更新为当前flag
43
- setattr(node, flag_name, max(flag, getattr(node, flag_name, 0)))
44
-
45
- cnt = 0
46
- for x in PreOrderIter(self, filter_=check_func):
47
- # 对找到的结点标记2
48
- cnt += 1
49
- set_flag(x, 2)
50
- # 其父结点、子结点标记1
51
- for y in x.ancestors:
52
- set_flag(y, 1)
53
- for y in PreOrderIter(x, maxlevel=child_depth):
54
- set_flag(y, 1)
55
- return cnt
56
-
57
- def render(self, attrname='name', *,
58
- childiter=list, maxlevel=None, filter_=None, # 结点的迭代、过滤等规则
59
- prefix='\t',
60
- dedent=0):
61
- """ 渲染展示结构树
62
-
63
- :pram attrname:
64
- str, 要展示的成员变量值
65
- def func(node, depth),自定义展示样式
66
- :param prefix: 缩进样式
67
- str,每个层级增加的样式,会直接用 prefix*depth作为前缀
68
- tuple(3), 长度3的tuple,对应AbstractStyle(vertical, cont, end)
69
- def func(depth), 输入深度,自定义前缀样式 (未实装,想到这个理念,但觉得用处不大)
70
- :param dedent: 统一减少缩进层级
71
-
72
- """
73
- from anytree import RenderTree
74
-
75
- # 1 文本格式化的规则
76
- if isinstance(attrname, str):
77
- def to_str(node, depth):
78
- if depth < 0:
79
- return ''
80
- return getattr(node, attrname)
81
- elif callable(attrname):
82
- to_str = attrname
83
- else:
84
- raise ValueError
85
-
86
- # 2 遍历结点
87
- ls = []
88
- for pre, fill, node in RenderTree(self, childiter=childiter, maxlevel=maxlevel):
89
- if filter_ and not filter_(node):
90
- continue
91
-
92
- depth = len(pre) // 4 - dedent
93
- ls.append(prefix * depth + to_str(node, depth))
94
-
95
- return '\n'.join(ls)
96
-
97
- def render_html(self, attrname='name', **kwargs):
98
- """ 渲染成html页面内容
99
- """
100
- if isinstance(attrname, str):
101
- def attrname(node, depth):
102
- if depth < 0:
103
- return '<br/>'
104
- content = getattr(node, attrname)
105
- div = f'<div style="padding-left:{depth * 2 + 1}em;text-indent:-1em">{content}</div>'
106
- return div
107
-
108
- return XlNode.render(self, attrname, **kwargs)
109
-
110
- def find_parent(self, check_func):
111
- """ 查找包含自身的所有父结点中,name符合check_func的结点 """
112
- if isinstance(check_func, str):
113
- def _check_func(x):
114
- return x.name == check_func
115
- elif isinstance(check_func, re.Pattern):
116
- def _check_func(x):
117
- return check_func.search(x.name)
118
- elif callable(check_func):
119
- _check_func = check_func
120
- else:
121
- raise ValueError
122
-
123
- p = self
124
- while p and not _check_func(p):
125
- p = p.parent
126
- return p
127
-
128
- def next_preorder_node(self, iter_child=True):
129
- """ 自己写的先序遍历
130
-
131
- 主要应用在xml、bs4相关遍历检索时,有时候遇到特殊结点
132
- 可能子结点不需要解析
133
- 或者整个cur_node和子结点已经被解析完了,不需要再按照通常的先序遍历继续进入子结点
134
- 此时可以 iter_child=False,进入下一个兄弟结点
135
- """
136
- from anytree.util import rightsibling
137
-
138
- if iter_child and self.children:
139
- return self.children[0]
140
- else:
141
- cur_node = self
142
- while True:
143
- parent = cur_node.parent
144
- if parent is None:
145
- return None
146
- sibing = rightsibling(cur_node)
147
- if sibing:
148
- return sibing
149
- cur_node = parent
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2022/04/07 15:45
6
+
7
+ """
8
+ 树形结构相关的处理
9
+ """
10
+
11
+ import re
12
+
13
+ from anytree import Node
14
+
15
+
16
+ class XlNode(Node):
17
+
18
+ def sign_node(self, check_func, *, flag_name='_flag', child_depth=-1, reset_flag=False):
19
+ """ 遍历所有结点
20
+
21
+ :param check_func: 检查node是否符合要求
22
+ True,自身打上标记2,其余父节点、子结点全部打上1 (这里处理方式后续可以再扩展更灵活)
23
+
24
+ 不是那么通用,但也可能存在复用的功能,做了个封装
25
+ """
26
+ from anytree import PreOrderIter
27
+
28
+ if child_depth == -1:
29
+ child_depth = None
30
+ else:
31
+ child_depth += 1
32
+
33
+ if reset_flag:
34
+ for x in PreOrderIter(self):
35
+ setattr(x, flag_name, 0)
36
+
37
+ def set_flag(node, flag):
38
+ # 结点没有值或者flag小余当前值时,才标记更新为当前flag
39
+ setattr(node, flag_name, max(flag, getattr(node, flag_name, 0)))
40
+
41
+ cnt = 0
42
+ for x in PreOrderIter(self, filter_=check_func):
43
+ # 对找到的结点标记2
44
+ cnt += 1
45
+ set_flag(x, 2)
46
+ # 其父结点、子结点标记1
47
+ for y in x.ancestors:
48
+ set_flag(y, 1)
49
+ for y in PreOrderIter(x, maxlevel=child_depth):
50
+ set_flag(y, 1)
51
+ return cnt
52
+
53
+ def render(self, attrname='name', *,
54
+ childiter=list, maxlevel=None, filter_=None, # 结点的迭代、过滤等规则
55
+ prefix='\t',
56
+ dedent=0):
57
+ """ 渲染展示结构树
58
+
59
+ :pram attrname:
60
+ str, 要展示的成员变量值
61
+ def func(node, depth),自定义展示样式
62
+ :param prefix: 缩进样式
63
+ str,每个层级增加的样式,会直接用 prefix*depth作为前缀
64
+ tuple(3), 长度3的tuple,对应AbstractStyle(vertical, cont, end)
65
+ def func(depth), 输入深度,自定义前缀样式 (未实装,想到这个理念,但觉得用处不大)
66
+ :param dedent: 统一减少缩进层级
67
+
68
+ """
69
+ from anytree import RenderTree
70
+
71
+ # 1 文本格式化的规则
72
+ if isinstance(attrname, str):
73
+ def to_str(node, depth):
74
+ if depth < 0:
75
+ return ''
76
+ return getattr(node, attrname)
77
+ elif callable(attrname):
78
+ to_str = attrname
79
+ else:
80
+ raise ValueError
81
+
82
+ # 2 遍历结点
83
+ ls = []
84
+ for pre, fill, node in RenderTree(self, childiter=childiter, maxlevel=maxlevel):
85
+ if filter_ and not filter_(node):
86
+ continue
87
+
88
+ depth = len(pre) // 4 - dedent
89
+ ls.append(prefix * depth + to_str(node, depth))
90
+
91
+ return '\n'.join(ls)
92
+
93
+ def render_html(self, attrname='name', **kwargs):
94
+ """ 渲染成html页面内容
95
+ """
96
+ if isinstance(attrname, str):
97
+ def attrname(node, depth):
98
+ if depth < 0:
99
+ return '<br/>'
100
+ content = getattr(node, attrname)
101
+ div = f'<div style="padding-left:{depth * 2 + 1}em;text-indent:-1em">{content}</div>'
102
+ return div
103
+
104
+ return XlNode.render(self, attrname, **kwargs)
105
+
106
+ def find_parent(self, check_func):
107
+ """ 查找包含自身的所有父结点中,name符合check_func的结点 """
108
+ if isinstance(check_func, str):
109
+ def _check_func(x):
110
+ return x.name == check_func
111
+ elif isinstance(check_func, re.Pattern):
112
+ def _check_func(x):
113
+ return check_func.search(x.name)
114
+ elif callable(check_func):
115
+ _check_func = check_func
116
+ else:
117
+ raise ValueError
118
+
119
+ p = self
120
+ while p and not _check_func(p):
121
+ p = p.parent
122
+ return p
123
+
124
+ def next_preorder_node(self, iter_child=True):
125
+ """ 自己写的先序遍历
126
+
127
+ 主要应用在xml、bs4相关遍历检索时,有时候遇到特殊结点
128
+ 可能子结点不需要解析
129
+ 或者整个cur_node和子结点已经被解析完了,不需要再按照通常的先序遍历继续进入子结点
130
+ 此时可以 iter_child=False,进入下一个兄弟结点
131
+ """
132
+ from anytree.util import rightsibling
133
+
134
+ if iter_child and self.children:
135
+ return self.children[0]
136
+ else:
137
+ cur_node = self
138
+ while True:
139
+ parent = cur_node.parent
140
+ if parent is None:
141
+ return None
142
+ sibing = rightsibling(cur_node)
143
+ if sibing:
144
+ return sibing
145
+ cur_node = parent
pyxllib/algo/unitlib.py CHANGED
@@ -1,66 +1,62 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2021/09/26 09:47
6
-
7
- """ 单位功能库 """
8
-
9
- from pyxllib.prog.pupil import check_install_package
10
-
11
- check_install_package('pint')
12
-
13
- import pint
14
-
15
- import pandas as pd
16
-
17
- from pyxllib.prog.newbie import xl_format_g
18
- from pyxllib.prog.pupil import run_once
19
-
20
-
21
- @run_once
22
- def get_ureg():
23
- """ 如果不想重复生成,可以用这个函数,只定义一个 """
24
- ureg = pint.UnitRegistry()
25
- return ureg
26
-
27
-
28
- def compare_quantity(units, base_unit, scale=None):
29
- """ 同一物理维度的数值量级大小对比
30
-
31
- 比如一套天文长度、距离数据,对比它们之间的量级大小
32
-
33
- :param List[str, str] units: 一组要对比的单位数值
34
- 第1个str是描述,第2个str是数值和单位
35
- :param base_unit: 基础单位值,比如长度是m,也可以用km等自己喜欢的基础单位值
36
- :param scale: 对数值进行缩放
37
- """
38
- ureg = get_ureg()
39
-
40
- # 统一到单位:米
41
- for x in units:
42
- x[1] = ureg(x[1]).to(base_unit)
43
-
44
- # 从小到大排
45
- units.sort(key=lambda x: x[1])
46
-
47
- # 格式化输出r
48
- unit_list = []
49
- if scale:
50
- columns = ['name', f'基础单位:{base_unit}', 'scale', '与上一项倍率']
51
- else:
52
- columns = ['name', f'基础单位:{base_unit}', 'scale', '与上一项倍率']
53
- last_value = units[0][1]
54
- for i, x in enumerate(units, start=1):
55
- x = x.copy()
56
- # x.append('{:.3g}'.format(round(float(x[1] / last_value), 2)))
57
- if scale:
58
- x.append(f'{x[1] * scale:.2e}')
59
- x.append(xl_format_g(round(float(x[1] / last_value), 2)))
60
- last_value = x[1]
61
- x[1] = f'{x[1]:.2e}'
62
- # print(f'{i:>4}', '\t'.join(x))
63
- unit_list.append(x)
64
-
65
- df = pd.DataFrame.from_records(unit_list, columns=columns)
66
- return df
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2021/09/26 09:47
6
+
7
+ """ 单位功能库 """
8
+
9
+ import pint
10
+
11
+ import pandas as pd
12
+
13
+ from pyxllib.prog.newbie import xl_format_g
14
+ from pyxllib.prog.pupil import run_once
15
+
16
+
17
+ @run_once
18
+ def get_ureg():
19
+ """ 如果不想重复生成,可以用这个函数,只定义一个 """
20
+ ureg = pint.UnitRegistry()
21
+ return ureg
22
+
23
+
24
+ def compare_quantity(units, base_unit, scale=None):
25
+ """ 同一物理维度的数值量级大小对比
26
+
27
+ 比如一套天文长度、距离数据,对比它们之间的量级大小
28
+
29
+ :param List[str, str] units: 一组要对比的单位数值
30
+ 第1个str是描述,第2个str是数值和单位
31
+ :param base_unit: 基础单位值,比如长度是m,也可以用km等自己喜欢的基础单位值
32
+ :param scale: 对数值进行缩放
33
+ """
34
+ ureg = get_ureg()
35
+
36
+ # 统一到单位:米
37
+ for x in units:
38
+ x[1] = ureg(x[1]).to(base_unit)
39
+
40
+ # 从小到大排
41
+ units.sort(key=lambda x: x[1])
42
+
43
+ # 格式化输出r
44
+ unit_list = []
45
+ if scale:
46
+ columns = ['name', f'基础单位:{base_unit}', 'scale', '与上一项倍率']
47
+ else:
48
+ columns = ['name', f'基础单位:{base_unit}', 'scale', '与上一项倍率']
49
+ last_value = units[0][1]
50
+ for i, x in enumerate(units, start=1):
51
+ x = x.copy()
52
+ # x.append('{:.3g}'.format(round(float(x[1] / last_value), 2)))
53
+ if scale:
54
+ x.append(f'{x[1] * scale:.2e}')
55
+ x.append(xl_format_g(round(float(x[1] / last_value), 2)))
56
+ last_value = x[1]
57
+ x[1] = f'{x[1]:.2e}'
58
+ # print(f'{i:>4}', '\t'.join(x))
59
+ unit_list.append(x)
60
+
61
+ df = pd.DataFrame.from_records(unit_list, columns=columns)
62
+ return df
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2021/08/01 15:26
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2021/08/01 15:26