pyxllib 0.0.43__py3-none-any.whl → 0.3.197__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 (186) hide show
  1. pyxllib/__init__.py +9 -2
  2. pyxllib/algo/__init__.py +8 -0
  3. pyxllib/algo/disjoint.py +54 -0
  4. pyxllib/algo/geo.py +541 -0
  5. pyxllib/{util/mathlib.py → algo/intervals.py} +172 -36
  6. pyxllib/algo/matcher.py +389 -0
  7. pyxllib/algo/newbie.py +166 -0
  8. pyxllib/algo/pupil.py +629 -0
  9. pyxllib/algo/shapelylib.py +67 -0
  10. pyxllib/algo/specialist.py +241 -0
  11. pyxllib/algo/stat.py +494 -0
  12. pyxllib/algo/treelib.py +149 -0
  13. pyxllib/algo/unitlib.py +66 -0
  14. pyxllib/autogui/__init__.py +5 -0
  15. pyxllib/autogui/activewin.py +246 -0
  16. pyxllib/autogui/all.py +9 -0
  17. pyxllib/autogui/autogui.py +852 -0
  18. pyxllib/autogui/uiautolib.py +362 -0
  19. pyxllib/autogui/virtualkey.py +102 -0
  20. pyxllib/autogui/wechat.py +827 -0
  21. pyxllib/autogui/wechat_msg.py +421 -0
  22. pyxllib/autogui/wxautolib.py +84 -0
  23. pyxllib/cv/__init__.py +1 -11
  24. pyxllib/cv/expert.py +267 -0
  25. pyxllib/cv/{imlib.py → imfile.py} +18 -83
  26. pyxllib/cv/imhash.py +39 -0
  27. pyxllib/cv/pupil.py +9 -0
  28. pyxllib/cv/rgbfmt.py +1525 -0
  29. pyxllib/cv/slidercaptcha.py +137 -0
  30. pyxllib/cv/trackbartools.py +163 -49
  31. pyxllib/cv/xlcvlib.py +1040 -0
  32. pyxllib/cv/xlpillib.py +423 -0
  33. pyxllib/data/__init__.py +0 -0
  34. pyxllib/data/echarts.py +240 -0
  35. pyxllib/data/jsonlib.py +89 -0
  36. pyxllib/{util/oss2_.py → data/oss.py} +11 -9
  37. pyxllib/data/pglib.py +1127 -0
  38. pyxllib/data/sqlite.py +568 -0
  39. pyxllib/{util → data}/sqllib.py +13 -31
  40. pyxllib/ext/JLineViewer.py +505 -0
  41. pyxllib/ext/__init__.py +6 -0
  42. pyxllib/{util → ext}/demolib.py +119 -35
  43. pyxllib/ext/drissionlib.py +277 -0
  44. pyxllib/ext/kq5034lib.py +12 -0
  45. pyxllib/{util/main.py → ext/old.py} +122 -284
  46. pyxllib/ext/qt.py +449 -0
  47. pyxllib/ext/robustprocfile.py +497 -0
  48. pyxllib/ext/seleniumlib.py +76 -0
  49. pyxllib/{util/tklib.py → ext/tk.py} +10 -11
  50. pyxllib/ext/unixlib.py +827 -0
  51. pyxllib/ext/utools.py +351 -0
  52. pyxllib/{util/webhooklib.py → ext/webhook.py} +45 -17
  53. pyxllib/ext/win32lib.py +40 -0
  54. pyxllib/ext/wjxlib.py +88 -0
  55. pyxllib/ext/wpsapi.py +124 -0
  56. pyxllib/ext/xlwork.py +9 -0
  57. pyxllib/ext/yuquelib.py +1105 -0
  58. pyxllib/file/__init__.py +17 -0
  59. pyxllib/file/docxlib.py +761 -0
  60. pyxllib/{util → file}/gitlib.py +40 -27
  61. pyxllib/file/libreoffice.py +165 -0
  62. pyxllib/file/movielib.py +148 -0
  63. pyxllib/file/newbie.py +10 -0
  64. pyxllib/file/onenotelib.py +1469 -0
  65. pyxllib/file/packlib/__init__.py +330 -0
  66. pyxllib/{util → file/packlib}/zipfile.py +598 -195
  67. pyxllib/file/pdflib.py +426 -0
  68. pyxllib/file/pupil.py +185 -0
  69. pyxllib/file/specialist/__init__.py +685 -0
  70. pyxllib/{basic/_5_dirlib.py → file/specialist/dirlib.py} +364 -93
  71. pyxllib/file/specialist/download.py +193 -0
  72. pyxllib/file/specialist/filelib.py +2829 -0
  73. pyxllib/file/xlsxlib.py +3131 -0
  74. pyxllib/file/xlsyncfile.py +341 -0
  75. pyxllib/prog/__init__.py +5 -0
  76. pyxllib/prog/cachetools.py +64 -0
  77. pyxllib/prog/deprecatedlib.py +233 -0
  78. pyxllib/prog/filelock.py +42 -0
  79. pyxllib/prog/ipyexec.py +253 -0
  80. pyxllib/prog/multiprogs.py +940 -0
  81. pyxllib/prog/newbie.py +451 -0
  82. pyxllib/prog/pupil.py +1197 -0
  83. pyxllib/{sitepackages.py → prog/sitepackages.py} +5 -3
  84. pyxllib/prog/specialist/__init__.py +391 -0
  85. pyxllib/prog/specialist/bc.py +203 -0
  86. pyxllib/prog/specialist/browser.py +497 -0
  87. pyxllib/prog/specialist/common.py +347 -0
  88. pyxllib/prog/specialist/datetime.py +199 -0
  89. pyxllib/prog/specialist/tictoc.py +240 -0
  90. pyxllib/prog/specialist/xllog.py +180 -0
  91. pyxllib/prog/xlosenv.py +108 -0
  92. pyxllib/stdlib/__init__.py +17 -0
  93. pyxllib/{util → stdlib}/tablepyxl/__init__.py +1 -3
  94. pyxllib/{util → stdlib}/tablepyxl/style.py +1 -1
  95. pyxllib/{util → stdlib}/tablepyxl/tablepyxl.py +2 -4
  96. pyxllib/text/__init__.py +8 -0
  97. pyxllib/text/ahocorasick.py +39 -0
  98. pyxllib/text/airscript.js +744 -0
  99. pyxllib/text/charclasslib.py +121 -0
  100. pyxllib/text/jiebalib.py +267 -0
  101. pyxllib/text/jinjalib.py +32 -0
  102. pyxllib/text/jsa_ai_prompt.md +271 -0
  103. pyxllib/text/jscode.py +922 -0
  104. pyxllib/text/latex/__init__.py +158 -0
  105. pyxllib/text/levenshtein.py +303 -0
  106. pyxllib/text/nestenv.py +1215 -0
  107. pyxllib/text/newbie.py +300 -0
  108. pyxllib/text/pupil/__init__.py +8 -0
  109. pyxllib/text/pupil/common.py +1121 -0
  110. pyxllib/text/pupil/xlalign.py +326 -0
  111. pyxllib/text/pycode.py +47 -0
  112. pyxllib/text/specialist/__init__.py +8 -0
  113. pyxllib/text/specialist/common.py +112 -0
  114. pyxllib/text/specialist/ptag.py +186 -0
  115. pyxllib/text/spellchecker.py +172 -0
  116. pyxllib/text/templates/echart_base.html +11 -0
  117. pyxllib/text/templates/highlight_code.html +17 -0
  118. pyxllib/text/templates/latex_editor.html +103 -0
  119. pyxllib/text/vbacode.py +17 -0
  120. pyxllib/text/xmllib.py +747 -0
  121. pyxllib/xl.py +39 -0
  122. pyxllib/xlcv.py +17 -0
  123. pyxllib-0.3.197.dist-info/METADATA +48 -0
  124. pyxllib-0.3.197.dist-info/RECORD +126 -0
  125. {pyxllib-0.0.43.dist-info → pyxllib-0.3.197.dist-info}/WHEEL +4 -5
  126. pyxllib/basic/_1_strlib.py +0 -945
  127. pyxllib/basic/_2_timelib.py +0 -488
  128. pyxllib/basic/_3_pathlib.py +0 -916
  129. pyxllib/basic/_4_loglib.py +0 -419
  130. pyxllib/basic/__init__.py +0 -54
  131. pyxllib/basic/arrow_.py +0 -250
  132. pyxllib/basic/chardet_.py +0 -66
  133. pyxllib/basic/dirlib.py +0 -529
  134. pyxllib/basic/dprint.py +0 -202
  135. pyxllib/basic/extension.py +0 -12
  136. pyxllib/basic/judge.py +0 -31
  137. pyxllib/basic/log.py +0 -204
  138. pyxllib/basic/pathlib_.py +0 -705
  139. pyxllib/basic/pytictoc.py +0 -102
  140. pyxllib/basic/qiniu_.py +0 -61
  141. pyxllib/basic/strlib.py +0 -761
  142. pyxllib/basic/timer.py +0 -132
  143. pyxllib/cv/cv.py +0 -834
  144. pyxllib/cv/cvlib/_1_geo.py +0 -543
  145. pyxllib/cv/cvlib/_2_cvprcs.py +0 -309
  146. pyxllib/cv/cvlib/_2_imgproc.py +0 -594
  147. pyxllib/cv/cvlib/_3_pilprcs.py +0 -80
  148. pyxllib/cv/cvlib/_4_cvimg.py +0 -211
  149. pyxllib/cv/cvlib/__init__.py +0 -10
  150. pyxllib/cv/debugtools.py +0 -82
  151. pyxllib/cv/fitz_.py +0 -300
  152. pyxllib/cv/installer.py +0 -42
  153. pyxllib/debug/_0_installer.py +0 -38
  154. pyxllib/debug/_1_typelib.py +0 -277
  155. pyxllib/debug/_2_chrome.py +0 -198
  156. pyxllib/debug/_3_showdir.py +0 -161
  157. pyxllib/debug/_4_bcompare.py +0 -140
  158. pyxllib/debug/__init__.py +0 -49
  159. pyxllib/debug/bcompare.py +0 -132
  160. pyxllib/debug/chrome.py +0 -198
  161. pyxllib/debug/installer.py +0 -38
  162. pyxllib/debug/showdir.py +0 -158
  163. pyxllib/debug/typelib.py +0 -278
  164. pyxllib/image/__init__.py +0 -12
  165. pyxllib/torch/__init__.py +0 -20
  166. pyxllib/torch/modellib.py +0 -37
  167. pyxllib/torch/trainlib.py +0 -344
  168. pyxllib/util/__init__.py +0 -20
  169. pyxllib/util/aip_.py +0 -141
  170. pyxllib/util/casiadb.py +0 -59
  171. pyxllib/util/excellib.py +0 -495
  172. pyxllib/util/filelib.py +0 -612
  173. pyxllib/util/jsondata.py +0 -27
  174. pyxllib/util/jsondata2.py +0 -92
  175. pyxllib/util/labelmelib.py +0 -139
  176. pyxllib/util/onepy/__init__.py +0 -29
  177. pyxllib/util/onepy/onepy.py +0 -574
  178. pyxllib/util/onepy/onmanager.py +0 -170
  179. pyxllib/util/pyautogui_.py +0 -219
  180. pyxllib/util/textlib.py +0 -1305
  181. pyxllib/util/unorder.py +0 -22
  182. pyxllib/util/xmllib.py +0 -639
  183. pyxllib-0.0.43.dist-info/METADATA +0 -39
  184. pyxllib-0.0.43.dist-info/RECORD +0 -80
  185. pyxllib-0.0.43.dist-info/top_level.txt +0 -1
  186. {pyxllib-0.0.43.dist-info → pyxllib-0.3.197.dist-info/licenses}/LICENSE +0 -0
