pyxllib 0.3.197__py3-none-any.whl → 0.3.200__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 (126) hide show
  1. pyxllib/__init__.py +21 -21
  2. pyxllib/algo/__init__.py +8 -8
  3. pyxllib/algo/disjoint.py +54 -54
  4. pyxllib/algo/geo.py +541 -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 +149 -149
  13. pyxllib/algo/unitlib.py +66 -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 +852 -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 +240 -240
  34. pyxllib/data/jsonlib.py +89 -89
  35. pyxllib/data/oss.py +72 -72
  36. pyxllib/data/pglib.py +1127 -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 +246 -246
  42. pyxllib/ext/drissionlib.py +277 -277
  43. pyxllib/ext/kq5034lib.py +12 -12
  44. pyxllib/ext/old.py +663 -663
  45. pyxllib/ext/qt.py +449 -449
  46. pyxllib/ext/robustprocfile.py +497 -497
  47. pyxllib/ext/seleniumlib.py +76 -76
  48. pyxllib/ext/tk.py +173 -173
  49. pyxllib/ext/unixlib.py +827 -827
  50. pyxllib/ext/utools.py +351 -351
  51. pyxllib/ext/webhook.py +124 -119
  52. pyxllib/ext/win32lib.py +40 -40
  53. pyxllib/ext/wjxlib.py +88 -88
  54. pyxllib/ext/wpsapi.py +124 -124
  55. pyxllib/ext/xlwork.py +9 -9
  56. pyxllib/ext/yuquelib.py +1105 -1105
  57. pyxllib/file/__init__.py +17 -17
  58. pyxllib/file/docxlib.py +761 -761
  59. pyxllib/file/gitlib.py +309 -309
  60. pyxllib/file/libreoffice.py +165 -165
  61. pyxllib/file/movielib.py +148 -148
  62. pyxllib/file/newbie.py +10 -10
  63. pyxllib/file/onenotelib.py +1469 -1469
  64. pyxllib/file/packlib/__init__.py +330 -330
  65. pyxllib/file/packlib/zipfile.py +2441 -2441
  66. pyxllib/file/pdflib.py +426 -426
  67. pyxllib/file/pupil.py +185 -185
  68. pyxllib/file/specialist/__init__.py +685 -685
  69. pyxllib/file/specialist/dirlib.py +799 -799
  70. pyxllib/file/specialist/download.py +193 -193
  71. pyxllib/file/specialist/filelib.py +2829 -2829
  72. pyxllib/file/xlsxlib.py +3131 -3131
  73. pyxllib/file/xlsyncfile.py +341 -341
  74. pyxllib/prog/__init__.py +5 -5
  75. pyxllib/prog/cachetools.py +64 -64
  76. pyxllib/prog/deprecatedlib.py +233 -233
  77. pyxllib/prog/filelock.py +42 -42
  78. pyxllib/prog/ipyexec.py +253 -253
  79. pyxllib/prog/multiprogs.py +940 -940
  80. pyxllib/prog/newbie.py +451 -451
  81. pyxllib/prog/pupil.py +1197 -1197
  82. pyxllib/prog/sitepackages.py +33 -33
  83. pyxllib/prog/specialist/__init__.py +391 -391
  84. pyxllib/prog/specialist/bc.py +203 -203
  85. pyxllib/prog/specialist/browser.py +497 -497
  86. pyxllib/prog/specialist/common.py +347 -347
  87. pyxllib/prog/specialist/datetime.py +198 -198
  88. pyxllib/prog/specialist/tictoc.py +240 -240
  89. pyxllib/prog/specialist/xllog.py +180 -180
  90. pyxllib/prog/xlosenv.py +108 -108
  91. pyxllib/stdlib/__init__.py +17 -17
  92. pyxllib/stdlib/tablepyxl/__init__.py +10 -10
  93. pyxllib/stdlib/tablepyxl/style.py +303 -303
  94. pyxllib/stdlib/tablepyxl/tablepyxl.py +130 -130
  95. pyxllib/text/__init__.py +8 -8
  96. pyxllib/text/ahocorasick.py +39 -39
  97. pyxllib/text/airscript.js +744 -744
  98. pyxllib/text/charclasslib.py +121 -121
  99. pyxllib/text/jiebalib.py +267 -267
  100. pyxllib/text/jinjalib.py +32 -32
  101. pyxllib/text/jsa_ai_prompt.md +271 -271
  102. pyxllib/text/jscode.py +922 -922
  103. pyxllib/text/latex/__init__.py +158 -158
  104. pyxllib/text/levenshtein.py +303 -303
  105. pyxllib/text/nestenv.py +1215 -1215
  106. pyxllib/text/newbie.py +300 -300
  107. pyxllib/text/pupil/__init__.py +8 -8
  108. pyxllib/text/pupil/common.py +1121 -1121
  109. pyxllib/text/pupil/xlalign.py +326 -326
  110. pyxllib/text/pycode.py +47 -47
  111. pyxllib/text/specialist/__init__.py +8 -8
  112. pyxllib/text/specialist/common.py +112 -112
  113. pyxllib/text/specialist/ptag.py +186 -186
  114. pyxllib/text/spellchecker.py +172 -172
  115. pyxllib/text/templates/echart_base.html +10 -10
  116. pyxllib/text/templates/highlight_code.html +16 -16
  117. pyxllib/text/templates/latex_editor.html +102 -102
  118. pyxllib/text/vbacode.py +17 -17
  119. pyxllib/text/xmllib.py +747 -747
  120. pyxllib/xl.py +42 -39
  121. pyxllib/xlcv.py +17 -17
  122. {pyxllib-0.3.197.dist-info → pyxllib-0.3.200.dist-info}/METADATA +1 -1
  123. pyxllib-0.3.200.dist-info/RECORD +126 -0
  124. {pyxllib-0.3.197.dist-info → pyxllib-0.3.200.dist-info}/licenses/LICENSE +190 -190
  125. pyxllib-0.3.197.dist-info/RECORD +0 -126
  126. {pyxllib-0.3.197.dist-info → pyxllib-0.3.200.dist-info}/WHEEL +0 -0
pyxllib/algo/treelib.py CHANGED
@@ -1,149 +1,149 @@
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
+ 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
pyxllib/algo/unitlib.py CHANGED
@@ -1,66 +1,66 @@
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
+ 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,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