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.
Files changed (126) hide show
  1. pyxllib/__init__.py +21 -21
  2. pyxllib/algo/__init__.py +8 -8
  3. pyxllib/algo/disjoint.py +54 -54
  4. pyxllib/algo/geo.py +541 -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 +149 -149
  13. pyxllib/algo/unitlib.py +66 -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 +852 -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 +240 -240
  34. pyxllib/data/jsonlib.py +89 -89
  35. pyxllib/data/oss.py +72 -72
  36. pyxllib/data/pglib.py +1127 -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 +246 -246
  42. pyxllib/ext/drissionlib.py +277 -277
  43. pyxllib/ext/kq5034lib.py +12 -12
  44. pyxllib/ext/old.py +663 -663
  45. pyxllib/ext/qt.py +449 -449
  46. pyxllib/ext/robustprocfile.py +497 -497
  47. pyxllib/ext/seleniumlib.py +76 -76
  48. pyxllib/ext/tk.py +173 -173
  49. pyxllib/ext/unixlib.py +827 -827
  50. pyxllib/ext/utools.py +351 -351
  51. pyxllib/ext/webhook.py +124 -119
  52. pyxllib/ext/win32lib.py +40 -40
  53. pyxllib/ext/wjxlib.py +88 -88
  54. pyxllib/ext/wpsapi.py +124 -124
  55. pyxllib/ext/xlwork.py +9 -9
  56. pyxllib/ext/yuquelib.py +1105 -1105
  57. pyxllib/file/__init__.py +17 -17
  58. pyxllib/file/docxlib.py +761 -761
  59. pyxllib/file/gitlib.py +309 -309
  60. pyxllib/file/libreoffice.py +165 -165
  61. pyxllib/file/movielib.py +148 -148
  62. pyxllib/file/newbie.py +10 -10
  63. pyxllib/file/onenotelib.py +1469 -1469
  64. pyxllib/file/packlib/__init__.py +330 -330
  65. pyxllib/file/packlib/zipfile.py +2441 -2441
  66. pyxllib/file/pdflib.py +426 -426
  67. pyxllib/file/pupil.py +185 -185
  68. pyxllib/file/specialist/__init__.py +685 -685
  69. pyxllib/file/specialist/dirlib.py +799 -799
  70. pyxllib/file/specialist/download.py +193 -193
  71. pyxllib/file/specialist/filelib.py +2829 -2829
  72. pyxllib/file/xlsxlib.py +3131 -3131
  73. pyxllib/file/xlsyncfile.py +341 -341
  74. pyxllib/prog/__init__.py +5 -5
  75. pyxllib/prog/cachetools.py +64 -64
  76. pyxllib/prog/deprecatedlib.py +233 -233
  77. pyxllib/prog/filelock.py +42 -42
  78. pyxllib/prog/ipyexec.py +253 -253
  79. pyxllib/prog/multiprogs.py +940 -940
  80. pyxllib/prog/newbie.py +451 -451
  81. pyxllib/prog/pupil.py +1197 -1197
  82. pyxllib/prog/sitepackages.py +33 -33
  83. pyxllib/prog/specialist/__init__.py +391 -391
  84. pyxllib/prog/specialist/bc.py +203 -203
  85. pyxllib/prog/specialist/browser.py +497 -497
  86. pyxllib/prog/specialist/common.py +347 -347
  87. pyxllib/prog/specialist/datetime.py +198 -198
  88. pyxllib/prog/specialist/tictoc.py +240 -240
  89. pyxllib/prog/specialist/xllog.py +180 -180
  90. pyxllib/prog/xlosenv.py +108 -108
  91. pyxllib/stdlib/__init__.py +17 -17
  92. pyxllib/stdlib/tablepyxl/__init__.py +10 -10
  93. pyxllib/stdlib/tablepyxl/style.py +303 -303
  94. pyxllib/stdlib/tablepyxl/tablepyxl.py +130 -130
  95. pyxllib/text/__init__.py +8 -8
  96. pyxllib/text/ahocorasick.py +39 -39
  97. pyxllib/text/airscript.js +744 -744
  98. pyxllib/text/charclasslib.py +121 -121
  99. pyxllib/text/jiebalib.py +267 -267
  100. pyxllib/text/jinjalib.py +32 -32
  101. pyxllib/text/jsa_ai_prompt.md +271 -271
  102. pyxllib/text/jscode.py +922 -922
  103. pyxllib/text/latex/__init__.py +158 -158
  104. pyxllib/text/levenshtein.py +303 -303
  105. pyxllib/text/nestenv.py +1215 -1215
  106. pyxllib/text/newbie.py +300 -300
  107. pyxllib/text/pupil/__init__.py +8 -8
  108. pyxllib/text/pupil/common.py +1121 -1121
  109. pyxllib/text/pupil/xlalign.py +326 -326
  110. pyxllib/text/pycode.py +47 -47
  111. pyxllib/text/specialist/__init__.py +8 -8
  112. pyxllib/text/specialist/common.py +112 -112
  113. pyxllib/text/specialist/ptag.py +186 -186
  114. pyxllib/text/spellchecker.py +172 -172
  115. pyxllib/text/templates/echart_base.html +10 -10
  116. pyxllib/text/templates/highlight_code.html +16 -16
  117. pyxllib/text/templates/latex_editor.html +102 -102
  118. pyxllib/text/vbacode.py +17 -17
  119. pyxllib/text/xmllib.py +747 -747
  120. pyxllib/xl.py +42 -39
  121. pyxllib/xlcv.py +17 -17
  122. {pyxllib-0.3.197.dist-info → pyxllib-0.3.200.dist-info}/METADATA +1 -1
  123. pyxllib-0.3.200.dist-info/RECORD +126 -0
  124. {pyxllib-0.3.197.dist-info → pyxllib-0.3.200.dist-info}/licenses/LICENSE +190 -190
  125. pyxllib-0.3.197.dist-info/RECORD +0 -126
  126. {pyxllib-0.3.197.dist-info → pyxllib-0.3.200.dist-info}/WHEEL +0 -0