@@ -1,309 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Data : 2020/11/15 10:09
6
-
7
- from pyxllib.basic import Path
8
- from pyxllib.cv.cvlib._1_geo import *
9
-
10
- import cv2
11
- import PIL.Image
12
- from PIL import Image
13
-
14
- try:
15
- import accimage
16
- except ImportError:
17
- accimage = None
18
- from collections.abc import Sequence, Iterable
19
- from abc import ABC
20
-
21
- ____functional = """
22
- torchvision.transforms搬过来的功能
23
-
24
- 这个库太大了,底层又依赖tensor,
25
- """
26
-
27
-
28
- def is_pil_image(img):
29
- if accimage is not None:
30
- return isinstance(img, (Image.Image, accimage.Image))
31
- else:
32
- return isinstance(img, Image.Image)
33
-
34
-
35
- def is_numpy(img):
36
- return isinstance(img, np.ndarray)
37
-
38
-
39
- def is_numpy_image(img):
40
- return is_numpy(img) and img.ndim in {2, 3}
41
-
42
-
43
- def cv2pil(pic, mode=None):
44
- """Convert a tensor or an ndarray to PIL Image. (删除了tensor的转换功能)
45
-
46
- See :class:`~torchvision.transforms.ToPILImage` for more details.
47
-
48
- Args:
49
- pic (Tensor or numpy.ndarray): Image to be converted to PIL Image.
50
- mode (`PIL.Image mode`_): color space and pixel depth of input data (optional).
51
-
52
- .. _PIL.Image mode: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#concept-modes
53
-
54
- Returns:
55
- PIL Image: Image converted to PIL Image.
56
- """
57
- if pic.ndim not in {2, 3}:
58
- raise ValueError('pic should be 2/3 dimensional. Got {} dimensions.'.format(pic.ndim))
59
- if pic.ndim == 2:
60
- # if 2D image, add channel dimension (HWC)
61
- pic = np.expand_dims(pic, 2)
62
-
63
- npimg = pic
64
-
65
- if npimg.shape[2] == 1:
66
- expected_mode = None
67
- npimg = npimg[:, :, 0]
68
- if npimg.dtype == np.uint8:
69
- expected_mode = 'L'
70
- elif npimg.dtype == np.int16:
71
- expected_mode = 'I;16'
72
- elif npimg.dtype == np.int32:
73
- expected_mode = 'I'
74
- elif npimg.dtype == np.float32:
75
- expected_mode = 'F'
76
- if mode is not None and mode != expected_mode:
77
- raise ValueError("Incorrect mode ({}) supplied for input type {}. Should be {}"
78
- .format(mode, np.dtype, expected_mode))
79
- mode = expected_mode
80
-
81
- elif npimg.shape[2] == 2:
82
- permitted_2_channel_modes = ['LA']
83
- if mode is not None and mode not in permitted_2_channel_modes:
84
- raise ValueError("Only modes {} are supported for 2D inputs".format(permitted_2_channel_modes))
85
-
86
- if mode is None and npimg.dtype == np.uint8:
87
- mode = 'LA'
88
-
89
- elif npimg.shape[2] == 4:
90
- permitted_4_channel_modes = ['RGBA', 'CMYK', 'RGBX']
91
- if mode is not None and mode not in permitted_4_channel_modes:
92
- raise ValueError("Only modes {} are supported for 4D inputs".format(permitted_4_channel_modes))
93
-
94
- if mode is None and npimg.dtype == np.uint8:
95
- mode = 'RGBA'
96
- else:
97
- permitted_3_channel_modes = ['RGB', 'YCbCr', 'HSV']
98
- if mode is not None and mode not in permitted_3_channel_modes:
99
- raise ValueError("Only modes {} are supported for 3D inputs".format(permitted_3_channel_modes))
100
- if mode is None and npimg.dtype == np.uint8:
101
- mode = 'RGB'
102
-
103
- if mode is None:
104
- raise TypeError('Input type {} is not supported'.format(npimg.dtype))
105
-
106
- return Image.fromarray(npimg, mode=mode)
107
-
108
-
109
- ____other_func = """
110
- """
111
-
112
-
113
- def pil2cv(img):
114
- """ pil图片转np图片 """
115
- x = img
116
- y = np_array(x)
117
- y = PIL.Image.fromarray(cv2.cvtColor(y, cv2.COLOR_BGR2RGB)) if y.size else None
118
- return y
119
-
120
-
121
- ____opencv = """
122
- opencv-python文档: https://opencv-python-tutroals.readthedocs.io/en/latest/
123
- pillow文档: https://pillow.readthedocs.io/en/stable/reference/
124
-
125
-
126
- TODO 201115周日20:18
127
- 1、很多功能是新写的,可能有bug,多用多优化~~
128
- 2、画图功能
129
- ① CvPlot有待整合进CvImg
130
- ② PilImg增加对应的画图功能
131
- ③ 整合、统一接口形式、名称
132
- 3、旧的仿射变换等功能
133
- ① 需要整合进CvImg
134
- ② PilImg需要对应的实现
135
- ③ 整合,统一接口
136
- """
137
-
138
-
139
- class CvPlot:
140
- @classmethod
141
- def get_plot_color(cls, src):
142
- """ 获得比较适合的作画颜色
143
-
144
- TODO 可以根据背景色智能推导画线用的颜色,目前是固定红色
145
- """
146
- if src.ndim == 3:
147
- return 0, 0, 255
148
- elif src.ndim == 2:
149
- return 255 # 灰度图,默认先填白色
150
-
151
- @classmethod
152
- def get_plot_args(cls, src, color=None):
153
- # 1 作图颜色
154
- if not color:
155
- color = cls.get_plot_color(src)
156
-
157
- # 2 画布
158
- if len(color) >= 3 and src.ndim <= 2:
159
- dst = cv2.cvtColor(src, cv2.COLOR_GRAY2BGR)
160
- else:
161
- dst = np.array(src)
162
-
163
- return dst, color
164
-
165
- @classmethod
166
- def lines(cls, src, lines, color=None, thickness=1, line_type=cv2.LINE_AA, shift=None):
167
- """ 在src图像上画系列线段
168
- """
169
- # 1 判断 lines 参数内容
170
- lines = np_array(lines).reshape(-1, 4)
171
- if not lines.size:
172
- return src
173
-
174
- # 2 参数
175
- dst, color = cls.get_plot_args(src, color)
176
-
177
- # 3 画线
178
- if lines.any():
179
- for line in lines:
180
- x1, y1, x2, y2 = line
181
- cv2.line(dst, (x1, y1), (x2, y2), color, thickness, line_type)
182
- return dst
183
-
184
- @classmethod
185
- def circles(cls, src, circles, color=None, thickness=1, center=False):
186
- """ 在图片上画圆形
187
-
188
- :param src: 要作画的图
189
- :param circles: 要画的圆形参数 (x, y, 半径 r)
190
- :param color: 画笔颜色
191
- :param center: 是否画出圆心
192
- """
193
- # 1 圆 参数
194
- circles = np_array(circles, dtype=int).reshape(-1, 3)
195
- if not circles.size:
196
- return src
197
-
198
- # 2 参数
199
- dst, color = cls.get_plot_args(src, color)
200
-
201
- # 3 作画
202
- for x in circles:
203
- cv2.circle(dst, (x[0], x[1]), x[2], color, thickness)
204
- if center:
205
- cv2.circle(dst, (x[0], x[1]), 2, color, thickness)
206
-
207
- return dst
208
-
209
-
210
- class CvPrcs:
211
- _show_win_num = 0
212
-
213
- @classmethod
214
- def read(cls, file, flags=1, **kwargs):
215
- """
216
- :param file: 支持非文件路径参数,会做类型转换
217
- 因为这个接口的灵活性,要判断file参数类型等,速度会慢一点点
218
- 如果需要效率,可以显式使用imread、Image.open等明确操作类型
219
- :param flags:
220
- -1,按照图像原样读取,保留Alpha通道(第4通道)
221
- 0,将图像转成单通道灰度图像后读取
222
- 1,将图像转换成3通道BGR彩色图像
223
- """
224
- if is_numpy_image(file):
225
- img = file
226
- elif Path(file).is_file():
227
- # https://www.yuque.com/xlpr/pyxllib/imread
228
- img = cv2.imdecode(np.fromfile(str(file), dtype=np.uint8), flags)
229
- elif is_pil_image(file):
230
- img = pil2cv(file)
231
- else:
232
- raise TypeError(f'类型错误:{type(file)}')
233
- return cls.cvt_channel(img, flags)
234
-
235
- @classmethod
236
- def cvt_channel(cls, img, flags):
237
- """ 确保图片目前是flags指示的通道情况 """
238
- n_c = cls.n_channels(img)
239
- if flags == 0 and n_c > 1:
240
- if n_c == 3:
241
- img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
242
- elif n_c == 4:
243
- img = cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY)
244
- elif flags == 1 and n_c != 3:
245
- if n_c == 1:
246
- img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
247
- elif n_c == 4:
248
- img = cv2.cvtColor(img, cv2.COLOR_BGRA2BGR)
249
- return img
250
-
251
- @classmethod
252
- def write(cls, img, path, if_exists='replace', **kwargs):
253
- if not isinstance(path, Path):
254
- path = Path(path)
255
- data = cv2.imencode(ext=path.suffix, img=img)[1]
256
- return path.write(data.tobytes(), if_exists=if_exists)
257
-
258
- @classmethod
259
- def size(cls, img):
260
- """ 图片尺寸,统一返回(height, width),不含通道 """
261
- return img.shape[:2]
262
-
263
- @classmethod
264
- def n_channels(cls, img):
265
- """ 通道数 """
266
- if img.ndim == 3:
267
- return img.shape[2]
268
- else:
269
- return 1
270
-
271
- @classmethod
272
- def resize(cls, img, size, interpolation=cv2.INTER_CUBIC, **kwargs):
273
- """
274
- :param size: (h, w)
275
- """
276
- return cv2.resize(img, size[::-1], interpolation, **kwargs)
277
-
278
- @classmethod
279
- def show(cls, img, winname=None, flags=0):
280
- """ 展示窗口
281
-
282
- :param winname: 未输入时,则按test1、test2依次生成窗口
283
- :param flags:
284
- cv2.WINDOW_NORMAL,0,输入2等偶数值好像也等价于输入0
285
- cv2.WINDOW_AUTOSIZE,1,输入3等奇数值好像等价于1
286
- cv2.WINDOW_OPENGL,4096
287
- :return:
288
- """
289
- if winname is None:
290
- n = cls._show_win_num + 1
291
- winname = f'test{n}'
292
- cv2.namedWindow(winname, flags)
293
- cv2.imshow(winname, img)
294
-
295
- @classmethod
296
- def reduce_by_area(cls, img, area):
297
- """ 根据面积上限缩小图片
298
-
299
- 即图片面积超过area时,按照等比例缩小到面积为area的图片
300
- """
301
- h, w = cls.size(img)
302
- s = h * w
303
- if s > area:
304
- r = (area / s) ** 0.5
305
- size = int(r * h), int(r * w)
306
- img = cls.resize(img, size)
307
- else:
308
- img = cls
309
- return img