chgksuite 0.24.0b1__py3-none-any.whl → 0.24.0b2__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/cli.py +20 -0
- chgksuite/composer/composer_common.py +11 -2
- chgksuite/composer/docx.py +9 -8
- chgksuite/composer/lj.py +2 -2
- chgksuite/composer/openquiz.py +0 -1
- chgksuite/composer/pptx.py +2 -3
- chgksuite/composer/telegram.py +6 -19
- chgksuite/typotools.py +16 -14
- chgksuite/version.py +1 -1
- {chgksuite-0.24.0b1.dist-info → chgksuite-0.24.0b2.dist-info}/METADATA +3 -2
- {chgksuite-0.24.0b1.dist-info → chgksuite-0.24.0b2.dist-info}/RECORD +15 -15
- {chgksuite-0.24.0b1.dist-info → chgksuite-0.24.0b2.dist-info}/WHEEL +1 -1
- {chgksuite-0.24.0b1.dist-info → chgksuite-0.24.0b2.dist-info}/entry_points.txt +0 -0
- {chgksuite-0.24.0b1.dist-info → chgksuite-0.24.0b2.dist-info/licenses}/LICENSE +0 -0
- {chgksuite-0.24.0b1.dist-info → chgksuite-0.24.0b2.dist-info}/top_level.txt +0 -0
chgksuite/cli.py
CHANGED
|
@@ -81,6 +81,26 @@ class ArgparseBuilder:
|
|
|
81
81
|
advanced=True,
|
|
82
82
|
argtype="radiobutton",
|
|
83
83
|
)
|
|
84
|
+
self.add_argument(
|
|
85
|
+
parser,
|
|
86
|
+
"--replace_no_break_spaces",
|
|
87
|
+
choices=["on", "off"],
|
|
88
|
+
default=default_overrides.get("replace_no_break_spaces") or "on",
|
|
89
|
+
help="add non-breaking spaces where applicable",
|
|
90
|
+
caption="Добавить неразрывные пробелы",
|
|
91
|
+
advanced=True,
|
|
92
|
+
argtype="radiobutton",
|
|
93
|
+
)
|
|
94
|
+
self.add_argument(
|
|
95
|
+
parser,
|
|
96
|
+
"--replace_no_break_hyphens",
|
|
97
|
+
choices=["on", "off"],
|
|
98
|
+
default=default_overrides.get("replace_no_break_hyphens") or "on",
|
|
99
|
+
help="add non-breaking hyphens where applicable",
|
|
100
|
+
caption="Добавить неразрывные дефисы",
|
|
101
|
+
advanced=True,
|
|
102
|
+
argtype="radiobutton",
|
|
103
|
+
)
|
|
84
104
|
self.add_argument(
|
|
85
105
|
parser,
|
|
86
106
|
"-v",
|
|
@@ -17,7 +17,7 @@ import toml
|
|
|
17
17
|
from PIL import Image
|
|
18
18
|
|
|
19
19
|
import chgksuite.typotools as typotools
|
|
20
|
-
from chgksuite.common import get_chgksuite_dir, init_logger, log_wrap
|
|
20
|
+
from chgksuite.common import DummyLogger, get_chgksuite_dir, init_logger, log_wrap
|
|
21
21
|
from chgksuite.typotools import re_lowercase, re_percent, re_uppercase, re_url
|
|
22
22
|
|
|
23
23
|
|
|
@@ -68,7 +68,9 @@ def make_filename(s, ext, args, addsuffix=""):
|
|
|
68
68
|
if addsuffix:
|
|
69
69
|
bn += addsuffix
|
|
70
70
|
if args.add_ts == "on":
|
|
71
|
-
return "{}_{}.{}".format(
|
|
71
|
+
return "{}_{}.{}".format(
|
|
72
|
+
bn, datetime.datetime.now().strftime("%Y%m%dT%H%M"), ext
|
|
73
|
+
)
|
|
72
74
|
return bn + "." + ext
|
|
73
75
|
|
|
74
76
|
|
|
@@ -401,6 +403,13 @@ class BaseExporter:
|
|
|
401
403
|
else:
|
|
402
404
|
self.logger = init_logger("composer", debug=self.args.debug)
|
|
403
405
|
|
|
406
|
+
def _replace_no_break(self, s):
|
|
407
|
+
return typotools.replace_no_break(
|
|
408
|
+
s,
|
|
409
|
+
spaces=self.args.replace_no_break_spaces == "on",
|
|
410
|
+
hyphens=self.args.replace_no_break_hyphens == "on",
|
|
411
|
+
)
|
|
412
|
+
|
|
404
413
|
def parse_4s_elem(self, *args, **kwargs):
|
|
405
414
|
kwargs["logger"] = self.logger
|
|
406
415
|
return _parse_4s_elem(*args, **kwargs)
|
chgksuite/composer/docx.py
CHANGED
|
@@ -14,7 +14,6 @@ from docx.shared import Pt as DocxPt
|
|
|
14
14
|
|
|
15
15
|
from chgksuite.common import log_wrap, replace_escaped
|
|
16
16
|
from chgksuite.composer.composer_common import BaseExporter, backtick_replace, parseimg
|
|
17
|
-
from chgksuite.typotools import replace_no_break_spaces
|
|
18
17
|
|
|
19
18
|
WHITEN = {
|
|
20
19
|
"handout": False,
|
|
@@ -126,7 +125,7 @@ class DocxExporter(BaseExporter):
|
|
|
126
125
|
else:
|
|
127
126
|
text = run[1]["for_print"]
|
|
128
127
|
if kwargs.get("replace_no_break_spaces"):
|
|
129
|
-
text =
|
|
128
|
+
text = self._replace_no_break(text)
|
|
130
129
|
r = para.add_run(text)
|
|
131
130
|
elif run[0] == "hyperlink" and not (
|
|
132
131
|
whiten and self.args.spoilers == "whiten"
|
|
@@ -175,7 +174,7 @@ class DocxExporter(BaseExporter):
|
|
|
175
174
|
else:
|
|
176
175
|
text = run[1]
|
|
177
176
|
if kwargs.get("replace_no_break_spaces"):
|
|
178
|
-
text =
|
|
177
|
+
text = self._replace_no_break(text)
|
|
179
178
|
r = para.add_run(text)
|
|
180
179
|
if "italic" in run[0]:
|
|
181
180
|
r.italic = True
|
|
@@ -206,9 +205,7 @@ class DocxExporter(BaseExporter):
|
|
|
206
205
|
return hyperlink
|
|
207
206
|
|
|
208
207
|
def add_question(
|
|
209
|
-
self,
|
|
210
|
-
element, skip_qcount=False, screen_mode=False,
|
|
211
|
-
external_para=None
|
|
208
|
+
self, element, skip_qcount=False, screen_mode=False, external_para=None
|
|
212
209
|
):
|
|
213
210
|
q = element[1]
|
|
214
211
|
if external_para is None:
|
|
@@ -326,8 +323,12 @@ class DocxExporter(BaseExporter):
|
|
|
326
323
|
table.cell(0, 0).paragraphs[0].add_run("Версия для ведущего\n").bold = True
|
|
327
324
|
table.cell(0, 1).paragraphs[0].add_run("Версия для экрана\n").bold = True
|
|
328
325
|
|
|
329
|
-
self.add_question(
|
|
330
|
-
|
|
326
|
+
self.add_question(
|
|
327
|
+
element, screen_mode=False, external_para=table.cell(0, 0).paragraphs[0]
|
|
328
|
+
)
|
|
329
|
+
self.add_question(
|
|
330
|
+
element, screen_mode=True, external_para=table.cell(0, 1).paragraphs[0]
|
|
331
|
+
)
|
|
331
332
|
|
|
332
333
|
self.doc.add_paragraph()
|
|
333
334
|
|
chgksuite/composer/lj.py
CHANGED
|
@@ -17,7 +17,7 @@ from chgksuite.composer.composer_common import (
|
|
|
17
17
|
md5,
|
|
18
18
|
parseimg,
|
|
19
19
|
)
|
|
20
|
-
from chgksuite.typotools import re_lowercase, re_uppercase
|
|
20
|
+
from chgksuite.typotools import re_lowercase, re_uppercase
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class LjExporter(BaseExporter):
|
|
@@ -375,7 +375,7 @@ class LjExporter(BaseExporter):
|
|
|
375
375
|
else:
|
|
376
376
|
res += self.htmlrepl(run[1])
|
|
377
377
|
if replace_spaces:
|
|
378
|
-
res =
|
|
378
|
+
res = self._replace_no_break(res)
|
|
379
379
|
return res
|
|
380
380
|
|
|
381
381
|
@staticmethod
|
chgksuite/composer/openquiz.py
CHANGED
chgksuite/composer/pptx.py
CHANGED
|
@@ -10,7 +10,6 @@ from pptx.util import Pt as PptxPt
|
|
|
10
10
|
|
|
11
11
|
from chgksuite.common import log_wrap, replace_escaped
|
|
12
12
|
from chgksuite.composer.composer_common import BaseExporter, backtick_replace, parseimg
|
|
13
|
-
from chgksuite.typotools import replace_no_break_spaces
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
class PptxExporter(BaseExporter):
|
|
@@ -51,7 +50,7 @@ class PptxExporter(BaseExporter):
|
|
|
51
50
|
def pptx_format(self, el, para, tf, slide, replace_spaces=True):
|
|
52
51
|
def r_sp(text):
|
|
53
52
|
if replace_spaces:
|
|
54
|
-
return
|
|
53
|
+
return self._replace_no_break(text)
|
|
55
54
|
return text
|
|
56
55
|
|
|
57
56
|
if isinstance(el, list):
|
|
@@ -127,7 +126,7 @@ class PptxExporter(BaseExporter):
|
|
|
127
126
|
for punct in (".", ",", "!", "?", ":"):
|
|
128
127
|
s = s.replace(" " + punct, punct)
|
|
129
128
|
if replace_spaces:
|
|
130
|
-
s =
|
|
129
|
+
s = self._replace_no_break(s)
|
|
131
130
|
s = s.strip()
|
|
132
131
|
return s
|
|
133
132
|
|
chgksuite/composer/telegram.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import importlib
|
|
2
1
|
import os
|
|
3
2
|
import random
|
|
4
3
|
import re
|
|
4
|
+
import shutil
|
|
5
5
|
import sqlite3
|
|
6
6
|
import time
|
|
7
7
|
|
|
@@ -27,12 +27,13 @@ class TelegramExporter(BaseExporter):
|
|
|
27
27
|
try:
|
|
28
28
|
self.init_tg()
|
|
29
29
|
except (errors.AuthKeyUnregisteredError, sqlite3.OperationalError) as e:
|
|
30
|
-
self.logger.warning(f"Session error: {str(e)}")
|
|
31
30
|
filepath = os.path.join(
|
|
32
31
|
self.chgksuite_dir, self.args.tgaccount + ".session"
|
|
33
32
|
)
|
|
33
|
+
new_filepath = filepath + ".bak"
|
|
34
|
+
self.logger.warning(f"Session error: {str(e)}. Moving session: {filepath} -> {new_filepath}")
|
|
34
35
|
if os.path.isfile(filepath):
|
|
35
|
-
|
|
36
|
+
shutil.move(filepath, new_filepath)
|
|
36
37
|
self.init_tg()
|
|
37
38
|
self.qcount = 1
|
|
38
39
|
self.number = 1
|
|
@@ -328,22 +329,8 @@ class TelegramExporter(BaseExporter):
|
|
|
328
329
|
)
|
|
329
330
|
root_msg_in_chat = result.messages[0]
|
|
330
331
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if channel_username:
|
|
335
|
-
root_msg_link = f"https://t.me/{channel_username}/{root_msg.id}"
|
|
336
|
-
else:
|
|
337
|
-
root_msg_link = f"https://t.me/c/{str(self.channel_id)[4:]}/{root_msg.id}"
|
|
338
|
-
|
|
339
|
-
if chat_username:
|
|
340
|
-
root_msg_in_chat_link = (
|
|
341
|
-
f"https://t.me/{chat_username}/{root_msg_in_chat.id}"
|
|
342
|
-
)
|
|
343
|
-
else:
|
|
344
|
-
root_msg_in_chat_link = (
|
|
345
|
-
f"https://t.me/c/{str(self.chat_id)[4:]}/{root_msg_in_chat.id}"
|
|
346
|
-
)
|
|
332
|
+
root_msg_link = self.get_message_link(root_msg, self.channel_entity)
|
|
333
|
+
root_msg_in_chat_link = self.get_message_link(root_msg_in_chat, self.chat_entity)
|
|
347
334
|
|
|
348
335
|
self.logger.info(
|
|
349
336
|
f"Posted message {root_msg_link} ({root_msg_in_chat_link} in chat)"
|
chgksuite/typotools.py
CHANGED
|
@@ -252,21 +252,23 @@ def get_dashes_right(s):
|
|
|
252
252
|
return s
|
|
253
253
|
|
|
254
254
|
|
|
255
|
-
def
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
s = s.replace(
|
|
267
|
-
srch.group("word"), srch.group("word").replace("-", "\u2011")
|
|
268
|
-
) # non-breaking hyphen
|
|
255
|
+
def replace_no_break(s, spaces=True, hyphens=True):
|
|
256
|
+
if spaces:
|
|
257
|
+
for sp in NO_BREAK_SEQUENCES + [x.title() for x in NO_BREAK_SEQUENCES]:
|
|
258
|
+
r_from = "(^|[ \u00a0]){sp} ".format(sp=sp)
|
|
259
|
+
r_to = "\\g<1>{sp}\u00a0".format(sp=sp)
|
|
260
|
+
s = re.sub(r_from, r_to, s)
|
|
261
|
+
for sp in NO_BREAK_SEQUENCES_LEFT + [x.title() for x in NO_BREAK_SEQUENCES_LEFT]:
|
|
262
|
+
r_from = " {sp}([ \u00a0]|$)".format(sp=sp)
|
|
263
|
+
r_to = "\u00a0{sp}\\g<1>".format(sp=sp)
|
|
264
|
+
s = re.sub(r_from, r_to, s)
|
|
265
|
+
if hyphens:
|
|
269
266
|
srch = re_nbh.search(s)
|
|
267
|
+
while srch:
|
|
268
|
+
s = s.replace(
|
|
269
|
+
srch.group("word"), srch.group("word").replace("-", "\u2011")
|
|
270
|
+
) # non-breaking hyphen
|
|
271
|
+
srch = re_nbh.search(s)
|
|
270
272
|
return s
|
|
271
273
|
|
|
272
274
|
|
chgksuite/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.24.
|
|
1
|
+
__version__ = "0.24.0b2"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: chgksuite
|
|
3
|
-
Version: 0.24.
|
|
3
|
+
Version: 0.24.0b2
|
|
4
4
|
Summary: A package for chgk automation
|
|
5
5
|
Home-page: https://gitlab.com/peczony/chgksuite
|
|
6
6
|
Author: Alexander Pecheny
|
|
@@ -33,6 +33,7 @@ Dynamic: classifier
|
|
|
33
33
|
Dynamic: description
|
|
34
34
|
Dynamic: description-content-type
|
|
35
35
|
Dynamic: home-page
|
|
36
|
+
Dynamic: license-file
|
|
36
37
|
Dynamic: requires-dist
|
|
37
38
|
Dynamic: summary
|
|
38
39
|
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
chgksuite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
chgksuite/__main__.py,sha256=0-_jfloveTW3SZYW5XEagbyaHKGCiDhGNgcLxsT_dMs,140
|
|
3
|
-
chgksuite/cli.py,sha256=
|
|
3
|
+
chgksuite/cli.py,sha256=8YoHWfc-wv6gdYMPH3X8HxV9SG70S7M6IQqavJaBXV4,31990
|
|
4
4
|
chgksuite/common.py,sha256=lHQG72HghaBudr1X6ognGbrKmStW5k9nGSLdoxydMSA,10834
|
|
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
|
-
chgksuite/typotools.py,sha256=
|
|
9
|
-
chgksuite/version.py,sha256=
|
|
8
|
+
chgksuite/typotools.py,sha256=Jdk65Wn_bXqpQtOT7PkBZyD2ZG1MBeeZFPMzcHEPkf4,12771
|
|
9
|
+
chgksuite/version.py,sha256=0Oh9QRxXRu7bku7hpnaBfS0Bood-SOaN3j3uUzin3lM,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=gOFAqPXRh-I5_GAPM6j1Jki-Wcdald5vPp2vFU1NwOM,8303
|
|
13
|
-
chgksuite/composer/composer_common.py,sha256=
|
|
13
|
+
chgksuite/composer/composer_common.py,sha256=S5ipehxep6LlGIZ9dcBnifbVaMYXijMhq6-pUHRISo8,15309
|
|
14
14
|
chgksuite/composer/db.py,sha256=71cINE_V8s6YidvqpmBmmlWbcXraUEGZA1xpVFAUENw,8173
|
|
15
|
-
chgksuite/composer/docx.py,sha256=
|
|
15
|
+
chgksuite/composer/docx.py,sha256=5MASXACM-ztWrr3VdO8HZ-W-hWWQ5TY1jXMsCQIufGc,18346
|
|
16
16
|
chgksuite/composer/latex.py,sha256=WtLdUICxeX4_5vHEJRF0YhFLpTsOUwBkQFunQS488FA,9248
|
|
17
|
-
chgksuite/composer/lj.py,sha256=
|
|
18
|
-
chgksuite/composer/openquiz.py,sha256=
|
|
19
|
-
chgksuite/composer/pptx.py,sha256=
|
|
17
|
+
chgksuite/composer/lj.py,sha256=nty3Zs3N1H0gNK378U04aAHo71_5cABhCM1Mm9jiUEA,15213
|
|
18
|
+
chgksuite/composer/openquiz.py,sha256=CWGxb_cPG2Qh3dQ3hu0pS5fOfhKc8klZuO38Lo9hUF8,7020
|
|
19
|
+
chgksuite/composer/pptx.py,sha256=05JxulgU80jBmxRqC3cFh0q_B3bMUCe31JzLYvnNZYM,19119
|
|
20
20
|
chgksuite/composer/reddit.py,sha256=-Eg4CqMHhyGGfCteVwdQdtE1pfUXQ42XcP5OYUrBXmo,3878
|
|
21
21
|
chgksuite/composer/stats.py,sha256=GbraSrjaZ8Mc2URs5aGAsI4ekboAKzlJJOqsbe96ELA,3995
|
|
22
|
-
chgksuite/composer/telegram.py,sha256=
|
|
22
|
+
chgksuite/composer/telegram.py,sha256=Af0LJIjz3vO5OiQikV7XQObx4ABJewBp7YqHRt0P4GY,25670
|
|
23
23
|
chgksuite/composer/telegram_parser.py,sha256=50WqOuvzzdMJJm5wsSLS49oURAQRYToPnbPJjQbMYC4,8096
|
|
24
24
|
chgksuite/resources/cheader.tex,sha256=Jfe3LESk0VIV0HCObbajSQpEMljaIDAIEGSs6YY9rTk,3454
|
|
25
25
|
chgksuite/resources/fix-unnumbered-sections.sty,sha256=FN6ZSWC6MvoRoThPm5AxCF98DdgcxbxyBYG6YImM05s,1409
|
|
@@ -43,9 +43,9 @@ chgksuite/resources/regexes_uz_cyr.json,sha256=cIQrNXbjDzRwvywDlicy7m6VEvgpE3V1D
|
|
|
43
43
|
chgksuite/resources/template.docx,sha256=Do29TAsg3YbH0rRSaXhVzKEoh4pwXkklW_idWA34HVE,11189
|
|
44
44
|
chgksuite/resources/template.pptx,sha256=hEFWqE-yYpwZ8ejrMCJIPEyoMT3eDqaqtiEeQ7I4fyk,29777
|
|
45
45
|
chgksuite/resources/trello.json,sha256=M5Q9JR-AAJF1u16YtNAxDX-7c7VoVTXuq4POTqYvq8o,555
|
|
46
|
-
chgksuite-0.24.
|
|
47
|
-
chgksuite-0.24.
|
|
48
|
-
chgksuite-0.24.
|
|
49
|
-
chgksuite-0.24.
|
|
50
|
-
chgksuite-0.24.
|
|
51
|
-
chgksuite-0.24.
|
|
46
|
+
chgksuite-0.24.0b2.dist-info/licenses/LICENSE,sha256=_a1yfntuPmctLsuiE_08xMSORuCfGS8X5hQph2U_PUw,1081
|
|
47
|
+
chgksuite-0.24.0b2.dist-info/METADATA,sha256=YbM_s5ki5fEblYecm8L3X1ScDldUlrvXQJgRdEbDawI,1309
|
|
48
|
+
chgksuite-0.24.0b2.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
|
|
49
|
+
chgksuite-0.24.0b2.dist-info/entry_points.txt,sha256=lqjX6ULQZGDt0rgouTXBuwEPiwKkDQkSiNsT877A_Jg,54
|
|
50
|
+
chgksuite-0.24.0b2.dist-info/top_level.txt,sha256=cSWiRBOGZW9nIO6Rv1IrEfwPgV2ZWs87QV9wPXeBGqM,10
|
|
51
|
+
chgksuite-0.24.0b2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|