chgksuite 0.25.0b4__py3-none-any.whl → 0.26.0b1__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 +4 -0
- chgksuite/composer/pptx.py +65 -44
- chgksuite/version.py +1 -1
- {chgksuite-0.25.0b4.dist-info → chgksuite-0.26.0b1.dist-info}/METADATA +1 -1
- {chgksuite-0.25.0b4.dist-info → chgksuite-0.26.0b1.dist-info}/RECORD +9 -9
- {chgksuite-0.25.0b4.dist-info → chgksuite-0.26.0b1.dist-info}/WHEEL +0 -0
- {chgksuite-0.25.0b4.dist-info → chgksuite-0.26.0b1.dist-info}/entry_points.txt +0 -0
- {chgksuite-0.25.0b4.dist-info → chgksuite-0.26.0b1.dist-info}/licenses/LICENSE +0 -0
- {chgksuite-0.25.0b4.dist-info → chgksuite-0.26.0b1.dist-info}/top_level.txt +0 -0
chgksuite/common.py
CHANGED
|
@@ -224,6 +224,8 @@ def xlsx_to_results(xlsx_file_path):
|
|
|
224
224
|
res_by_tour = defaultdict(lambda: defaultdict(list))
|
|
225
225
|
tour_len = defaultdict(lambda: 0)
|
|
226
226
|
for row in sheet.iter_rows(values_only=True):
|
|
227
|
+
if not any(x for x in row):
|
|
228
|
+
continue
|
|
227
229
|
if first:
|
|
228
230
|
assert row[1] == "Название"
|
|
229
231
|
if row[3] == "Тур":
|
|
@@ -233,6 +235,8 @@ def xlsx_to_results(xlsx_file_path):
|
|
|
233
235
|
first = False
|
|
234
236
|
continue
|
|
235
237
|
team_id = row[0]
|
|
238
|
+
if not tryint(team_id):
|
|
239
|
+
continue
|
|
236
240
|
team_name = row[1]
|
|
237
241
|
if table_type == "tour":
|
|
238
242
|
tour = row[3]
|
chgksuite/composer/pptx.py
CHANGED
|
@@ -3,15 +3,15 @@ import os
|
|
|
3
3
|
import re
|
|
4
4
|
|
|
5
5
|
import toml
|
|
6
|
+
|
|
7
|
+
from chgksuite.common import log_wrap, replace_escaped, tryint
|
|
8
|
+
from chgksuite.composer.composer_common import BaseExporter, backtick_replace, parseimg
|
|
6
9
|
from pptx import Presentation
|
|
7
10
|
from pptx.dml.color import RGBColor
|
|
8
11
|
from pptx.enum.text import MSO_AUTO_SIZE, MSO_VERTICAL_ANCHOR, PP_ALIGN
|
|
9
12
|
from pptx.util import Inches as PptxInches
|
|
10
13
|
from pptx.util import Pt as PptxPt
|
|
11
14
|
|
|
12
|
-
from chgksuite.common import log_wrap, replace_escaped, tryint
|
|
13
|
-
from chgksuite.composer.composer_common import BaseExporter, backtick_replace, parseimg
|
|
14
|
-
|
|
15
15
|
|
|
16
16
|
class PptxExporter(BaseExporter):
|
|
17
17
|
def __init__(self, *args, **kwargs):
|
|
@@ -48,6 +48,15 @@ class PptxExporter(BaseExporter):
|
|
|
48
48
|
textbox = slide.shapes.add_textbox(left, top, width, height)
|
|
49
49
|
return textbox
|
|
50
50
|
|
|
51
|
+
def add_run(self, para, text, color=None):
|
|
52
|
+
r = para.add_run()
|
|
53
|
+
r.text = text
|
|
54
|
+
if color is None:
|
|
55
|
+
color = self.c["textbox"].get("color")
|
|
56
|
+
if color:
|
|
57
|
+
r.font.color.rgb = RGBColor(*color)
|
|
58
|
+
return r
|
|
59
|
+
|
|
51
60
|
def pptx_format(self, el, para, tf, slide, replace_spaces=True):
|
|
52
61
|
def r_sp(text):
|
|
53
62
|
if replace_spaces:
|
|
@@ -60,15 +69,13 @@ class PptxExporter(BaseExporter):
|
|
|
60
69
|
licount = 0
|
|
61
70
|
for li in el[1]:
|
|
62
71
|
licount += 1
|
|
63
|
-
|
|
64
|
-
r.text = "\n{}. ".format(licount)
|
|
72
|
+
self.add_run(para, "\n{}. ".format(licount))
|
|
65
73
|
self.pptx_format(li, para, tf, slide)
|
|
66
74
|
else:
|
|
67
75
|
licount = 0
|
|
68
76
|
for li in el:
|
|
69
77
|
licount += 1
|
|
70
|
-
|
|
71
|
-
r.text = "\n{}. ".format(licount)
|
|
78
|
+
self.add_run(para, "\n{}. ".format(licount))
|
|
72
79
|
self.pptx_format(li, para, tf, slide)
|
|
73
80
|
|
|
74
81
|
if isinstance(el, str):
|
|
@@ -77,23 +84,20 @@ class PptxExporter(BaseExporter):
|
|
|
77
84
|
|
|
78
85
|
for run in self.parse_4s_elem(el):
|
|
79
86
|
if run[0] == "screen":
|
|
80
|
-
|
|
81
|
-
r.text = r_sp(run[1]["for_screen"])
|
|
87
|
+
self.add_run(para, r_sp(run[1]["for_screen"]))
|
|
82
88
|
|
|
83
89
|
elif run[0] == "linebreak":
|
|
84
|
-
|
|
90
|
+
self.add_run(para, "\n")
|
|
85
91
|
|
|
86
92
|
elif run[0] == "strike":
|
|
87
|
-
r =
|
|
88
|
-
r.text = r_sp(run[1])
|
|
93
|
+
r = self.add_run(para, r_sp(run[1]))
|
|
89
94
|
r.font.strike = True # TODO: doesn't work as of 2023-12-24, cf. https://github.com/scanny/python-pptx/issues/339
|
|
90
95
|
|
|
91
96
|
elif run[0] == "img":
|
|
92
97
|
pass # image processing is moved to other places
|
|
93
98
|
|
|
94
99
|
else:
|
|
95
|
-
r =
|
|
96
|
-
r.text = r_sp(run[1])
|
|
100
|
+
r = self.add_run(para, r_sp(run[1]))
|
|
97
101
|
if "italic" in run[0]:
|
|
98
102
|
r.font.italic = True
|
|
99
103
|
if "bold" in run[0]:
|
|
@@ -166,25 +170,30 @@ class PptxExporter(BaseExporter):
|
|
|
166
170
|
txt = txt.upper()
|
|
167
171
|
self.set_question_number(slide, number=txt)
|
|
168
172
|
else:
|
|
169
|
-
r =
|
|
170
|
-
|
|
173
|
+
r = self.add_run(
|
|
174
|
+
p, self._replace_no_break(self.pptx_process_text(section[0][1]))
|
|
175
|
+
)
|
|
171
176
|
r.font.size = PptxPt(self.c["text_size_grid"]["section"])
|
|
172
177
|
add_line_break = True
|
|
173
178
|
if editor:
|
|
174
|
-
r =
|
|
175
|
-
|
|
176
|
-
(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
r = self.add_run(
|
|
180
|
+
p,
|
|
181
|
+
self._replace_no_break(
|
|
182
|
+
("\n" if add_line_break else "")
|
|
183
|
+
+ self.pptx_process_text(editor[0][1])
|
|
184
|
+
+ "\n"
|
|
185
|
+
),
|
|
179
186
|
)
|
|
180
187
|
add_line_break = True
|
|
181
188
|
if meta:
|
|
182
189
|
for element in meta:
|
|
183
|
-
r =
|
|
184
|
-
|
|
185
|
-
(
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
r = self.add_run(
|
|
191
|
+
p,
|
|
192
|
+
self._replace_no_break(
|
|
193
|
+
("\n" if add_line_break else "")
|
|
194
|
+
+ self.pptx_process_text(element[1])
|
|
195
|
+
+ "\n"
|
|
196
|
+
),
|
|
188
197
|
)
|
|
189
198
|
add_line_break = True
|
|
190
199
|
|
|
@@ -211,8 +220,11 @@ class PptxExporter(BaseExporter):
|
|
|
211
220
|
title = slide.shapes.title
|
|
212
221
|
title.text = title_text[0][1]
|
|
213
222
|
if date_text:
|
|
214
|
-
|
|
215
|
-
|
|
223
|
+
try:
|
|
224
|
+
subtitle = slide.placeholders[1]
|
|
225
|
+
subtitle.text = date_text[0][1]
|
|
226
|
+
except KeyError:
|
|
227
|
+
pass
|
|
216
228
|
for block in (editor_block, section_block):
|
|
217
229
|
self._process_block(block)
|
|
218
230
|
|
|
@@ -223,11 +235,12 @@ class PptxExporter(BaseExporter):
|
|
|
223
235
|
qtf = qntextbox.text_frame
|
|
224
236
|
qtf_p = self.init_paragraph(qtf)
|
|
225
237
|
if self.c["number_textbox"].get("align"):
|
|
226
|
-
qtf_p.alignment = getattr(
|
|
227
|
-
|
|
238
|
+
qtf_p.alignment = getattr(
|
|
239
|
+
PP_ALIGN, self.c["number_textbox"]["align"].upper()
|
|
240
|
+
)
|
|
228
241
|
if self.c.get("question_number_format") == "caps" and tryint(number):
|
|
229
242
|
number = f"ВОПРОС {number}"
|
|
230
|
-
qtf_r
|
|
243
|
+
qtf_r = self.add_run(qtf_p, number)
|
|
231
244
|
if self.c["number_textbox"].get("bold"):
|
|
232
245
|
qtf_r.font.bold = True
|
|
233
246
|
if self.c["number_textbox"].get("color"):
|
|
@@ -278,6 +291,15 @@ class PptxExporter(BaseExporter):
|
|
|
278
291
|
base_top = PptxInches(self.c["textbox"]["top"])
|
|
279
292
|
base_width = PptxInches(self.c["textbox"]["width"])
|
|
280
293
|
base_height = PptxInches(self.c["textbox"]["height"])
|
|
294
|
+
if self.c.get("disable_autolayout"):
|
|
295
|
+
slide.shapes.add_picture(
|
|
296
|
+
image["imgfile"],
|
|
297
|
+
left=base_left,
|
|
298
|
+
top=base_top,
|
|
299
|
+
width=img_base_width,
|
|
300
|
+
height=img_base_height,
|
|
301
|
+
)
|
|
302
|
+
return self.get_textbox(slide), 1
|
|
281
303
|
big_mode = (
|
|
282
304
|
image["big"] and not self.c.get("text_is_duplicated") and allowbigimage
|
|
283
305
|
)
|
|
@@ -390,9 +412,13 @@ class PptxExporter(BaseExporter):
|
|
|
390
412
|
def process_question_text(self, q):
|
|
391
413
|
image = self._get_image_from_4s(q["question"])
|
|
392
414
|
handout = self._get_handout_from_4s(q["question"])
|
|
393
|
-
|
|
415
|
+
add_handout_on_separate_slide = self.c.get("add_handout_on_separate_slide")
|
|
416
|
+
add_handout_on_separate_slide = (
|
|
417
|
+
add_handout_on_separate_slide is None or add_handout_on_separate_slide
|
|
418
|
+
)
|
|
419
|
+
if image and add_handout_on_separate_slide:
|
|
394
420
|
self.add_slide_with_image(image, number=self.number)
|
|
395
|
-
elif handout:
|
|
421
|
+
elif handout and add_handout_on_separate_slide:
|
|
396
422
|
self.add_slide_with_handout(handout, number=self.number)
|
|
397
423
|
slide = self.prs.slides.add_slide(self.BLANK_SLIDE)
|
|
398
424
|
text_is_duplicated = bool(self.c.get("text_is_duplicated"))
|
|
@@ -451,34 +477,29 @@ class PptxExporter(BaseExporter):
|
|
|
451
477
|
p = self.init_paragraph(tf, size=self.c["force_text_size_answer"])
|
|
452
478
|
else:
|
|
453
479
|
p = self.init_paragraph(tf, text=text_for_size, coeff=coeff)
|
|
454
|
-
r =
|
|
455
|
-
r.text = f"{self.get_label(q, 'answer')}: "
|
|
480
|
+
r = self.add_run(p, f"{self.get_label(q, 'answer')}: ")
|
|
456
481
|
r.font.bold = True
|
|
457
482
|
self.pptx_format(
|
|
458
483
|
self.pptx_process_text(q["answer"], strip_brackets=False), p, tf, slide
|
|
459
484
|
)
|
|
460
485
|
if q.get("zachet") and self.c.get("add_zachet"):
|
|
461
486
|
zachet_text = self.pptx_process_text(q["zachet"], strip_brackets=False)
|
|
462
|
-
r =
|
|
463
|
-
r.text = f"\n{self.get_label(q, 'zachet')}: "
|
|
487
|
+
r = self.add_run(p, f"\n{self.get_label(q, 'zachet')}: ")
|
|
464
488
|
r.font.bold = True
|
|
465
489
|
self.pptx_format(zachet_text, p, tf, slide)
|
|
466
490
|
if self.c["add_comment"] and "comment" in q:
|
|
467
491
|
comment_text = self.pptx_process_text(q["comment"])
|
|
468
|
-
r =
|
|
469
|
-
r.text = f"\n{self.get_label(q, 'comment')}: "
|
|
492
|
+
r = self.add_run(p, f"\n{self.get_label(q, 'comment')}: ")
|
|
470
493
|
r.font.bold = True
|
|
471
494
|
self.pptx_format(comment_text, p, tf, slide)
|
|
472
495
|
if self.c["add_source"] and "source" in q:
|
|
473
496
|
source_text = self.pptx_process_text(q["source"])
|
|
474
|
-
r =
|
|
475
|
-
r.text = f"\n{self.get_label(q, 'source')}: "
|
|
497
|
+
r = self.add_run(p, f"\n{self.get_label(q, 'source')}: ")
|
|
476
498
|
r.font.bold = True
|
|
477
499
|
self.pptx_format(source_text, p, tf, slide)
|
|
478
500
|
if self.c["add_author"] and "author" in q:
|
|
479
501
|
author_text = self.pptx_process_text(q["author"])
|
|
480
|
-
r =
|
|
481
|
-
r.text = f"\n{self.get_label(q, 'author')}: "
|
|
502
|
+
r = self.add_run(p, f"\n{self.get_label(q, 'author')}: ")
|
|
482
503
|
r.font.bold = True
|
|
483
504
|
self.pptx_format(author_text, p, tf, slide)
|
|
484
505
|
|
|
@@ -510,7 +531,7 @@ class PptxExporter(BaseExporter):
|
|
|
510
531
|
return element["size"]
|
|
511
532
|
return self.c["text_size_grid"]["smallest"]
|
|
512
533
|
|
|
513
|
-
def init_paragraph(self, text_frame, text=None, coeff=1, size=None):
|
|
534
|
+
def init_paragraph(self, text_frame, text=None, coeff=1, size=None, color=None):
|
|
514
535
|
p = text_frame.paragraphs[0]
|
|
515
536
|
p.font.name = self.c["font"]["name"]
|
|
516
537
|
if size:
|
chgksuite/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.26.0b1"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
chgksuite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
chgksuite/__main__.py,sha256=0-_jfloveTW3SZYW5XEagbyaHKGCiDhGNgcLxsT_dMs,140
|
|
3
3
|
chgksuite/cli.py,sha256=8YoHWfc-wv6gdYMPH3X8HxV9SG70S7M6IQqavJaBXV4,31990
|
|
4
|
-
chgksuite/common.py,sha256=
|
|
4
|
+
chgksuite/common.py,sha256=VkOhoBA_P3qY5VgtvfrBjOsm5uVNL2s2Th2AhGB2pg8,11207
|
|
5
5
|
chgksuite/parser.py,sha256=AVNeTUgv0aGHsxWunV_7bM4Ul2hbDslkzqg0dU49lic,37285
|
|
6
6
|
chgksuite/parser_db.py,sha256=W1--OcDnx18mehH1T2ISHu3Saeq-9mqHo-xJopNySXI,11135
|
|
7
7
|
chgksuite/trello.py,sha256=BG1Qb_W7Uu4o3Mfc_tK71ElU8ysdSplGlj_sAKfvUn4,14730
|
|
8
8
|
chgksuite/typotools.py,sha256=Jdk65Wn_bXqpQtOT7PkBZyD2ZG1MBeeZFPMzcHEPkf4,12771
|
|
9
|
-
chgksuite/version.py,sha256=
|
|
9
|
+
chgksuite/version.py,sha256=BHaAG3qba6mDVpDU4IR40uysOU36ZQn-SAYFlFPuCro,25
|
|
10
10
|
chgksuite/vulture_whitelist.py,sha256=P__p_X0zt10ivddIf81uyxsobV14vFg8uS2lt4foYpc,3582
|
|
11
11
|
chgksuite/composer/__init__.py,sha256=MAOVZIYXmZmD6nNQSo9DueV6b5RgxF7_HGeLvsAhMJs,6490
|
|
12
12
|
chgksuite/composer/chgksuite_parser.py,sha256=MFcLUWbccMqo3OYEuaAIA0loEvWM_PNS9vR7c1z_c60,8843
|
|
@@ -16,7 +16,7 @@ chgksuite/composer/docx.py,sha256=5MASXACM-ztWrr3VdO8HZ-W-hWWQ5TY1jXMsCQIufGc,18
|
|
|
16
16
|
chgksuite/composer/latex.py,sha256=WtLdUICxeX4_5vHEJRF0YhFLpTsOUwBkQFunQS488FA,9248
|
|
17
17
|
chgksuite/composer/lj.py,sha256=nty3Zs3N1H0gNK378U04aAHo71_5cABhCM1Mm9jiUEA,15213
|
|
18
18
|
chgksuite/composer/openquiz.py,sha256=4adZewvRXpZhKrh9H4epKoMMDhmki9US55-Q0LcpZW0,7019
|
|
19
|
-
chgksuite/composer/pptx.py,sha256=
|
|
19
|
+
chgksuite/composer/pptx.py,sha256=z1G-KU90GCg9a91ZMVdeOXkWFVU_Sg9M7EMgUcRMMpo,23067
|
|
20
20
|
chgksuite/composer/reddit.py,sha256=-Eg4CqMHhyGGfCteVwdQdtE1pfUXQ42XcP5OYUrBXmo,3878
|
|
21
21
|
chgksuite/composer/stats.py,sha256=GbraSrjaZ8Mc2URs5aGAsI4ekboAKzlJJOqsbe96ELA,3995
|
|
22
22
|
chgksuite/composer/telegram.py,sha256=H65LS79JZ3aCcqeq_SrnUU4E4yro1f-EZxCM3IrIyyQ,46526
|
|
@@ -45,9 +45,9 @@ chgksuite/resources/template.docx,sha256=Do29TAsg3YbH0rRSaXhVzKEoh4pwXkklW_idWA3
|
|
|
45
45
|
chgksuite/resources/template.pptx,sha256=hEFWqE-yYpwZ8ejrMCJIPEyoMT3eDqaqtiEeQ7I4fyk,29777
|
|
46
46
|
chgksuite/resources/template_shorin.pptx,sha256=hEFWqE-yYpwZ8ejrMCJIPEyoMT3eDqaqtiEeQ7I4fyk,29777
|
|
47
47
|
chgksuite/resources/trello.json,sha256=M5Q9JR-AAJF1u16YtNAxDX-7c7VoVTXuq4POTqYvq8o,555
|
|
48
|
-
chgksuite-0.
|
|
49
|
-
chgksuite-0.
|
|
50
|
-
chgksuite-0.
|
|
51
|
-
chgksuite-0.
|
|
52
|
-
chgksuite-0.
|
|
53
|
-
chgksuite-0.
|
|
48
|
+
chgksuite-0.26.0b1.dist-info/licenses/LICENSE,sha256=_a1yfntuPmctLsuiE_08xMSORuCfGS8X5hQph2U_PUw,1081
|
|
49
|
+
chgksuite-0.26.0b1.dist-info/METADATA,sha256=T7bSwl0wzFrgOWvJU9U8M9nVraZQHVANw5ZTnbEgVQE,1296
|
|
50
|
+
chgksuite-0.26.0b1.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
|
51
|
+
chgksuite-0.26.0b1.dist-info/entry_points.txt,sha256=lqjX6ULQZGDt0rgouTXBuwEPiwKkDQkSiNsT877A_Jg,54
|
|
52
|
+
chgksuite-0.26.0b1.dist-info/top_level.txt,sha256=cSWiRBOGZW9nIO6Rv1IrEfwPgV2ZWs87QV9wPXeBGqM,10
|
|
53
|
+
chgksuite-0.26.0b1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|