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.
- pyxllib/__init__.py +21 -21
- pyxllib/algo/__init__.py +8 -8
- pyxllib/algo/disjoint.py +54 -54
- pyxllib/algo/geo.py +541 -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 +149 -149
- pyxllib/algo/unitlib.py +66 -66
- pyxllib/autogui/__init__.py +5 -5
- pyxllib/autogui/activewin.py +246 -246
- pyxllib/autogui/all.py +9 -9
- pyxllib/autogui/autogui.py +852 -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 +240 -240
- pyxllib/data/jsonlib.py +89 -89
- pyxllib/data/oss.py +72 -72
- pyxllib/data/pglib.py +1127 -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 +246 -246
- pyxllib/ext/drissionlib.py +277 -277
- pyxllib/ext/kq5034lib.py +12 -12
- pyxllib/ext/old.py +663 -663
- pyxllib/ext/qt.py +449 -449
- pyxllib/ext/robustprocfile.py +497 -497
- pyxllib/ext/seleniumlib.py +76 -76
- pyxllib/ext/tk.py +173 -173
- pyxllib/ext/unixlib.py +827 -827
- pyxllib/ext/utools.py +351 -351
- pyxllib/ext/webhook.py +124 -119
- pyxllib/ext/win32lib.py +40 -40
- pyxllib/ext/wjxlib.py +88 -88
- pyxllib/ext/wpsapi.py +124 -124
- pyxllib/ext/xlwork.py +9 -9
- pyxllib/ext/yuquelib.py +1105 -1105
- pyxllib/file/__init__.py +17 -17
- pyxllib/file/docxlib.py +761 -761
- pyxllib/file/gitlib.py +309 -309
- pyxllib/file/libreoffice.py +165 -165
- pyxllib/file/movielib.py +148 -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 +426 -426
- pyxllib/file/pupil.py +185 -185
- pyxllib/file/specialist/__init__.py +685 -685
- pyxllib/file/specialist/dirlib.py +799 -799
- pyxllib/file/specialist/download.py +193 -193
- pyxllib/file/specialist/filelib.py +2829 -2829
- pyxllib/file/xlsxlib.py +3131 -3131
- pyxllib/file/xlsyncfile.py +341 -341
- pyxllib/prog/__init__.py +5 -5
- pyxllib/prog/cachetools.py +64 -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 +1197 -1197
- pyxllib/prog/sitepackages.py +33 -33
- pyxllib/prog/specialist/__init__.py +391 -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 +108 -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 +39 -39
- pyxllib/text/airscript.js +744 -744
- pyxllib/text/charclasslib.py +121 -121
- pyxllib/text/jiebalib.py +267 -267
- pyxllib/text/jinjalib.py +32 -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 +747 -747
- pyxllib/xl.py +42 -39
- pyxllib/xlcv.py +17 -17
- {pyxllib-0.3.197.dist-info → pyxllib-0.3.200.dist-info}/METADATA +1 -1
- pyxllib-0.3.200.dist-info/RECORD +126 -0
- {pyxllib-0.3.197.dist-info → pyxllib-0.3.200.dist-info}/licenses/LICENSE +190 -190
- pyxllib-0.3.197.dist-info/RECORD +0 -126
- {pyxllib-0.3.197.dist-info → pyxllib-0.3.200.dist-info}/WHEEL +0 -0
pyxllib/algo/newbie.py
CHANGED
@@ -1,166 +1,166 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
# @Author : 陈坤泽
|
4
|
-
# @Email : 877362867@qq.com
|
5
|
-
# @Date : 2021/06/06 10:51
|
6
|
-
|
7
|
-
from pyxllib.prog.newbie import round_int
|
8
|
-
|
9
|
-
|
10
|
-
def vector_compare(x, y):
|
11
|
-
"""
|
12
|
-
:param x: 一个数值向量
|
13
|
-
:param y: 一个数值向量,理论上长度要跟x相同
|
14
|
-
:return: 返回<、=、>、?
|
15
|
-
=,各个位置的数值都相同
|
16
|
-
<,x各个位置的值都≤y,且至少有一处值<y
|
17
|
-
>,x各个位置的值都≥,且至少有一处值>y
|
18
|
-
?,其他情况,x、y各有优劣
|
19
|
-
|
20
|
-
>>> vector_compare([1, 2, 3], [1, 3, 3])
|
21
|
-
'<'
|
22
|
-
>>> vector_compare([1, 2, 3], [1, 1, 4])
|
23
|
-
'?'
|
24
|
-
>>> vector_compare({'a': 1, 'b': 2}, {'a': 1, 'b': 2, 'c': 0})
|
25
|
-
'='
|
26
|
-
>>> vector_compare({'b': 3, 'a': 1}, {'a': 1, 'b': 2, 'c': 0})
|
27
|
-
'>'
|
28
|
-
>>> vector_compare({'b': 3, 'a': 1}, {'a': 1, 'b': 2, 'c': 1})
|
29
|
-
'?'
|
30
|
-
"""
|
31
|
-
# 1 不同数据类型处理
|
32
|
-
if isinstance(x, dict) and isinstance(y, dict):
|
33
|
-
# 字典比较比较特别,要先做个映射
|
34
|
-
keys = set(x.keys()) | set(y.keys())
|
35
|
-
a = [x.get(k, 0) - y.get(k, 0) for k in keys]
|
36
|
-
else:
|
37
|
-
a = [i - j for i, j in zip(x, y)]
|
38
|
-
|
39
|
-
# 2 算法
|
40
|
-
n, m = max(a), min(a)
|
41
|
-
if n == m == 0:
|
42
|
-
return '='
|
43
|
-
elif n <= 0:
|
44
|
-
return '<'
|
45
|
-
elif m >= 0:
|
46
|
-
return '>'
|
47
|
-
else:
|
48
|
-
return '?'
|
49
|
-
|
50
|
-
|
51
|
-
def round_unit(x, unit):
|
52
|
-
""" 按特定单位量对x取倍率
|
53
|
-
|
54
|
-
round_int偏向于工程代码简化,round_unit偏向算法,功能不太一样,所以分组不同
|
55
|
-
|
56
|
-
Args:
|
57
|
-
x: 原值
|
58
|
-
unit: 单位量
|
59
|
-
|
60
|
-
Returns: 新值,是unit的整数倍
|
61
|
-
|
62
|
-
>>> round_unit(1.2, 0.5)
|
63
|
-
1.0
|
64
|
-
>>> round_unit(1.6, 0.5)
|
65
|
-
1.5
|
66
|
-
>>> round_unit(7, 5)
|
67
|
-
5
|
68
|
-
>>> round_unit(13, 5)
|
69
|
-
15
|
70
|
-
"""
|
71
|
-
return round_int(x / unit) * unit
|
72
|
-
|
73
|
-
|
74
|
-
def int2excel_col_name(d):
|
75
|
-
"""
|
76
|
-
>>> int2excel_col_name(1)
|
77
|
-
'A'
|
78
|
-
>>> int2excel_col_name(28)
|
79
|
-
'AB'
|
80
|
-
>>> int2excel_col_name(100)
|
81
|
-
'CV'
|
82
|
-
"""
|
83
|
-
s = []
|
84
|
-
while d:
|
85
|
-
t = (d - 1) % 26
|
86
|
-
s.append(chr(65 + t))
|
87
|
-
d = (d - 1) // 26
|
88
|
-
return ''.join(reversed(s))
|
89
|
-
|
90
|
-
|
91
|
-
def excel_col_name2int(s):
|
92
|
-
"""
|
93
|
-
>>> excel_col_name2int('A')
|
94
|
-
1
|
95
|
-
>>> excel_col_name2int('AA')
|
96
|
-
27
|
97
|
-
>>> excel_col_name2int('AB')
|
98
|
-
28
|
99
|
-
"""
|
100
|
-
d = 0
|
101
|
-
for ch in s:
|
102
|
-
d = d * 26 + (ord(ch.upper()) - 64)
|
103
|
-
return d
|
104
|
-
|
105
|
-
|
106
|
-
def gentuple(n, tag):
|
107
|
-
""" 有点类似range函数,但生成的数列更加灵活
|
108
|
-
|
109
|
-
:param n:
|
110
|
-
数组长度
|
111
|
-
:param tag:
|
112
|
-
int类型,从指定数字开始编号
|
113
|
-
0,从0开始编号
|
114
|
-
1,从1开始编号
|
115
|
-
'A',用Excel的形式编号
|
116
|
-
tuple,按枚举值循环显示
|
117
|
-
('A', 'B'):循环使用A、B编号
|
118
|
-
|
119
|
-
>>> gentuple(4, 'A')
|
120
|
-
('A', 'B', 'C', 'D')
|
121
|
-
"""
|
122
|
-
a = [''] * n
|
123
|
-
if isinstance(tag, int):
|
124
|
-
for i in range(n):
|
125
|
-
a[i] = i + tag
|
126
|
-
elif tag == 'A':
|
127
|
-
a = tuple(map(lambda x: int2excel_col_name(x + 1), range(n)))
|
128
|
-
elif isinstance(tag, (list, tuple)):
|
129
|
-
k = len(tag)
|
130
|
-
a = tuple(map(lambda x: tag[x % k], range(n)))
|
131
|
-
return a
|
132
|
-
|
133
|
-
|
134
|
-
def cvsecs(time):
|
135
|
-
""" 从moviepy抄来的,任何时间格式转秒数的功能
|
136
|
-
Will convert any time into seconds.
|
137
|
-
|
138
|
-
If the type of `time` is not valid,
|
139
|
-
it's returned as is.
|
140
|
-
|
141
|
-
Here are the accepted formats::
|
142
|
-
|
143
|
-
>>> cvsecs(15.4) # seconds
|
144
|
-
15.4
|
145
|
-
>>> cvsecs((1, 21.5)) # (min,sec)
|
146
|
-
81.5
|
147
|
-
>>> cvsecs((1, 1, 2)) # (hr, min, sec)
|
148
|
-
3662
|
149
|
-
>>> cvsecs('01:01:33.045')
|
150
|
-
3693.045
|
151
|
-
>>> cvsecs('01:01:33,5') # coma works too
|
152
|
-
3693.5
|
153
|
-
>>> cvsecs('1:33,5') # only minutes and secs
|
154
|
-
99.5
|
155
|
-
>>> cvsecs('33.5') # only secs
|
156
|
-
33.5
|
157
|
-
"""
|
158
|
-
factors = (1, 60, 3600)
|
159
|
-
|
160
|
-
if isinstance(time, str):
|
161
|
-
time = [float(f.replace(',', '.')) for f in time.split(':')]
|
162
|
-
|
163
|
-
if not isinstance(time, (tuple, list)):
|
164
|
-
return time
|
165
|
-
|
166
|
-
return sum(mult * part for mult, part in zip(factors, reversed(time)))
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Author : 陈坤泽
|
4
|
+
# @Email : 877362867@qq.com
|
5
|
+
# @Date : 2021/06/06 10:51
|
6
|
+
|
7
|
+
from pyxllib.prog.newbie import round_int
|
8
|
+
|
9
|
+
|
10
|
+
def vector_compare(x, y):
|
11
|
+
"""
|
12
|
+
:param x: 一个数值向量
|
13
|
+
:param y: 一个数值向量,理论上长度要跟x相同
|
14
|
+
:return: 返回<、=、>、?
|
15
|
+
=,各个位置的数值都相同
|
16
|
+
<,x各个位置的值都≤y,且至少有一处值<y
|
17
|
+
>,x各个位置的值都≥,且至少有一处值>y
|
18
|
+
?,其他情况,x、y各有优劣
|
19
|
+
|
20
|
+
>>> vector_compare([1, 2, 3], [1, 3, 3])
|
21
|
+
'<'
|
22
|
+
>>> vector_compare([1, 2, 3], [1, 1, 4])
|
23
|
+
'?'
|
24
|
+
>>> vector_compare({'a': 1, 'b': 2}, {'a': 1, 'b': 2, 'c': 0})
|
25
|
+
'='
|
26
|
+
>>> vector_compare({'b': 3, 'a': 1}, {'a': 1, 'b': 2, 'c': 0})
|
27
|
+
'>'
|
28
|
+
>>> vector_compare({'b': 3, 'a': 1}, {'a': 1, 'b': 2, 'c': 1})
|
29
|
+
'?'
|
30
|
+
"""
|
31
|
+
# 1 不同数据类型处理
|
32
|
+
if isinstance(x, dict) and isinstance(y, dict):
|
33
|
+
# 字典比较比较特别,要先做个映射
|
34
|
+
keys = set(x.keys()) | set(y.keys())
|
35
|
+
a = [x.get(k, 0) - y.get(k, 0) for k in keys]
|
36
|
+
else:
|
37
|
+
a = [i - j for i, j in zip(x, y)]
|
38
|
+
|
39
|
+
# 2 算法
|
40
|
+
n, m = max(a), min(a)
|
41
|
+
if n == m == 0:
|
42
|
+
return '='
|
43
|
+
elif n <= 0:
|
44
|
+
return '<'
|
45
|
+
elif m >= 0:
|
46
|
+
return '>'
|
47
|
+
else:
|
48
|
+
return '?'
|
49
|
+
|
50
|
+
|
51
|
+
def round_unit(x, unit):
|
52
|
+
""" 按特定单位量对x取倍率
|
53
|
+
|
54
|
+
round_int偏向于工程代码简化,round_unit偏向算法,功能不太一样,所以分组不同
|
55
|
+
|
56
|
+
Args:
|
57
|
+
x: 原值
|
58
|
+
unit: 单位量
|
59
|
+
|
60
|
+
Returns: 新值,是unit的整数倍
|
61
|
+
|
62
|
+
>>> round_unit(1.2, 0.5)
|
63
|
+
1.0
|
64
|
+
>>> round_unit(1.6, 0.5)
|
65
|
+
1.5
|
66
|
+
>>> round_unit(7, 5)
|
67
|
+
5
|
68
|
+
>>> round_unit(13, 5)
|
69
|
+
15
|
70
|
+
"""
|
71
|
+
return round_int(x / unit) * unit
|
72
|
+
|
73
|
+
|
74
|
+
def int2excel_col_name(d):
|
75
|
+
"""
|
76
|
+
>>> int2excel_col_name(1)
|
77
|
+
'A'
|
78
|
+
>>> int2excel_col_name(28)
|
79
|
+
'AB'
|
80
|
+
>>> int2excel_col_name(100)
|
81
|
+
'CV'
|
82
|
+
"""
|
83
|
+
s = []
|
84
|
+
while d:
|
85
|
+
t = (d - 1) % 26
|
86
|
+
s.append(chr(65 + t))
|
87
|
+
d = (d - 1) // 26
|
88
|
+
return ''.join(reversed(s))
|
89
|
+
|
90
|
+
|
91
|
+
def excel_col_name2int(s):
|
92
|
+
"""
|
93
|
+
>>> excel_col_name2int('A')
|
94
|
+
1
|
95
|
+
>>> excel_col_name2int('AA')
|
96
|
+
27
|
97
|
+
>>> excel_col_name2int('AB')
|
98
|
+
28
|
99
|
+
"""
|
100
|
+
d = 0
|
101
|
+
for ch in s:
|
102
|
+
d = d * 26 + (ord(ch.upper()) - 64)
|
103
|
+
return d
|
104
|
+
|
105
|
+
|
106
|
+
def gentuple(n, tag):
|
107
|
+
""" 有点类似range函数,但生成的数列更加灵活
|
108
|
+
|
109
|
+
:param n:
|
110
|
+
数组长度
|
111
|
+
:param tag:
|
112
|
+
int类型,从指定数字开始编号
|
113
|
+
0,从0开始编号
|
114
|
+
1,从1开始编号
|
115
|
+
'A',用Excel的形式编号
|
116
|
+
tuple,按枚举值循环显示
|
117
|
+
('A', 'B'):循环使用A、B编号
|
118
|
+
|
119
|
+
>>> gentuple(4, 'A')
|
120
|
+
('A', 'B', 'C', 'D')
|
121
|
+
"""
|
122
|
+
a = [''] * n
|
123
|
+
if isinstance(tag, int):
|
124
|
+
for i in range(n):
|
125
|
+
a[i] = i + tag
|
126
|
+
elif tag == 'A':
|
127
|
+
a = tuple(map(lambda x: int2excel_col_name(x + 1), range(n)))
|
128
|
+
elif isinstance(tag, (list, tuple)):
|
129
|
+
k = len(tag)
|
130
|
+
a = tuple(map(lambda x: tag[x % k], range(n)))
|
131
|
+
return a
|
132
|
+
|
133
|
+
|
134
|
+
def cvsecs(time):
|
135
|
+
""" 从moviepy抄来的,任何时间格式转秒数的功能
|
136
|
+
Will convert any time into seconds.
|
137
|
+
|
138
|
+
If the type of `time` is not valid,
|
139
|
+
it's returned as is.
|
140
|
+
|
141
|
+
Here are the accepted formats::
|
142
|
+
|
143
|
+
>>> cvsecs(15.4) # seconds
|
144
|
+
15.4
|
145
|
+
>>> cvsecs((1, 21.5)) # (min,sec)
|
146
|
+
81.5
|
147
|
+
>>> cvsecs((1, 1, 2)) # (hr, min, sec)
|
148
|
+
3662
|
149
|
+
>>> cvsecs('01:01:33.045')
|
150
|
+
3693.045
|
151
|
+
>>> cvsecs('01:01:33,5') # coma works too
|
152
|
+
3693.5
|
153
|
+
>>> cvsecs('1:33,5') # only minutes and secs
|
154
|
+
99.5
|
155
|
+
>>> cvsecs('33.5') # only secs
|
156
|
+
33.5
|
157
|
+
"""
|
158
|
+
factors = (1, 60, 3600)
|
159
|
+
|
160
|
+
if isinstance(time, str):
|
161
|
+
time = [float(f.replace(',', '.')) for f in time.split(':')]
|
162
|
+
|
163
|
+
if not isinstance(time, (tuple, list)):
|
164
|
+
return time
|
165
|
+
|
166
|
+
return sum(mult * part for mult, part in zip(factors, reversed(time)))
|