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/text/pycode.py CHANGED
@@ -1,47 +1,47 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2021/08/20 11:46
6
-
7
-
8
- import re
9
-
10
-
11
- def py_remove_interaction_chars(s):
12
- """ 去掉复制的一段代码中,前导的“>>>”标记 """
13
- # 这个算法可能还不够严谨,实际应用中再逐步写鲁棒
14
- # ">>> "、"... "
15
- lines = [line[4:] for line in s.splitlines()]
16
- return '\n'.join(lines)
17
-
18
-
19
- def pycode_sort_import(s):
20
- from pyxllib.text.nestenv import PyNestEnv
21
-
22
- def cmp(line):
23
- """ 将任意一句import映射为一个可比较的list对象
24
-
25
- :return: 2个数值
26
- 1、模块优先级
27
- 2、import在前,from在后
28
- """
29
- name = re.search(r'(?:import|from)\s+(\S+)', line).group(1)
30
- for i, x in enumerate('stdlib prog algo text file cv data extend'.split()):
31
- name = name.replace('pyxllib.' + x, f'{i:02}')
32
- for i, x in enumerate('pyxllib pyxlpr xlproject'.split()):
33
- name = name.replace(x, f'~{i:02}')
34
- for i, x in enumerate('newbie pupil specialist expert'.split()):
35
- name = name.replace('.' + x, f'{i:02}')
36
-
37
- # 忽略大小写
38
- return [name.lower(), line.startswith('import')]
39
-
40
- def sort_part(m):
41
- parts = PyNestEnv(m.group()).imports().strings()
42
- parts = [p.rstrip() + '\n' for p in parts]
43
- parts.sort(key=cmp)
44
- return ''.join(parts)
45
-
46
- res = PyNestEnv(s).imports().sub(sort_part, adjacent=True) # 需要邻接,分块处理
47
- return res
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2021/08/20 11:46
6
+
7
+
8
+ import re
9
+
10
+
11
+ def py_remove_interaction_chars(s):
12
+ """ 去掉复制的一段代码中,前导的“>>>”标记 """
13
+ # 这个算法可能还不够严谨,实际应用中再逐步写鲁棒
14
+ # ">>> "、"... "
15
+ lines = [line[4:] for line in s.splitlines()]
16
+ return '\n'.join(lines)
17
+
18
+
19
+ def pycode_sort_import(s):
20
+ from pyxllib.text.nestenv import PyNestEnv
21
+
22
+ def cmp(line):
23
+ """ 将任意一句import映射为一个可比较的list对象
24
+
25
+ :return: 2个数值
26
+ 1、模块优先级
27
+ 2、import在前,from在后
28
+ """
29
+ name = re.search(r'(?:import|from)\s+(\S+)', line).group(1)
30
+ for i, x in enumerate('stdlib prog algo text file cv data extend'.split()):
31
+ name = name.replace('pyxllib.' + x, f'{i:02}')
32
+ for i, x in enumerate('pyxllib pyxlpr xlproject'.split()):
33
+ name = name.replace(x, f'~{i:02}')
34
+ for i, x in enumerate('newbie pupil specialist expert'.split()):
35
+ name = name.replace('.' + x, f'{i:02}')
36
+
37
+ # 忽略大小写
38
+ return [name.lower(), line.startswith('import')]
39
+
40
+ def sort_part(m):
41
+ parts = PyNestEnv(m.group()).imports().strings()
42
+ parts = [p.rstrip() + '\n' for p in parts]
43
+ parts.sort(key=cmp)
44
+ return ''.join(parts)
45
+
46
+ res = PyNestEnv(s).imports().sub(sort_part, adjacent=True) # 需要邻接,分块处理
47
+ return res
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2021/06/06 17:56
6
-
7
- from pyxllib.text.specialist.common import *
8
- from pyxllib.text.specialist.ptag import *
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2021/06/06 17:56
6
+
7
+ from pyxllib.text.specialist.common import *
8
+ from pyxllib.text.specialist.ptag import *
@@ -1,112 +1,112 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2021/06/06 17:34
6
-
7
- import re
8
- import sys
9
- import textwrap
10
-
11
- from bs4 import BeautifulSoup
12
- import pandas as pd
13
- import requests
14
-
15
- from pyxllib.prog.newbie import len_in_dim2
16
- from pyxllib.prog.pupil import check_install_package
17
- from pyxllib.prog.specialist import dataframe_str
18
- from pyxllib.text.pupil import ContentLine
19
- from pyxllib.file.specialist import get_encoding, File
20
-
21
-
22
- def regularcheck(pattern, string, flags=0):
23
- arr = []
24
- cl = ContentLine(string)
25
- for i, m in enumerate(re.finditer(pattern, string, flags)):
26
- ss = map(lambda x: textwrap.shorten(x, 200), m.groups())
27
- arr.append([i + 1, cl.in_line(m.start(0)), *ss])
28
- tablehead = ['行号'] + list(map(lambda x: f'第{x}组', range(len_in_dim2(arr) - 2)))
29
- df = pd.DataFrame.from_records(arr, columns=tablehead)
30
- res = f'正则模式:{pattern},匹配结果:\n' + dataframe_str(df)
31
- return res
32
-
33
-
34
- def readtext(filename, encoding=None):
35
- """读取普通的文本文件
36
- 会根据tex、py文件情况指定默认编码
37
- """
38
- try:
39
- with open(filename, 'rb') as f: # 以二进制读取文件,注意二进制没有\r\n参数
40
- bstr = f.read()
41
- except FileNotFoundError:
42
- return None
43
-
44
- if not encoding:
45
- encoding = get_encoding(bstr)
46
- s = bstr.decode(encoding=encoding, errors='ignore')
47
- if '\r' in s: # 注意这个问题跟gb2312和gbk是独立的,用gbk编码也要做这个处理
48
- s = s.replace('\r\n', '\n') # 如果用\r\n作为换行符会有一些意外不好处理
49
- return s
50
-
51
-
52
- def ensure_content(ob=None, encoding=None):
53
- """
54
- :param ob:
55
- 未输入:从控制台获取文本
56
- 存在的文件名:读取文件的内容返回
57
- tex、py、
58
- docx、doc
59
- pdf
60
- 有read可调用成员方法:返回f.read()
61
- 其他字符串:返回原值
62
- :param encoding: 强制指定编码
63
- """
64
- # TODO: 如果输入的是一个文件指针,也能调用f.read()返回所有内容
65
- # TODO: 增加鲁棒性判断,如果输入的不是字符串类型也要有出错判断
66
- if ob is None:
67
- return sys.stdin.read() # 注意输入是按 Ctrl + D 结束
68
- elif File(ob): # 如果存在这样的文件,那就读取文件内容(bug点:如果输入是目录名会PermissionError)
69
- if ob.endswith('.docx'): # 这里还要再扩展pdf、doc文件的读取
70
- # 安装详见: https://blog.csdn.net/code4101/article/details/79328636
71
- check_install_package('textract')
72
- text = textract.process(ob)
73
- return text.decode('utf8', errors='ignore')
74
- elif ob.endswith('.doc'):
75
- raise NotImplementedError
76
- elif ob.endswith('.pdf'):
77
- raise NotImplementedError
78
- else: # 按照普通的文本文件读取内容
79
- return readtext(ob, encoding)
80
- else: # 判断不了的情况,也认为是字符串
81
- return ob
82
-
83
-
84
- def file_lastlines(fn, n):
85
- """获得一个文件最后的几行内容
86
- 参考资料: https://stackoverflow.com/questions/136168/get-last-n-lines-of-a-file-with-python-similar-to-tail
87
-
88
- >> s = FileLastLine('book.log', 1)
89
- 'Output written on book.dvi (2 pages, 7812 bytes).'
90
- """
91
- f = ensure_content(fn)
92
- assert n >= 0
93
- pos, lines = n + 1, []
94
- while len(lines) <= n:
95
- try:
96
- f.seek(-pos, 2)
97
- except IOError:
98
- f.seek(0)
99
- break
100
- finally:
101
- lines = list(f)
102
- pos *= 2
103
- f.close()
104
- return ''.join(lines[-n:])
105
-
106
-
107
- def readurl(url):
108
- """从url读取文本"""
109
- r = requests.get(url)
110
- soup = BeautifulSoup(r.text, 'lxml')
111
- s = soup.get_text()
112
- return s
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2021/06/06 17:34
6
+
7
+ import re
8
+ import sys
9
+ import textwrap
10
+
11
+ from bs4 import BeautifulSoup
12
+ import pandas as pd
13
+ import requests
14
+
15
+ from pyxllib.prog.newbie import len_in_dim2
16
+ from pyxllib.prog.pupil import check_install_package
17
+ from pyxllib.prog.specialist import dataframe_str
18
+ from pyxllib.text.pupil import ContentLine
19
+ from pyxllib.file.specialist import get_encoding, File
20
+
21
+
22
+ def regularcheck(pattern, string, flags=0):
23
+ arr = []
24
+ cl = ContentLine(string)
25
+ for i, m in enumerate(re.finditer(pattern, string, flags)):
26
+ ss = map(lambda x: textwrap.shorten(x, 200), m.groups())
27
+ arr.append([i + 1, cl.in_line(m.start(0)), *ss])
28
+ tablehead = ['行号'] + list(map(lambda x: f'第{x}组', range(len_in_dim2(arr) - 2)))
29
+ df = pd.DataFrame.from_records(arr, columns=tablehead)
30
+ res = f'正则模式:{pattern},匹配结果:\n' + dataframe_str(df)
31
+ return res
32
+
33
+
34
+ def readtext(filename, encoding=None):
35
+ """读取普通的文本文件
36
+ 会根据tex、py文件情况指定默认编码
37
+ """
38
+ try:
39
+ with open(filename, 'rb') as f: # 以二进制读取文件,注意二进制没有\r\n参数
40
+ bstr = f.read()
41
+ except FileNotFoundError:
42
+ return None
43
+
44
+ if not encoding:
45
+ encoding = get_encoding(bstr)
46
+ s = bstr.decode(encoding=encoding, errors='ignore')
47
+ if '\r' in s: # 注意这个问题跟gb2312和gbk是独立的,用gbk编码也要做这个处理
48
+ s = s.replace('\r\n', '\n') # 如果用\r\n作为换行符会有一些意外不好处理
49
+ return s
50
+
51
+
52
+ def ensure_content(ob=None, encoding=None):
53
+ """
54
+ :param ob:
55
+ 未输入:从控制台获取文本
56
+ 存在的文件名:读取文件的内容返回
57
+ tex、py、
58
+ docx、doc
59
+ pdf
60
+ 有read可调用成员方法:返回f.read()
61
+ 其他字符串:返回原值
62
+ :param encoding: 强制指定编码
63
+ """
64
+ # TODO: 如果输入的是一个文件指针,也能调用f.read()返回所有内容
65
+ # TODO: 增加鲁棒性判断,如果输入的不是字符串类型也要有出错判断
66
+ if ob is None:
67
+ return sys.stdin.read() # 注意输入是按 Ctrl + D 结束
68
+ elif File(ob): # 如果存在这样的文件,那就读取文件内容(bug点:如果输入是目录名会PermissionError)
69
+ if ob.endswith('.docx'): # 这里还要再扩展pdf、doc文件的读取
70
+ # 安装详见: https://blog.csdn.net/code4101/article/details/79328636
71
+ check_install_package('textract')
72
+ text = textract.process(ob)
73
+ return text.decode('utf8', errors='ignore')
74
+ elif ob.endswith('.doc'):
75
+ raise NotImplementedError
76
+ elif ob.endswith('.pdf'):
77
+ raise NotImplementedError
78
+ else: # 按照普通的文本文件读取内容
79
+ return readtext(ob, encoding)
80
+ else: # 判断不了的情况,也认为是字符串
81
+ return ob
82
+
83
+
84
+ def file_lastlines(fn, n):
85
+ """获得一个文件最后的几行内容
86
+ 参考资料: https://stackoverflow.com/questions/136168/get-last-n-lines-of-a-file-with-python-similar-to-tail
87
+
88
+ >> s = FileLastLine('book.log', 1)
89
+ 'Output written on book.dvi (2 pages, 7812 bytes).'
90
+ """
91
+ f = ensure_content(fn)
92
+ assert n >= 0
93
+ pos, lines = n + 1, []
94
+ while len(lines) <= n:
95
+ try:
96
+ f.seek(-pos, 2)
97
+ except IOError:
98
+ f.seek(0)
99
+ break
100
+ finally:
101
+ lines = list(f)
102
+ pos *= 2
103
+ f.close()
104
+ return ''.join(lines[-n:])
105
+
106
+
107
+ def readurl(url):
108
+ """从url读取文本"""
109
+ r = requests.get(url)
110
+ soup = BeautifulSoup(r.text, 'lxml')
111
+ s = soup.get_text()
112
+ return s