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/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)))