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
@@ -1,186 +1,186 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2021/06/06 17:22
6
-
7
- """ 百分注格式处理 """
8
-
9
- import re
10
-
11
- import bs4
12
- from bs4 import BeautifulSoup
13
-
14
- from pyxllib.prog.pupil import dprint
15
- from pyxllib.text.pupil import grp_bracket
16
-
17
-
18
- def gettag_name(tagstr):
19
- """
20
- >>> gettag_name('%<topic type=danxuan description=单选题>')
21
- 'topic'
22
- >>> gettag_name('</topic>')
23
- 'topic'
24
- """
25
- m = re.search(r'</?([a-zA-Z_]+)', tagstr)
26
- if m:
27
- return m.group(1)
28
- else:
29
- return None
30
-
31
-
32
- def settag_name(tagstr, *, new_name=None, switch=None):
33
- """设置标签名称,或者将标签类型设为close类型
34
-
35
- >>> settag_name('%<topic type=danxuan description=单选题>', new_name='mdzz')
36
- '%<mdzz type=danxuan description=单选题>'
37
- >>> settag_name('<topic type=danxuan description=单选题>', switch=False)
38
- '</topic>'
39
- """
40
- if new_name: # 是否设置新名称
41
- tagstr = re.sub(r'(</?)([a-zA-Z_]+)', lambda m: m.group(1) + new_name, tagstr)
42
-
43
- if switch is not None: # 是否设置标签开关
44
- if switch: # 将标签改为开
45
- tagstr = tagstr.replace('</', '<')
46
- else: # 将标签改为关
47
- name = gettag_name(tagstr)
48
- res = f'</{name}>' # 会删除所有attr属性
49
- tagstr = '%' + res if '%<' in tagstr else res
50
-
51
- return tagstr
52
-
53
-
54
- def gettag_attr(tagstr, attrname):
55
- r"""tagstr是一个标签字符串,attrname是要索引的名字
56
- 返回属性值,如果不存在该属性则返回None
57
-
58
- >>> gettag_attr('%<topic type=danxuan description=单选题> 123\n<a b=c></a>', 'type')
59
- 'danxuan'
60
- >>> gettag_attr('%<topic type="dan xu an" description=单选题>', 'type')
61
- 'dan xu an'
62
- >>> gettag_attr("%<topic type='dan xu an' description=单选题>", 'type')
63
- 'dan xu an'
64
- >>> gettag_attr('%<topic type=dan xu an description=单选题>', 'description')
65
- '单选题'
66
- >>> gettag_attr('%<topic type=dan xu an description=单选题>', 'type')
67
- 'dan'
68
- >>> gettag_attr('%<topic type=danxuan description=单选题 >', 'description')
69
- '单选题'
70
- >>> gettag_attr('%<topic type=danxuan description=单选题 >', 'description123') is None
71
- True
72
- """
73
- soup = BeautifulSoup(tagstr, 'lxml')
74
- try:
75
- for tag in soup.p.contents:
76
- if isinstance(tag, bs4.Tag):
77
- return tag.get(attrname, None)
78
- except AttributeError:
79
- dprint(tagstr)
80
- return None
81
-
82
-
83
- def settag_attr(tagstr, attrname, target_value):
84
- r"""tagstr是一个标签字符串,attrname是要索引的名字
85
- 重设该属性的值,设置成功则返回新的tagstr;否则返回原始值
86
-
87
- close类型不能用这个命令,用了的话不进行任何处理,直接返回
88
-
89
- >>> settag_attr('%<topic type=danxuan> 123\n<a></a>', 'type', 'tiankong')
90
- '%<topic type="tiankong"> 123\n<a></a>'
91
- >>> settag_attr('%<topic>', 'type', 'tiankong')
92
- '%<topic type="tiankong">'
93
- >>> settag_attr('</topic>', 'type', 'tiankong')
94
- '</topic>'
95
- >>> settag_attr('<seq value="1">', 'value', '练习1.2')
96
- '<seq value="练习1.2">'
97
- >>> settag_attr('<seq type=123 value=1>', 'type', '') # 删除attr操作
98
- '<seq value=1>'
99
- >>> settag_attr('<seq type=123 value=1>', 'value', '') # 删除attr操作
100
- '<seq type=123>'
101
- >>> settag_attr('<seq type=123 value=1>', 'haha', '') # 删除attr操作
102
- '<seq type=123 value=1>'
103
- """
104
- # 如果是close类型是不处理的
105
- if tagstr.startswith('</'): return tagstr
106
-
107
- # 预处理targetValue的值,删除空白
108
- target_value = re.sub(r'\s', '', target_value)
109
- r = re.compile(r'(<|\s)(' + attrname + r'=)(.+?)(\s+\w+=|\s*>)')
110
- gs = r.search(tagstr)
111
- if target_value:
112
- if not gs: # 如果未找到则添加attr与value
113
- n = tagstr.find('>')
114
- return tagstr[:n] + ' ' + attrname + '="' + target_value + '"' + tagstr[n:]
115
- else: # 如果找到则更改value
116
- # TODO: 目前的替换值是直接放到正则式里了,这样会有很大的风险,后续看看能不能优化这个处理算法
117
- return r.sub(r'\1\g<2>"' + target_value + r'"\4', tagstr)
118
- else:
119
- if gs:
120
- return r.sub(r'\4', tagstr)
121
- else:
122
- return tagstr
123
-
124
-
125
- def brieftexstr(s):
126
- """对比两段tex文本
127
- """
128
- # 1 删除百分注
129
- s = re.sub(r'%' + grp_bracket(2, '<', '>'), r'', s)
130
- # 2 删除所有空白字符
131
- # debuglib.dprint(debuglib.typename(s))
132
- s = re.sub(r'\s+', '', s)
133
- # 3 转小写字符
134
- s = s.casefold()
135
- return s
136
-
137
-
138
- # 默认不建议开,编校如果用的多,可以在那边定义
139
- # 定义常用的几种格式,并且只匹配抓取花括号里面的值,不要花括号本身
140
- # SQUARE3 = r'\\[(' + grp_bracket(3, '[')[3:-3] + r')\\]'
141
- # BRACE1 = '{(' + grp_bracket(1)[1:-1] + ')}'
142
- # BRACE2 = '{(' + grp_bracket(2)[1:-1] + ')}'
143
- # BRACE3 = '{(' + grp_bracket(3)[1:-1] + ')}'
144
- # BRACE4 = '{(' + grp_bracket(4)[1:-1] + ')}'
145
- # BRACE5 = '{(' + grp_bracket(5)[1:-1] + ')}'
146
- r""" 使用示例
147
- >> m = re.search(r'\\multicolumn' + BRACE3*3, r'\multicolumn{2}{|c|}{$2^{12}$个数}')
148
- >> m.groups()
149
- ('2', '|c|', '$2^{12}$个数')
150
- """
151
-
152
-
153
- def grp_topic(*, type_value=None):
154
- """定位topic
155
-
156
- :param type_value: 设置题目类型(TODO: 功能尚未开发)
157
- """
158
- s = r'%<topic.*?%</topic>' # 注意外部使用的re要开flags=re.DOTALL
159
- return s
160
-
161
-
162
- def grp_figure(cnt_groups=0, parpic=False):
163
- r""" 生成跟图片匹配相关的表达式
164
-
165
- D:\2017LaTeX\D招培试卷\高中地理,用过 \captionfig{3-3.eps}{图~3}
166
- 奕本从2018秋季教材开始使用多种图片格式
167
-
168
- 191224周二18:20 更新:匹配到的图片名不带花括号
169
- """
170
- ibrace3 = grp_bracket(3, inner=True)
171
-
172
- if cnt_groups == 0: # 不分组
173
- s = r'\\(?:includegraphics|figt|figc|figr|fig).*?' + grp_bracket(3) # 注意第1组fig要放最后面
174
- elif cnt_groups == 1: # 只分1组,那么只对图片括号内的内容分组
175
- s = r'\\(?:includegraphics|figt|figc|figr|fig).*?' + ibrace3
176
- elif cnt_groups == 2: # 只分2组,那么只对插图命令和图片分组
177
- s = r'\\(includegraphics|figt|figc|figr|fig).*?' + ibrace3
178
- elif cnt_groups == 3:
179
- s = r'\\(includegraphics|figt|figc|figr|fig)(.*?)' + ibrace3
180
- else:
181
- s = None
182
-
183
- if s and parpic:
184
- s = r'{?\\parpic(?:\[.\])?{' + s + r'}*'
185
-
186
- return s
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2021/06/06 17:22
6
+
7
+ """ 百分注格式处理 """
8
+
9
+ import re
10
+
11
+ import bs4
12
+ from bs4 import BeautifulSoup
13
+
14
+ from pyxllib.prog.pupil import dprint
15
+ from pyxllib.text.pupil import grp_bracket
16
+
17
+
18
+ def gettag_name(tagstr):
19
+ """
20
+ >>> gettag_name('%<topic type=danxuan description=单选题>')
21
+ 'topic'
22
+ >>> gettag_name('</topic>')
23
+ 'topic'
24
+ """
25
+ m = re.search(r'</?([a-zA-Z_]+)', tagstr)
26
+ if m:
27
+ return m.group(1)
28
+ else:
29
+ return None
30
+
31
+
32
+ def settag_name(tagstr, *, new_name=None, switch=None):
33
+ """设置标签名称,或者将标签类型设为close类型
34
+
35
+ >>> settag_name('%<topic type=danxuan description=单选题>', new_name='mdzz')
36
+ '%<mdzz type=danxuan description=单选题>'
37
+ >>> settag_name('<topic type=danxuan description=单选题>', switch=False)
38
+ '</topic>'
39
+ """
40
+ if new_name: # 是否设置新名称
41
+ tagstr = re.sub(r'(</?)([a-zA-Z_]+)', lambda m: m.group(1) + new_name, tagstr)
42
+
43
+ if switch is not None: # 是否设置标签开关
44
+ if switch: # 将标签改为开
45
+ tagstr = tagstr.replace('</', '<')
46
+ else: # 将标签改为关
47
+ name = gettag_name(tagstr)
48
+ res = f'</{name}>' # 会删除所有attr属性
49
+ tagstr = '%' + res if '%<' in tagstr else res
50
+
51
+ return tagstr
52
+
53
+
54
+ def gettag_attr(tagstr, attrname):
55
+ r"""tagstr是一个标签字符串,attrname是要索引的名字
56
+ 返回属性值,如果不存在该属性则返回None
57
+
58
+ >>> gettag_attr('%<topic type=danxuan description=单选题> 123\n<a b=c></a>', 'type')
59
+ 'danxuan'
60
+ >>> gettag_attr('%<topic type="dan xu an" description=单选题>', 'type')
61
+ 'dan xu an'
62
+ >>> gettag_attr("%<topic type='dan xu an' description=单选题>", 'type')
63
+ 'dan xu an'
64
+ >>> gettag_attr('%<topic type=dan xu an description=单选题>', 'description')
65
+ '单选题'
66
+ >>> gettag_attr('%<topic type=dan xu an description=单选题>', 'type')
67
+ 'dan'
68
+ >>> gettag_attr('%<topic type=danxuan description=单选题 >', 'description')
69
+ '单选题'
70
+ >>> gettag_attr('%<topic type=danxuan description=单选题 >', 'description123') is None
71
+ True
72
+ """
73
+ soup = BeautifulSoup(tagstr, 'lxml')
74
+ try:
75
+ for tag in soup.p.contents:
76
+ if isinstance(tag, bs4.Tag):
77
+ return tag.get(attrname, None)
78
+ except AttributeError:
79
+ dprint(tagstr)
80
+ return None
81
+
82
+
83
+ def settag_attr(tagstr, attrname, target_value):
84
+ r"""tagstr是一个标签字符串,attrname是要索引的名字
85
+ 重设该属性的值,设置成功则返回新的tagstr;否则返回原始值
86
+
87
+ close类型不能用这个命令,用了的话不进行任何处理,直接返回
88
+
89
+ >>> settag_attr('%<topic type=danxuan> 123\n<a></a>', 'type', 'tiankong')
90
+ '%<topic type="tiankong"> 123\n<a></a>'
91
+ >>> settag_attr('%<topic>', 'type', 'tiankong')
92
+ '%<topic type="tiankong">'
93
+ >>> settag_attr('</topic>', 'type', 'tiankong')
94
+ '</topic>'
95
+ >>> settag_attr('<seq value="1">', 'value', '练习1.2')
96
+ '<seq value="练习1.2">'
97
+ >>> settag_attr('<seq type=123 value=1>', 'type', '') # 删除attr操作
98
+ '<seq value=1>'
99
+ >>> settag_attr('<seq type=123 value=1>', 'value', '') # 删除attr操作
100
+ '<seq type=123>'
101
+ >>> settag_attr('<seq type=123 value=1>', 'haha', '') # 删除attr操作
102
+ '<seq type=123 value=1>'
103
+ """
104
+ # 如果是close类型是不处理的
105
+ if tagstr.startswith('</'): return tagstr
106
+
107
+ # 预处理targetValue的值,删除空白
108
+ target_value = re.sub(r'\s', '', target_value)
109
+ r = re.compile(r'(<|\s)(' + attrname + r'=)(.+?)(\s+\w+=|\s*>)')
110
+ gs = r.search(tagstr)
111
+ if target_value:
112
+ if not gs: # 如果未找到则添加attr与value
113
+ n = tagstr.find('>')
114
+ return tagstr[:n] + ' ' + attrname + '="' + target_value + '"' + tagstr[n:]
115
+ else: # 如果找到则更改value
116
+ # TODO: 目前的替换值是直接放到正则式里了,这样会有很大的风险,后续看看能不能优化这个处理算法
117
+ return r.sub(r'\1\g<2>"' + target_value + r'"\4', tagstr)
118
+ else:
119
+ if gs:
120
+ return r.sub(r'\4', tagstr)
121
+ else:
122
+ return tagstr
123
+
124
+
125
+ def brieftexstr(s):
126
+ """对比两段tex文本
127
+ """
128
+ # 1 删除百分注
129
+ s = re.sub(r'%' + grp_bracket(2, '<', '>'), r'', s)
130
+ # 2 删除所有空白字符
131
+ # debuglib.dprint(debuglib.typename(s))
132
+ s = re.sub(r'\s+', '', s)
133
+ # 3 转小写字符
134
+ s = s.casefold()
135
+ return s
136
+
137
+
138
+ # 默认不建议开,编校如果用的多,可以在那边定义
139
+ # 定义常用的几种格式,并且只匹配抓取花括号里面的值,不要花括号本身
140
+ # SQUARE3 = r'\\[(' + grp_bracket(3, '[')[3:-3] + r')\\]'
141
+ # BRACE1 = '{(' + grp_bracket(1)[1:-1] + ')}'
142
+ # BRACE2 = '{(' + grp_bracket(2)[1:-1] + ')}'
143
+ # BRACE3 = '{(' + grp_bracket(3)[1:-1] + ')}'
144
+ # BRACE4 = '{(' + grp_bracket(4)[1:-1] + ')}'
145
+ # BRACE5 = '{(' + grp_bracket(5)[1:-1] + ')}'
146
+ r""" 使用示例
147
+ >> m = re.search(r'\\multicolumn' + BRACE3*3, r'\multicolumn{2}{|c|}{$2^{12}$个数}')
148
+ >> m.groups()
149
+ ('2', '|c|', '$2^{12}$个数')
150
+ """
151
+
152
+
153
+ def grp_topic(*, type_value=None):
154
+ """定位topic
155
+
156
+ :param type_value: 设置题目类型(TODO: 功能尚未开发)
157
+ """
158
+ s = r'%<topic.*?%</topic>' # 注意外部使用的re要开flags=re.DOTALL
159
+ return s
160
+
161
+
162
+ def grp_figure(cnt_groups=0, parpic=False):
163
+ r""" 生成跟图片匹配相关的表达式
164
+
165
+ D:\2017LaTeX\D招培试卷\高中地理,用过 \captionfig{3-3.eps}{图~3}
166
+ 奕本从2018秋季教材开始使用多种图片格式
167
+
168
+ 191224周二18:20 更新:匹配到的图片名不带花括号
169
+ """
170
+ ibrace3 = grp_bracket(3, inner=True)
171
+
172
+ if cnt_groups == 0: # 不分组
173
+ s = r'\\(?:includegraphics|figt|figc|figr|fig).*?' + grp_bracket(3) # 注意第1组fig要放最后面
174
+ elif cnt_groups == 1: # 只分1组,那么只对图片括号内的内容分组
175
+ s = r'\\(?:includegraphics|figt|figc|figr|fig).*?' + ibrace3
176
+ elif cnt_groups == 2: # 只分2组,那么只对插图命令和图片分组
177
+ s = r'\\(includegraphics|figt|figc|figr|fig).*?' + ibrace3
178
+ elif cnt_groups == 3:
179
+ s = r'\\(includegraphics|figt|figc|figr|fig)(.*?)' + ibrace3
180
+ else:
181
+ s = None
182
+
183
+ if s and parpic:
184
+ s = r'{?\\parpic(?:\[.\])?{' + s + r'}*'
185
+
186
+ return s