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.
- pyxllib/__init__.py +14 -21
- pyxllib/algo/__init__.py +8 -8
- pyxllib/algo/disjoint.py +54 -54
- pyxllib/algo/geo.py +537 -541
- pyxllib/algo/intervals.py +964 -964
- pyxllib/algo/matcher.py +389 -389
- pyxllib/algo/newbie.py +166 -166
- pyxllib/algo/pupil.py +629 -629
- pyxllib/algo/shapelylib.py +67 -67
- pyxllib/algo/specialist.py +241 -241
- pyxllib/algo/stat.py +494 -494
- pyxllib/algo/treelib.py +145 -149
- pyxllib/algo/unitlib.py +62 -66
- pyxllib/autogui/__init__.py +5 -5
- pyxllib/autogui/activewin.py +246 -246
- pyxllib/autogui/all.py +9 -9
- pyxllib/autogui/autogui.py +846 -852
- pyxllib/autogui/uiautolib.py +362 -362
- pyxllib/autogui/virtualkey.py +102 -102
- pyxllib/autogui/wechat.py +827 -827
- pyxllib/autogui/wechat_msg.py +421 -421
- pyxllib/autogui/wxautolib.py +84 -84
- pyxllib/cv/__init__.py +5 -5
- pyxllib/cv/expert.py +267 -267
- pyxllib/cv/imfile.py +159 -159
- pyxllib/cv/imhash.py +39 -39
- pyxllib/cv/pupil.py +9 -9
- pyxllib/cv/rgbfmt.py +1525 -1525
- pyxllib/cv/slidercaptcha.py +137 -137
- pyxllib/cv/trackbartools.py +251 -251
- pyxllib/cv/xlcvlib.py +1040 -1040
- pyxllib/cv/xlpillib.py +423 -423
- pyxllib/data/echarts.py +236 -240
- pyxllib/data/jsonlib.py +85 -89
- pyxllib/data/oss.py +72 -72
- pyxllib/data/pglib.py +1111 -1127
- pyxllib/data/sqlite.py +568 -568
- pyxllib/data/sqllib.py +297 -297
- pyxllib/ext/JLineViewer.py +505 -505
- pyxllib/ext/__init__.py +6 -6
- pyxllib/ext/demolib.py +251 -246
- pyxllib/ext/drissionlib.py +277 -277
- pyxllib/ext/kq5034lib.py +12 -12
- pyxllib/ext/qt.py +449 -449
- pyxllib/ext/robustprocfile.py +493 -497
- pyxllib/ext/seleniumlib.py +76 -76
- pyxllib/ext/tk.py +173 -173
- pyxllib/ext/unixlib.py +821 -827
- pyxllib/ext/utools.py +345 -351
- pyxllib/ext/webhook.py +124 -119
- pyxllib/ext/win32lib.py +40 -40
- pyxllib/ext/wjxlib.py +91 -88
- pyxllib/ext/wpsapi.py +124 -124
- pyxllib/ext/xlwork.py +9 -9
- pyxllib/ext/yuquelib.py +1110 -1105
- pyxllib/file/__init__.py +17 -17
- pyxllib/file/docxlib.py +757 -761
- pyxllib/file/gitlib.py +309 -309
- pyxllib/file/libreoffice.py +165 -165
- pyxllib/file/movielib.py +144 -148
- pyxllib/file/newbie.py +10 -10
- pyxllib/file/onenotelib.py +1469 -1469
- pyxllib/file/packlib/__init__.py +330 -330
- pyxllib/file/packlib/zipfile.py +2441 -2441
- pyxllib/file/pdflib.py +422 -426
- pyxllib/file/pupil.py +185 -185
- pyxllib/file/specialist/__init__.py +681 -685
- pyxllib/file/specialist/dirlib.py +799 -799
- pyxllib/file/specialist/download.py +193 -193
- pyxllib/file/specialist/filelib.py +2825 -2829
- pyxllib/file/xlsxlib.py +3122 -3131
- pyxllib/file/xlsyncfile.py +341 -341
- pyxllib/prog/__init__.py +5 -5
- pyxllib/prog/cachetools.py +58 -64
- pyxllib/prog/deprecatedlib.py +233 -233
- pyxllib/prog/filelock.py +42 -42
- pyxllib/prog/ipyexec.py +253 -253
- pyxllib/prog/multiprogs.py +940 -940
- pyxllib/prog/newbie.py +451 -451
- pyxllib/prog/pupil.py +1208 -1197
- pyxllib/prog/sitepackages.py +33 -33
- pyxllib/prog/specialist/__init__.py +348 -391
- pyxllib/prog/specialist/bc.py +203 -203
- pyxllib/prog/specialist/browser.py +497 -497
- pyxllib/prog/specialist/common.py +347 -347
- pyxllib/prog/specialist/datetime.py +198 -198
- pyxllib/prog/specialist/tictoc.py +240 -240
- pyxllib/prog/specialist/xllog.py +180 -180
- pyxllib/prog/xlosenv.py +110 -108
- pyxllib/stdlib/__init__.py +17 -17
- pyxllib/stdlib/tablepyxl/__init__.py +10 -10
- pyxllib/stdlib/tablepyxl/style.py +303 -303
- pyxllib/stdlib/tablepyxl/tablepyxl.py +130 -130
- pyxllib/text/__init__.py +8 -8
- pyxllib/text/ahocorasick.py +36 -39
- pyxllib/text/airscript.js +754 -744
- pyxllib/text/charclasslib.py +121 -121
- pyxllib/text/jiebalib.py +267 -267
- pyxllib/text/jinjalib.py +27 -32
- pyxllib/text/jsa_ai_prompt.md +271 -271
- pyxllib/text/jscode.py +922 -922
- pyxllib/text/latex/__init__.py +158 -158
- pyxllib/text/levenshtein.py +303 -303
- pyxllib/text/nestenv.py +1215 -1215
- pyxllib/text/newbie.py +300 -300
- pyxllib/text/pupil/__init__.py +8 -8
- pyxllib/text/pupil/common.py +1121 -1121
- pyxllib/text/pupil/xlalign.py +326 -326
- pyxllib/text/pycode.py +47 -47
- pyxllib/text/specialist/__init__.py +8 -8
- pyxllib/text/specialist/common.py +112 -112
- pyxllib/text/specialist/ptag.py +186 -186
- pyxllib/text/spellchecker.py +172 -172
- pyxllib/text/templates/echart_base.html +10 -10
- pyxllib/text/templates/highlight_code.html +16 -16
- pyxllib/text/templates/latex_editor.html +102 -102
- pyxllib/text/vbacode.py +17 -17
- pyxllib/text/xmllib.py +741 -747
- pyxllib/xl.py +42 -39
- pyxllib/xlcv.py +17 -17
- pyxllib-3.201.1.dist-info/METADATA +296 -0
- pyxllib-3.201.1.dist-info/RECORD +125 -0
- {pyxllib-0.3.197.dist-info → pyxllib-3.201.1.dist-info}/licenses/LICENSE +190 -190
- pyxllib/ext/old.py +0 -663
- pyxllib-0.3.197.dist-info/METADATA +0 -48
- pyxllib-0.3.197.dist-info/RECORD +0 -126
- {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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
def func(
|
66
|
-
:param
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
import
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
x
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
pyxllib/autogui/__init__.py
CHANGED
@@ -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
|