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/data/jsonlib.py CHANGED
@@ -1,89 +1,85 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2024/04/01
6
-
7
- from collections import Counter
8
-
9
- from pyxllib.prog.pupil import check_install_package
10
-
11
- check_install_package('jmespath')
12
-
13
- import jmespath
14
-
15
-
16
- class JsonTool:
17
- @classmethod
18
- def find_paths_by_condition(cls, obj, condition, current_path=''):
19
- """
20
- 根据提供的条件递归搜索JSON对象,查找满足条件的路径。
21
- """
22
- if isinstance(obj, dict):
23
- for k, v in obj.items():
24
- new_path = f"{current_path}.{k}" if current_path else k
25
- if condition(k, v):
26
- yield new_path
27
- else:
28
- if isinstance(v, (dict, list)):
29
- yield from JsonTool.find_paths_by_condition(v, condition, new_path)
30
- elif isinstance(obj, list):
31
- for index, item in enumerate(obj):
32
- new_path = f"{current_path}[{index}]"
33
- if isinstance(item, (dict, list)):
34
- yield from JsonTool.find_paths_by_condition(item, condition, new_path)
35
-
36
- @classmethod
37
- def find_paths_with_key(cls, obj, key, current_path=''):
38
- """
39
- 查找包含指定键名的路径。
40
- """
41
- # 定义一个简单的条件函数,仅基于键名
42
- condition = lambda k, v: k == key
43
- return JsonTool.find_paths_by_condition(obj, condition, current_path)
44
-
45
-
46
- class JsonlTool:
47
- @classmethod
48
- def check_key_positions(cls, json_list, key):
49
- """
50
- 在JSON对象列表中统计每种包含指定键名的路径出现的次数。
51
-
52
- :param json_list: 包含多个JSON对象的列表。
53
- :param key: 要查找的键名。
54
- :return: 一个Counter对象,统计每种路径出现的次数。
55
- """
56
- paths_counter = Counter()
57
- for json_obj in json_list:
58
- # 使用JsonTool查找当前对象中包含指定键的路径
59
- paths = list(JsonTool.find_paths_with_key(json_obj, key))
60
- paths_counter.update(paths)
61
-
62
- return paths_counter
63
-
64
- @classmethod
65
- def check_path_values(cls, json_list, jmespath_expression, value_extractor=lambda x: x):
66
- """
67
- 根据提供的jmespath表达式,在JSON对象列表中直接统计表达式取值的次数。
68
- 支持自定义函数来获取要统计的键。
69
-
70
- :param json_list: 包含多个JSON对象的列表。
71
- :param jmespath_expression: 要应用的jmespath表达式。
72
- :param value_extractor: 一个函数,用于从jmespath.search的结果中提取要统计的值。
73
- :return: 一个Counter对象,统计提取值出现的次数。
74
- """
75
- values_counter = Counter()
76
- for json_obj in json_list:
77
-
78
- # 使用jmespath搜索当前对象
79
- result = jmespath.search(jmespath_expression, json_obj)
80
- # 使用自定义的value_extractor函数提取要统计的值
81
- extracted_values = value_extractor(result)
82
- if not isinstance(extracted_values, list):
83
- extracted_values = [extracted_values]
84
-
85
- for value in extracted_values:
86
- values_counter[value] += 1
87
-
88
- values_counter = Counter(dict(values_counter.most_common()))
89
- return values_counter
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2024/04/01
6
+
7
+ from collections import Counter
8
+
9
+ import jmespath
10
+
11
+
12
+ class JsonTool:
13
+ @classmethod
14
+ def find_paths_by_condition(cls, obj, condition, current_path=''):
15
+ """
16
+ 根据提供的条件递归搜索JSON对象,查找满足条件的路径。
17
+ """
18
+ if isinstance(obj, dict):
19
+ for k, v in obj.items():
20
+ new_path = f"{current_path}.{k}" if current_path else k
21
+ if condition(k, v):
22
+ yield new_path
23
+ else:
24
+ if isinstance(v, (dict, list)):
25
+ yield from JsonTool.find_paths_by_condition(v, condition, new_path)
26
+ elif isinstance(obj, list):
27
+ for index, item in enumerate(obj):
28
+ new_path = f"{current_path}[{index}]"
29
+ if isinstance(item, (dict, list)):
30
+ yield from JsonTool.find_paths_by_condition(item, condition, new_path)
31
+
32
+ @classmethod
33
+ def find_paths_with_key(cls, obj, key, current_path=''):
34
+ """
35
+ 查找包含指定键名的路径。
36
+ """
37
+ # 定义一个简单的条件函数,仅基于键名
38
+ condition = lambda k, v: k == key
39
+ return JsonTool.find_paths_by_condition(obj, condition, current_path)
40
+
41
+
42
+ class JsonlTool:
43
+ @classmethod
44
+ def check_key_positions(cls, json_list, key):
45
+ """
46
+ 在JSON对象列表中统计每种包含指定键名的路径出现的次数。
47
+
48
+ :param json_list: 包含多个JSON对象的列表。
49
+ :param key: 要查找的键名。
50
+ :return: 一个Counter对象,统计每种路径出现的次数。
51
+ """
52
+ paths_counter = Counter()
53
+ for json_obj in json_list:
54
+ # 使用JsonTool查找当前对象中包含指定键的路径
55
+ paths = list(JsonTool.find_paths_with_key(json_obj, key))
56
+ paths_counter.update(paths)
57
+
58
+ return paths_counter
59
+
60
+ @classmethod
61
+ def check_path_values(cls, json_list, jmespath_expression, value_extractor=lambda x: x):
62
+ """
63
+ 根据提供的jmespath表达式,在JSON对象列表中直接统计表达式取值的次数。
64
+ 支持自定义函数来获取要统计的键。
65
+
66
+ :param json_list: 包含多个JSON对象的列表。
67
+ :param jmespath_expression: 要应用的jmespath表达式。
68
+ :param value_extractor: 一个函数,用于从jmespath.search的结果中提取要统计的值。
69
+ :return: 一个Counter对象,统计提取值出现的次数。
70
+ """
71
+ values_counter = Counter()
72
+ for json_obj in json_list:
73
+
74
+ # 使用jmespath搜索当前对象
75
+ result = jmespath.search(jmespath_expression, json_obj)
76
+ # 使用自定义的value_extractor函数提取要统计的值
77
+ extracted_values = value_extractor(result)
78
+ if not isinstance(extracted_values, list):
79
+ extracted_values = [extracted_values]
80
+
81
+ for value in extracted_values:
82
+ values_counter[value] += 1
83
+
84
+ values_counter = Counter(dict(values_counter.most_common()))
85
+ return values_counter
pyxllib/data/oss.py CHANGED
@@ -1,72 +1,72 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2020/06/15
6
-
7
- """
8
- oss2 · PyPI: https://pypi.org/project/oss2/
9
- """
10
-
11
- from pyxllib.prog.pupil import check_install_package
12
-
13
- check_install_package('oss2')
14
-
15
- import oss2
16
-
17
- from pyxllib.file.specialist import File
18
-
19
-
20
- class OssBucket:
21
- def __init__(self, bucket_name, endpoint, access_key_id, access_key_secret):
22
- self.bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name)
23
-
24
- def upload(self, key, localfile, if_exists='replace', force=False):
25
- """ 如果云端已存在,默认会进行覆盖
26
-
27
- :param key: 上传后存储的文件名
28
- :param localfile: 本地文件
29
- :param if_exists:
30
- replace, 如果oss上已存在也替换掉
31
- ignore, 如果oss上已经存在则忽略
32
- :param force: 是否在导入因意外失败后,重复上传,直到成功为止
33
- False 时会报错终止程序
34
- :return: 返回云端是否存在该文件(已存在或者上传后存在,都是True)
35
- """
36
- done = False
37
- while not done:
38
- try:
39
- e = self.check_exists(key)
40
- if e and if_exists == 'ignore': return True
41
- oss2.resumable_upload(self.bucket, key, localfile)
42
- done = True
43
- except Exception as e:
44
- print('如果一直弹出这一条,则要检查oss账号是否设置正确')
45
- if not force:
46
- raise e
47
- return True
48
-
49
- def check_exists(self, key):
50
- """ 检查一个文件在oss是否存在
51
-
52
- :param key:
53
- :return: 存在返回 GetObjectResult 对象,不存在返回False
54
- """
55
- try:
56
- return self.bucket.get_object(key)
57
- except oss2.exceptions.NoSuchKey:
58
- return False
59
-
60
- def download(self, key, localfile):
61
- File(localfile).ensure_parent()
62
- if self.check_exists(key):
63
- return self.bucket.get_object_to_file(key, localfile)
64
- else:
65
- return None
66
-
67
- def ObjectIterator(self, **kwargs):
68
- """ 遍历某个目录下的所有文件(含子目录里的文件)
69
-
70
- >> print(len(list(oss.ObjectIterator(prefix='histudy/tr/teacher/lateximage/'))))
71
- """
72
- return oss2.ObjectIterator(self.bucket, **kwargs)
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2020/06/15
6
+
7
+ """
8
+ oss2 · PyPI: https://pypi.org/project/oss2/
9
+ """
10
+
11
+ from pyxllib.prog.pupil import check_install_package
12
+
13
+ check_install_package('oss2')
14
+
15
+ import oss2
16
+
17
+ from pyxllib.file.specialist import File
18
+
19
+
20
+ class OssBucket:
21
+ def __init__(self, bucket_name, endpoint, access_key_id, access_key_secret):
22
+ self.bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name)
23
+
24
+ def upload(self, key, localfile, if_exists='replace', force=False):
25
+ """ 如果云端已存在,默认会进行覆盖
26
+
27
+ :param key: 上传后存储的文件名
28
+ :param localfile: 本地文件
29
+ :param if_exists:
30
+ replace, 如果oss上已存在也替换掉
31
+ ignore, 如果oss上已经存在则忽略
32
+ :param force: 是否在导入因意外失败后,重复上传,直到成功为止
33
+ False 时会报错终止程序
34
+ :return: 返回云端是否存在该文件(已存在或者上传后存在,都是True)
35
+ """
36
+ done = False
37
+ while not done:
38
+ try:
39
+ e = self.check_exists(key)
40
+ if e and if_exists == 'ignore': return True
41
+ oss2.resumable_upload(self.bucket, key, localfile)
42
+ done = True
43
+ except Exception as e:
44
+ print('如果一直弹出这一条,则要检查oss账号是否设置正确')
45
+ if not force:
46
+ raise e
47
+ return True
48
+
49
+ def check_exists(self, key):
50
+ """ 检查一个文件在oss是否存在
51
+
52
+ :param key:
53
+ :return: 存在返回 GetObjectResult 对象,不存在返回False
54
+ """
55
+ try:
56
+ return self.bucket.get_object(key)
57
+ except oss2.exceptions.NoSuchKey:
58
+ return False
59
+
60
+ def download(self, key, localfile):
61
+ File(localfile).ensure_parent()
62
+ if self.check_exists(key):
63
+ return self.bucket.get_object_to_file(key, localfile)
64
+ else:
65
+ return None
66
+
67
+ def ObjectIterator(self, **kwargs):
68
+ """ 遍历某个目录下的所有文件(含子目录里的文件)
69
+
70
+ >> print(len(list(oss.ObjectIterator(prefix='histudy/tr/teacher/lateximage/'))))
71
+ """
72
+ return oss2.ObjectIterator(self.bucket, **kwargs)