pyxllib/ext/wpsapi.py CHANGED
@@ -1,124 +1,124 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Date : 2024/07/31
5
-
6
- import os
7
- import re
8
-
9
- import requests
10
- import pandas as pd
11
-
12
-
13
- class WpsOnlineBook:
14
- """ wps的"脚本令牌"调用模式
15
-
16
- 官方文档:https://airsheet.wps.cn/docs/apitoken/api.html
17
- """
18
-
19
- def __1_基础功能(self):
20
- pass
21
-
22
- def __init__(self, file_id, script_id=None, *, token=None):
23
- self.headers = {
24
- 'Content-Type': "application/json",
25
- 'AirScript-Token': token or os.getenv('WPS_SCRIPT_TOKEN', ''),
26
- }
27
- self.file_id = file_id
28
- self.default_script_id = script_id
29
-
30
- def post_request(self, url, payload):
31
- """
32
- 发送 POST 请求到指定的 URL 并返回响应结果
33
- """
34
- try:
35
- resp = requests.post(url, json=payload, headers=self.headers)
36
- resp.raise_for_status() # 如果请求失败会抛出异常
37
- return resp.json()
38
- except requests.exceptions.RequestException as e:
39
- print(f"请求失败: {e}")
40
- return None
41
-
42
- def run_script(self, script_id=None, context_argv=None, sync=True):
43
- """ 原本执行 WPS 脚本并返回执行结果
44
-
45
- :param script_id: 脚本 ID
46
- :param context_argv: 脚本参数 (可选)
47
- context本来能支持这些参数的:
48
- dict argv: 传入的上下文参数对象,比如传入{name: 'xiaomeng', age: 18}, 在 AS 代码中可通过Context.argv.name获取到传入的值
49
- str sheet_name: et,ksheet 运行时所在表名
50
- str range: et,ksheet 运行时所在区域,例如$B$156
51
- str link_from: et,ksheet 点击超链接所在单元格
52
- str db_active_view: db 运行时所在 view 名
53
- str db_selection: db 运行时所在选区
54
- 但是,sheet_name, range等,并看不到对运行代码有什么实质影响,不影响active,而且as里也引用不了sheet_name等值
55
- 所以退化,简化为只要传入content_argv参数就行
56
- :param sync:
57
- True, 同步运行
58
- False, 异步运行
59
-
60
- 这个接口跟普通as一样,运行有30秒时限
61
- """
62
- url = f"https://www.kdocs.cn/api/v3/ide/file/{self.file_id}/script/{script_id}/{'sync_task' if sync else 'task'}"
63
- payload = {
64
- "Context": {'argv': context_argv or {}}
65
- }
66
- res = self.post_request(url, payload)
67
- if sync:
68
- return res['data']['result']
69
- else:
70
- return res
71
-
72
- def __2_封装的更高级的接口(self):
73
- """ 这系列的功能需要配套这个框架范式使用:
74
- https://github.com/XLPRUtils/pyxllib/blob/master/pyxllib/text/airscript.js
75
- """
76
- pass
77
-
78
- def run_func(self, func_name, *args):
79
- """ 我自己常用的jsa框架,jsa那边已经简化了对接模式,所以一般都只用这个高级的接口即可
80
- (旧函数名run_script2不再使用)
81
- """
82
- return self.run_script(self.default_script_id, context_argv={'funcName': func_name, 'args': args})
83
-
84
- def get_sheet_data(self, sheet_name, fields, data_row=0, filter_empty_rows=True, *,
85
- return_mode='pd') -> pd.DataFrame:
86
- """ 获取某张sheet表格数据
87
-
88
- :param sheet_name: sheet表名
89
- :param list[str] fields: 字段名列表
90
- :param int data_row: 数据起始行,详细用法见packTableDataFields
91
- :param return_mode: 'pd' or 'json'
92
- """
93
- data = self.run_func('packTableDataFields', sheet_name, fields, data_row, filter_empty_rows)
94
- if return_mode == 'json':
95
- return data
96
- elif return_mode == 'pd':
97
- return pd.DataFrame(data)
98
-
99
- def write_arr(self, rows, start_cell, batch_size=None):
100
- """ 把一个二维数组数据写入表格
101
-
102
- :param rows: 一个n*m的数据
103
- :param start_cell: 写入的起始位置,例如'A1',也可以使用Sheet1!A1的格式表示具体的表格位置
104
- :param batch_size: 为了避免一次写入内容过多,超时写入失败,可以分成多批运行
105
- 这里写每批的数据行数
106
- 默认表示一次性全部提交
107
- :return:
108
- """
109
- if batch_size is None:
110
- batch_size = len(rows) # 如果未指定批次大小,一次性写入所有行
111
-
112
- def func(m):
113
- return str(int(m.group()) + batch_size)
114
-
115
- current_cell = start_cell
116
- for start in range(0, len(rows), batch_size):
117
- end = start + batch_size
118
- batch_rows = rows[start:end]
119
- self.run_func('writeArrToSheet', batch_rows, current_cell)
120
- current_cell = re.sub(r'\d+$', func, current_cell)
121
-
122
-
123
- if __name__ == '__main__':
124
- pass
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Date : 2024/07/31
5
+
6
+ import os
7
+ import re
8
+
9
+ import requests
10
+ import pandas as pd
11
+
12
+
13
+ class WpsOnlineBook:
14
+ """ wps的"脚本令牌"调用模式
15
+
16
+ 官方文档:https://airsheet.wps.cn/docs/apitoken/api.html
17
+ """
18
+
19
+ def __1_基础功能(self):
20
+ pass
21
+
22
+ def __init__(self, file_id, script_id=None, *, token=None):
23
+ self.headers = {
24
+ 'Content-Type': "application/json",
25
+ 'AirScript-Token': token or os.getenv('WPS_SCRIPT_TOKEN', ''),
26
+ }
27
+ self.file_id = file_id
28
+ self.default_script_id = script_id
29
+
30
+ def post_request(self, url, payload):
31
+ """
32
+ 发送 POST 请求到指定的 URL 并返回响应结果
33
+ """
34
+ try:
35
+ resp = requests.post(url, json=payload, headers=self.headers)
36
+ resp.raise_for_status() # 如果请求失败会抛出异常
37
+ return resp.json()
38
+ except requests.exceptions.RequestException as e:
39
+ print(f"请求失败: {e}")
40
+ return None
41
+
42
+ def run_script(self, script_id=None, context_argv=None, sync=True):
43
+ """ 原本执行 WPS 脚本并返回执行结果
44
+
45
+ :param script_id: 脚本 ID
46
+ :param context_argv: 脚本参数 (可选)
47
+ context本来能支持这些参数的:
48
+ dict argv: 传入的上下文参数对象,比如传入{name: 'xiaomeng', age: 18}, 在 AS 代码中可通过Context.argv.name获取到传入的值
49
+ str sheet_name: et,ksheet 运行时所在表名
50
+ str range: et,ksheet 运行时所在区域,例如$B$156
51
+ str link_from: et,ksheet 点击超链接所在单元格
52
+ str db_active_view: db 运行时所在 view 名
53
+ str db_selection: db 运行时所在选区
54
+ 但是,sheet_name, range等,并看不到对运行代码有什么实质影响,不影响active,而且as里也引用不了sheet_name等值
55
+ 所以退化,简化为只要传入content_argv参数就行
56
+ :param sync:
57
+ True, 同步运行
58
+ False, 异步运行
59
+
60
+ 这个接口跟普通as一样,运行有30秒时限
61
+ """
62
+ url = f"https://www.kdocs.cn/api/v3/ide/file/{self.file_id}/script/{script_id}/{'sync_task' if sync else 'task'}"
63
+ payload = {
64
+ "Context": {'argv': context_argv or {}}
65
+ }
66
+ res = self.post_request(url, payload)
67
+ if sync:
68
+ return res['data']['result']
69
+ else:
70
+ return res
71
+
72
+ def __2_封装的更高级的接口(self):
73
+ """ 这系列的功能需要配套这个框架范式使用:
74
+ https://github.com/XLPRUtils/pyxllib/blob/master/pyxllib/text/airscript.js
75
+ """
76
+ pass
77
+
78
+ def run_func(self, func_name, *args):
79
+ """ 我自己常用的jsa框架,jsa那边已经简化了对接模式,所以一般都只用这个高级的接口即可
80
+ (旧函数名run_script2不再使用)
81
+ """
82
+ return self.run_script(self.default_script_id, context_argv={'funcName': func_name, 'args': args})
83
+
84
+ def get_sheet_data(self, sheet_name, fields, data_row=0, filter_empty_rows=True, *,
85
+ return_mode='pd') -> pd.DataFrame:
86
+ """ 获取某张sheet表格数据
87
+
88
+ :param sheet_name: sheet表名
89
+ :param list[str] fields: 字段名列表
90
+ :param int data_row: 数据起始行,详细用法见packTableDataFields
91
+ :param return_mode: 'pd' or 'json'
92
+ """
93
+ data = self.run_func('packTableDataFields', sheet_name, fields, data_row, filter_empty_rows)
94
+ if return_mode == 'json':
95
+ return data
96
+ elif return_mode == 'pd':
97
+ return pd.DataFrame(data)
98
+
99
+ def write_arr(self, rows, start_cell, batch_size=None):
100
+ """ 把一个二维数组数据写入表格
101
+
102
+ :param rows: 一个n*m的数据
103
+ :param start_cell: 写入的起始位置,例如'A1',也可以使用Sheet1!A1的格式表示具体的表格位置
104
+ :param batch_size: 为了避免一次写入内容过多,超时写入失败,可以分成多批运行
105
+ 这里写每批的数据行数
106
+ 默认表示一次性全部提交
107
+ :return:
108
+ """
109
+ if batch_size is None:
110
+ batch_size = len(rows) # 如果未指定批次大小,一次性写入所有行
111
+
112
+ def func(m):
113
+ return str(int(m.group()) + batch_size)
114
+
115
+ current_cell = start_cell
116
+ for start in range(0, len(rows), batch_size):
117
+ end = start + batch_size
118
+ batch_rows = rows[start:end]
119
+ self.run_func('writeArrToSheet', batch_rows, current_cell)
120
+ current_cell = re.sub(r'\d+$', func, current_cell)
121
+
122
+
123
+ if __name__ == '__main__':
124
+ pass
pyxllib/ext/xlwork.py CHANGED
@@ -1,9 +1,9 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2025/04/17
6
-
7
- """ code4101的众多账号密码管理接口,工作目录等控制位置 """
8
-
9
-
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2025/04/17
6
+
7
+ """ code4101的众多账号密码管理接口,工作目录等控制位置 """
8
+
9
+