chgksuite 0.24.0b3__py3-none-any.whl → 0.24.2__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.
- chgksuite/common.py +12 -4
- chgksuite/composer/chgksuite_parser.py +17 -8
- chgksuite/composer/pptx.py +3 -3
- chgksuite/composer/telegram.py +700 -168
- chgksuite/composer/telegram_bot.py +115 -0
- chgksuite/resources/template_shorin.pptx +0 -0
- chgksuite/version.py +1 -1
- {chgksuite-0.24.0b3.dist-info → chgksuite-0.24.2.dist-info}/METADATA +2 -3
- {chgksuite-0.24.0b3.dist-info → chgksuite-0.24.2.dist-info}/RECORD +13 -11
- {chgksuite-0.24.0b3.dist-info → chgksuite-0.24.2.dist-info}/WHEEL +1 -1
- {chgksuite-0.24.0b3.dist-info → chgksuite-0.24.2.dist-info}/entry_points.txt +0 -0
- {chgksuite-0.24.0b3.dist-info → chgksuite-0.24.2.dist-info}/licenses/LICENSE +0 -0
- {chgksuite-0.24.0b3.dist-info → chgksuite-0.24.2.dist-info}/top_level.txt +0 -0
chgksuite/common.py
CHANGED
|
@@ -226,17 +226,25 @@ def xlsx_to_results(xlsx_file_path):
|
|
|
226
226
|
for row in sheet.iter_rows(values_only=True):
|
|
227
227
|
if first:
|
|
228
228
|
assert row[1] == "Название"
|
|
229
|
-
|
|
229
|
+
if row[3] == "Тур":
|
|
230
|
+
table_type = "tour"
|
|
231
|
+
elif row[3] in ("1", 1):
|
|
232
|
+
table_type = "full"
|
|
230
233
|
first = False
|
|
231
234
|
continue
|
|
232
235
|
team_id = row[0]
|
|
233
236
|
team_name = row[1]
|
|
234
|
-
|
|
235
|
-
|
|
237
|
+
if table_type == "tour":
|
|
238
|
+
tour = row[3]
|
|
239
|
+
results = [x for x in row[4:] if x is not None]
|
|
240
|
+
else:
|
|
241
|
+
tour = 1
|
|
242
|
+
results = [x for x in row[3:] if x is not None]
|
|
236
243
|
rlen = len(results)
|
|
237
244
|
tour_len[tour] = max(tour_len[tour], rlen)
|
|
238
245
|
res_by_tour[(team_id, team_name)][tour] = results
|
|
239
246
|
results = []
|
|
247
|
+
|
|
240
248
|
tours = sorted(tour_len)
|
|
241
249
|
for team_tup in res_by_tour:
|
|
242
250
|
team_id, team_name = team_tup
|
|
@@ -246,7 +254,7 @@ def xlsx_to_results(xlsx_file_path):
|
|
|
246
254
|
if len(team_res) < tour_len[tour]:
|
|
247
255
|
team_res += [0] * (tour_len[tour] - len(team_res))
|
|
248
256
|
for element in team_res:
|
|
249
|
-
if element in (1, 0):
|
|
257
|
+
if tryint(element) in (1, 0):
|
|
250
258
|
mask.append(str(element))
|
|
251
259
|
else:
|
|
252
260
|
mask.append("0")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import codecs
|
|
2
2
|
import random
|
|
3
3
|
import re
|
|
4
|
-
from collections import
|
|
4
|
+
from collections import defaultdict
|
|
5
5
|
|
|
6
6
|
from chgksuite.common import QUESTION_LABELS, check_question, init_logger, log_wrap
|
|
7
7
|
from chgksuite.typotools import remove_excessive_whitespace as rew
|
|
@@ -63,18 +63,27 @@ def process_list(element):
|
|
|
63
63
|
element[1] = inner_list
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
RE_COUNTER =
|
|
66
|
+
RE_COUNTER = "4SCOUNTER(?P<counter_id>[0-9a-zA-Z_]*)"
|
|
67
|
+
RE_SET_COUNTER = "set 4SCOUNTER(?P<counter_id_set>[0-9a-zA-Z_]*) = (?P<counter_value>[0-9+])"
|
|
68
|
+
RE_COUNTER_UNIFY = re.compile(f"({RE_COUNTER}|{RE_SET_COUNTER})")
|
|
67
69
|
|
|
68
70
|
|
|
69
71
|
def replace_counters(string_):
|
|
70
|
-
dd =
|
|
71
|
-
match =
|
|
72
|
+
dd = defaultdict(lambda: 1)
|
|
73
|
+
match = RE_COUNTER_UNIFY.search(string_)
|
|
72
74
|
while match:
|
|
73
75
|
span = match.span()
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
if re.search(RE_SET_COUNTER, match.group(0)):
|
|
77
|
+
counter_id = match.group("counter_id_set")
|
|
78
|
+
counter_value = int(match.group("counter_value"))
|
|
79
|
+
dd[counter_id] = counter_value
|
|
80
|
+
string_ = string_[: span[0]] + string_[span[1] :]
|
|
81
|
+
else:
|
|
82
|
+
span = match.span()
|
|
83
|
+
counter_id = match.group("counter_id")
|
|
84
|
+
string_ = string_[: span[0]] + str(dd[counter_id]) + string_[span[1] :]
|
|
85
|
+
dd[counter_id] += 1
|
|
86
|
+
match = RE_COUNTER_UNIFY.search(string_)
|
|
78
87
|
return string_
|
|
79
88
|
|
|
80
89
|
|
chgksuite/composer/pptx.py
CHANGED
|
@@ -151,12 +151,12 @@ class PptxExporter(BaseExporter):
|
|
|
151
151
|
add_line_break = False
|
|
152
152
|
if section:
|
|
153
153
|
r = p.add_run()
|
|
154
|
-
r.text =
|
|
154
|
+
r.text = self._replace_no_break(self.pptx_process_text(section[0][1]))
|
|
155
155
|
r.font.size = PptxPt(self.c["text_size_grid"]["section"])
|
|
156
156
|
add_line_break = True
|
|
157
157
|
if editor:
|
|
158
158
|
r = p.add_run()
|
|
159
|
-
r.text =
|
|
159
|
+
r.text = self._replace_no_break(
|
|
160
160
|
("\n" if add_line_break else "")
|
|
161
161
|
+ self.pptx_process_text(editor[0][1])
|
|
162
162
|
+ "\n"
|
|
@@ -165,7 +165,7 @@ class PptxExporter(BaseExporter):
|
|
|
165
165
|
if meta:
|
|
166
166
|
for element in meta:
|
|
167
167
|
r = p.add_run()
|
|
168
|
-
r.text =
|
|
168
|
+
r.text = self._replace_no_break(
|
|
169
169
|
("\n" if add_line_break else "")
|
|
170
170
|
+ self.pptx_process_text(element[1])
|
|
171
171
|
+ "\n"
|