chgksuite 0.26.1__py3-none-any.whl → 0.27.0__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/_html2md.py +90 -0
- chgksuite/cli.py +21 -8
- chgksuite/common.py +16 -12
- chgksuite/composer/__init__.py +9 -7
- chgksuite/composer/chgksuite_parser.py +16 -7
- chgksuite/composer/composer_common.py +14 -5
- chgksuite/composer/db.py +1 -2
- chgksuite/composer/docx.py +29 -8
- chgksuite/composer/latex.py +1 -2
- chgksuite/composer/lj.py +1 -2
- chgksuite/composer/{reddit.py → markdown.py} +35 -25
- chgksuite/composer/openquiz.py +2 -3
- chgksuite/composer/pptx.py +2 -2
- chgksuite/composer/telegram.py +2 -1
- chgksuite/handouter/gen.py +11 -7
- chgksuite/handouter/installer.py +0 -0
- chgksuite/handouter/runner.py +234 -10
- chgksuite/handouter/tex_internals.py +12 -13
- chgksuite/lastdir +1 -0
- chgksuite/parser.py +32 -33
- chgksuite/parser_db.py +4 -6
- chgksuite/resources/labels_az.toml +22 -0
- chgksuite/resources/labels_by.toml +1 -2
- chgksuite/resources/labels_by_tar.toml +1 -2
- chgksuite/resources/labels_en.toml +1 -2
- chgksuite/resources/labels_kz_cyr.toml +1 -2
- chgksuite/resources/labels_ru.toml +1 -2
- chgksuite/resources/labels_sr.toml +1 -2
- chgksuite/resources/labels_ua.toml +1 -2
- chgksuite/resources/labels_uz.toml +0 -3
- chgksuite/resources/labels_uz_cyr.toml +1 -2
- chgksuite/resources/regexes_az.json +17 -0
- chgksuite/resources/regexes_by.json +3 -2
- chgksuite/resources/regexes_by_tar.json +17 -0
- chgksuite/resources/regexes_en.json +3 -2
- chgksuite/resources/regexes_kz_cyr.json +3 -2
- chgksuite/resources/regexes_ru.json +3 -2
- chgksuite/resources/regexes_sr.json +3 -2
- chgksuite/resources/regexes_ua.json +3 -2
- chgksuite/resources/regexes_uz.json +16 -0
- chgksuite/resources/regexes_uz_cyr.json +3 -2
- chgksuite/trello.py +8 -9
- chgksuite/typotools.py +9 -8
- chgksuite/version.py +1 -1
- {chgksuite-0.26.1.dist-info → chgksuite-0.27.0.dist-info}/METADATA +10 -19
- chgksuite-0.27.0.dist-info/RECORD +63 -0
- {chgksuite-0.26.1.dist-info → chgksuite-0.27.0.dist-info}/WHEEL +1 -2
- chgksuite/composer/telegram_parser.py +0 -230
- chgksuite-0.26.1.dist-info/RECORD +0 -59
- chgksuite-0.26.1.dist-info/top_level.txt +0 -1
- {chgksuite-0.26.1.dist-info → chgksuite-0.27.0.dist-info}/entry_points.txt +0 -0
- {chgksuite-0.26.1.dist-info → chgksuite-0.27.0.dist-info}/licenses/LICENSE +0 -0
chgksuite/parser.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
import base64
|
|
4
|
-
import codecs
|
|
5
4
|
import datetime
|
|
6
5
|
import hashlib
|
|
7
6
|
import itertools
|
|
@@ -18,8 +17,9 @@ import time
|
|
|
18
17
|
|
|
19
18
|
import bs4
|
|
20
19
|
import chardet
|
|
21
|
-
import dashtable
|
|
22
20
|
import mammoth
|
|
21
|
+
|
|
22
|
+
from chgksuite._html2md import html2md
|
|
23
23
|
import pypandoc
|
|
24
24
|
import requests
|
|
25
25
|
import toml
|
|
@@ -46,7 +46,7 @@ from chgksuite.parser_db import chgk_parse_db
|
|
|
46
46
|
from chgksuite.typotools import re_url
|
|
47
47
|
from chgksuite.typotools import remove_excessive_whitespace as rew
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
SEP = os.linesep
|
|
51
51
|
EDITORS = {
|
|
52
52
|
"win32": "notepad",
|
|
@@ -61,7 +61,7 @@ def partition(alist, indices):
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
def load_regexes(regexfile):
|
|
64
|
-
with
|
|
64
|
+
with open(regexfile, "r", encoding="utf-8") as f:
|
|
65
65
|
regexes = json.loads(f.read())
|
|
66
66
|
return {k: re.compile(v) for k, v in regexes.items()}
|
|
67
67
|
|
|
@@ -327,7 +327,7 @@ class ChgkParser:
|
|
|
327
327
|
regex,
|
|
328
328
|
regexes[regex].search(self.remove_formatting(st[i][1])).start(0),
|
|
329
329
|
)
|
|
330
|
-
for regex in set(regexes) - {"number", "date2"}
|
|
330
|
+
for regex in set(regexes) - {"number", "date2", "handout_short"}
|
|
331
331
|
if regexes[regex].search(self.remove_formatting(st[i][1]))
|
|
332
332
|
}
|
|
333
333
|
|
|
@@ -526,7 +526,7 @@ class ChgkParser:
|
|
|
526
526
|
)
|
|
527
527
|
|
|
528
528
|
if debug:
|
|
529
|
-
with
|
|
529
|
+
with open("debug_0.txt", "w", encoding="utf-8") as f:
|
|
530
530
|
f.write(text)
|
|
531
531
|
|
|
532
532
|
# 1.
|
|
@@ -558,7 +558,7 @@ class ChgkParser:
|
|
|
558
558
|
i = 0
|
|
559
559
|
|
|
560
560
|
if debug:
|
|
561
|
-
with
|
|
561
|
+
with open("debug_1.json", "w", encoding="utf-8") as f:
|
|
562
562
|
f.write(json.dumps(self.structure, ensure_ascii=False, indent=4))
|
|
563
563
|
|
|
564
564
|
self.process_single_number_lines()
|
|
@@ -566,15 +566,15 @@ class ChgkParser:
|
|
|
566
566
|
# hack for https://gitlab.com/peczony/chgksuite/-/issues/23; TODO: make less hacky
|
|
567
567
|
for i, element in enumerate(self.structure):
|
|
568
568
|
if (
|
|
569
|
-
"
|
|
570
|
-
or "
|
|
569
|
+
"Дуплет." in element[1].split()
|
|
570
|
+
or "Блиц." in element[1].split()
|
|
571
571
|
and element[0] != "question"
|
|
572
572
|
and (i == 0 or self.structure[i - 1][0] != "question")
|
|
573
573
|
):
|
|
574
574
|
element[0] = "question"
|
|
575
575
|
|
|
576
576
|
if debug:
|
|
577
|
-
with
|
|
577
|
+
with open("debug_1a.json", "w", encoding="utf-8") as f:
|
|
578
578
|
f.write(json.dumps(self.structure, ensure_ascii=False, indent=4))
|
|
579
579
|
|
|
580
580
|
# 2.
|
|
@@ -584,7 +584,7 @@ class ChgkParser:
|
|
|
584
584
|
self.merge_to_x_until_nextfield("comment")
|
|
585
585
|
|
|
586
586
|
if debug:
|
|
587
|
-
with
|
|
587
|
+
with open("debug_2.json", "w", encoding="utf-8") as f:
|
|
588
588
|
f.write(json.dumps(self.structure, ensure_ascii=False, indent=4))
|
|
589
589
|
|
|
590
590
|
# 3.
|
|
@@ -647,7 +647,7 @@ class ChgkParser:
|
|
|
647
647
|
self.merge_to_x_until_nextfield("nezachet")
|
|
648
648
|
|
|
649
649
|
if debug:
|
|
650
|
-
with
|
|
650
|
+
with open("debug_3.json", "w", encoding="utf-8") as f:
|
|
651
651
|
f.write(json.dumps(self.structure, ensure_ascii=False, indent=4))
|
|
652
652
|
|
|
653
653
|
# 4.
|
|
@@ -660,7 +660,7 @@ class ChgkParser:
|
|
|
660
660
|
self.merge_to_next(0)
|
|
661
661
|
|
|
662
662
|
if debug:
|
|
663
|
-
with
|
|
663
|
+
with open("debug_3a.json", "w", encoding="utf-8") as f:
|
|
664
664
|
f.write(
|
|
665
665
|
json.dumps(
|
|
666
666
|
list(enumerate(self.structure)), ensure_ascii=False, indent=4
|
|
@@ -688,12 +688,9 @@ class ChgkParser:
|
|
|
688
688
|
except Exception as e:
|
|
689
689
|
num = None
|
|
690
690
|
sys.stderr.write(
|
|
691
|
-
f"exception at setting number: {type(e)} {e}\n"
|
|
691
|
+
f"exception at setting number: {type(e)} {e}\nQuestion: {element[1]}\n"
|
|
692
692
|
)
|
|
693
|
-
if (
|
|
694
|
-
num is None
|
|
695
|
-
or num and not num.group("number")
|
|
696
|
-
) and (
|
|
693
|
+
if (num is None or num and not num.group("number")) and (
|
|
697
694
|
("нулевой вопрос" in element[1].lower())
|
|
698
695
|
or ("разминочный вопрос" in element[1].lower())
|
|
699
696
|
):
|
|
@@ -721,7 +718,7 @@ class ChgkParser:
|
|
|
721
718
|
idx += 1
|
|
722
719
|
|
|
723
720
|
if debug:
|
|
724
|
-
with
|
|
721
|
+
with open("debug_4.json", "w", encoding="utf-8") as f:
|
|
725
722
|
f.write(json.dumps(self.structure, ensure_ascii=False, indent=4))
|
|
726
723
|
|
|
727
724
|
# 5.
|
|
@@ -801,7 +798,7 @@ class ChgkParser:
|
|
|
801
798
|
)
|
|
802
799
|
|
|
803
800
|
if debug:
|
|
804
|
-
with
|
|
801
|
+
with open("debug_5.json", "w", encoding="utf-8") as f:
|
|
805
802
|
f.write(json.dumps(self.structure, ensure_ascii=False, indent=4))
|
|
806
803
|
|
|
807
804
|
# 6.
|
|
@@ -856,7 +853,7 @@ class ChgkParser:
|
|
|
856
853
|
final_structure.append(["Question", current_question])
|
|
857
854
|
|
|
858
855
|
if debug:
|
|
859
|
-
with
|
|
856
|
+
with open("debug_6.json", "w", encoding="utf-8") as f:
|
|
860
857
|
f.write(json.dumps(final_structure, ensure_ascii=False, indent=4))
|
|
861
858
|
|
|
862
859
|
# 7.
|
|
@@ -902,7 +899,7 @@ class ChgkParser:
|
|
|
902
899
|
element[1] = self._process_images_in_text(element[1])
|
|
903
900
|
|
|
904
901
|
if debug:
|
|
905
|
-
with
|
|
902
|
+
with open("debug_final.json", "w", encoding="utf-8") as f:
|
|
906
903
|
f.write(json.dumps(final_structure, ensure_ascii=False, indent=4))
|
|
907
904
|
return final_structure
|
|
908
905
|
|
|
@@ -985,8 +982,8 @@ def chgk_parse_docx(docxfile, defaultauthor="", args=None, logger=None):
|
|
|
985
982
|
with open(docxfile, "rb") as docx_file:
|
|
986
983
|
html = mammoth.convert_to_html(docx_file).value
|
|
987
984
|
if args.debug:
|
|
988
|
-
with
|
|
989
|
-
os.path.join(target_dir, "debugdebug.pydocx"), "w", "
|
|
985
|
+
with open(
|
|
986
|
+
os.path.join(target_dir, "debugdebug.pydocx"), "w", encoding="utf-8"
|
|
990
987
|
) as dbg:
|
|
991
988
|
dbg.write(html)
|
|
992
989
|
input_docx = (
|
|
@@ -997,8 +994,8 @@ def chgk_parse_docx(docxfile, defaultauthor="", args=None, logger=None):
|
|
|
997
994
|
bsoup = BeautifulSoup(input_docx, "html.parser")
|
|
998
995
|
|
|
999
996
|
if args.debug:
|
|
1000
|
-
with
|
|
1001
|
-
os.path.join(target_dir, "debug.pydocx"), "w", "
|
|
997
|
+
with open(
|
|
998
|
+
os.path.join(target_dir, "debug.pydocx"), "w", encoding="utf-8"
|
|
1002
999
|
) as dbg:
|
|
1003
1000
|
dbg.write(input_docx)
|
|
1004
1001
|
|
|
@@ -1068,7 +1065,7 @@ def chgk_parse_docx(docxfile, defaultauthor="", args=None, logger=None):
|
|
|
1068
1065
|
ensure_line_breaks(tag)
|
|
1069
1066
|
for tag in bsoup.find_all("table"):
|
|
1070
1067
|
try:
|
|
1071
|
-
table =
|
|
1068
|
+
table = html2md(str(tag))
|
|
1072
1069
|
tag.insert_before(table)
|
|
1073
1070
|
except (TypeError, ValueError):
|
|
1074
1071
|
logger.error(f"couldn't parse html table: {str(tag)}")
|
|
@@ -1099,12 +1096,12 @@ def chgk_parse_docx(docxfile, defaultauthor="", args=None, logger=None):
|
|
|
1099
1096
|
tag.unwrap()
|
|
1100
1097
|
|
|
1101
1098
|
if args.debug:
|
|
1102
|
-
with
|
|
1103
|
-
os.path.join(target_dir, "debug_raw.html"), "w", "
|
|
1099
|
+
with open(
|
|
1100
|
+
os.path.join(target_dir, "debug_raw.html"), "w", encoding="utf-8"
|
|
1104
1101
|
) as dbg:
|
|
1105
1102
|
dbg.write(str(bsoup))
|
|
1106
|
-
with
|
|
1107
|
-
os.path.join(target_dir, "debug.html"), "w", "
|
|
1103
|
+
with open(
|
|
1104
|
+
os.path.join(target_dir, "debug.html"), "w", encoding="utf-8"
|
|
1108
1105
|
) as dbg:
|
|
1109
1106
|
dbg.write(bsoup.prettify())
|
|
1110
1107
|
|
|
@@ -1142,7 +1139,9 @@ def chgk_parse_docx(docxfile, defaultauthor="", args=None, logger=None):
|
|
|
1142
1139
|
txt = txt.replace(f"IMGPATH({i})", elem)
|
|
1143
1140
|
|
|
1144
1141
|
if args.debug:
|
|
1145
|
-
with
|
|
1142
|
+
with open(
|
|
1143
|
+
os.path.join(target_dir, "debug.debug"), "w", encoding="utf-8"
|
|
1144
|
+
) as dbg:
|
|
1146
1145
|
dbg.write(txt)
|
|
1147
1146
|
|
|
1148
1147
|
final_structure = chgk_parse(txt, defaultauthor=defaultauthor, args=args)
|
|
@@ -1176,7 +1175,7 @@ def chgk_parse_wrapper(path, args, logger=None):
|
|
|
1176
1175
|
sys.exit()
|
|
1177
1176
|
outfilename = os.path.join(target_dir, make_filename(abspath, "4s", args))
|
|
1178
1177
|
logger.info("Output: {}".format(os.path.abspath(outfilename)))
|
|
1179
|
-
with
|
|
1178
|
+
with open(outfilename, "w", encoding="utf-8") as output_file:
|
|
1180
1179
|
output_file.write(compose_4s(final_structure, args=args))
|
|
1181
1180
|
return outfilename
|
|
1182
1181
|
|
chgksuite/parser_db.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
-
import codecs
|
|
5
4
|
import json
|
|
6
5
|
import os
|
|
7
6
|
import re
|
|
@@ -128,7 +127,7 @@ def t_ANSWER(t):
|
|
|
128
127
|
t.lexer.text = ""
|
|
129
128
|
if t.lexer.question["answer"]:
|
|
130
129
|
logger.warning(
|
|
131
|
-
"Bad format: several Answer fields.
|
|
130
|
+
"Bad format: several Answer fields. Previous Answer was: '%s'",
|
|
132
131
|
t.lexer.question["answer"],
|
|
133
132
|
)
|
|
134
133
|
|
|
@@ -151,7 +150,7 @@ def t_COMMENT(t):
|
|
|
151
150
|
t.lexer.text = ""
|
|
152
151
|
if t.lexer.question["comment"]:
|
|
153
152
|
logger.warning(
|
|
154
|
-
"Bad format: several Comment fields.
|
|
153
|
+
"Bad format: several Comment fields. Previous Comment was: '%s'",
|
|
155
154
|
t.lexer.question["comment"],
|
|
156
155
|
)
|
|
157
156
|
|
|
@@ -162,7 +161,7 @@ def t_SOURCE(t):
|
|
|
162
161
|
t.lexer.text = ""
|
|
163
162
|
if t.lexer.question["source"]:
|
|
164
163
|
logger.warning(
|
|
165
|
-
"Bad format: several Source fields.
|
|
164
|
+
"Bad format: several Source fields. Previous Source was: '%s'",
|
|
166
165
|
t.lexer.question["source"],
|
|
167
166
|
)
|
|
168
167
|
|
|
@@ -417,7 +416,6 @@ def replace_handouts(match_handout):
|
|
|
417
416
|
|
|
418
417
|
|
|
419
418
|
def chgk_parse_db(text, debug=False, logger=False):
|
|
420
|
-
|
|
421
419
|
if not logger:
|
|
422
420
|
logger = init_logger("parser_db", debug=debug)
|
|
423
421
|
|
|
@@ -437,7 +435,7 @@ def chgk_parse_db(text, debug=False, logger=False):
|
|
|
437
435
|
append_question(lexer)
|
|
438
436
|
|
|
439
437
|
if debug:
|
|
440
|
-
with
|
|
438
|
+
with open("debug_final.json", "w", encoding="utf-8") as f:
|
|
441
439
|
f.write(json.dumps(lexer.structure, ensure_ascii=False, indent=4))
|
|
442
440
|
|
|
443
441
|
return lexer.structure
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[question_labels]
|
|
2
|
+
question = "Sual"
|
|
3
|
+
answer = "Cavab"
|
|
4
|
+
zachet = "Sayılma meyarı"
|
|
5
|
+
nezachet = "Sayılmır"
|
|
6
|
+
comment = "Şərh"
|
|
7
|
+
source = "Mənbə"
|
|
8
|
+
sources = "Mənbələr"
|
|
9
|
+
author = "Müəllif"
|
|
10
|
+
authors = "Müəlliflər"
|
|
11
|
+
handout = "Paylama materialı"
|
|
12
|
+
|
|
13
|
+
[general]
|
|
14
|
+
section = "Tur"
|
|
15
|
+
editor = "Redaktor"
|
|
16
|
+
date = "Tarix"
|
|
17
|
+
questions_in_comments = "Suallar şərh bölməsindədir."
|
|
18
|
+
general_impressions_caption = "Ümumi təəssüratlar"
|
|
19
|
+
handout_for_question = "Paylama materialı sual {} üçün"
|
|
20
|
+
general_impressions_text = "Paket barədə ümumi təəssüratlar — bu posun altına şərh kimi yazın."
|
|
21
|
+
right_answers_for_stats = "Doğru cavablar"
|
|
22
|
+
cf_image = "Şəklə baxın"
|
|
@@ -9,7 +9,6 @@ sources = "Крыніцы"
|
|
|
9
9
|
author = "Аўтар"
|
|
10
10
|
authors = "Аўтары"
|
|
11
11
|
handout = "Раздаткавы матэрыял"
|
|
12
|
-
handout_short = "Раздат"
|
|
13
12
|
|
|
14
13
|
[general]
|
|
15
14
|
section = "Тур"
|
|
@@ -19,4 +18,4 @@ questions_in_comments = "Пытанні ў каментарах."
|
|
|
19
18
|
handout_for_question = "Раздаткавы матэрыял да пытання {}"
|
|
20
19
|
general_impressions_caption = "Агульныя ўражанні"
|
|
21
20
|
general_impressions_text = "Агульныя ўражанні ад пакета — у каментарах да гэтага паста."
|
|
22
|
-
right_answers_for_stats = "Правільных адказаў"
|
|
21
|
+
right_answers_for_stats = "Правільных адказаў"
|
|
@@ -9,7 +9,6 @@ sources = "Крыніцы"
|
|
|
9
9
|
author = "Аўтар"
|
|
10
10
|
authors = "Аўтары"
|
|
11
11
|
handout = "Раздаткавы матэрыял"
|
|
12
|
-
handout_short = "Раздат"
|
|
13
12
|
|
|
14
13
|
[general]
|
|
15
14
|
section = "Тур"
|
|
@@ -19,4 +18,4 @@ questions_in_comments = "Пытаньні ў каментарыях."
|
|
|
19
18
|
handout_for_question = "Раздатачны матэрыял да пытаньня {}"
|
|
20
19
|
general_impressions_caption = "Агульныя ўражаньні"
|
|
21
20
|
general_impressions_text = "Агульныя ўражаньні ад пакета — у каментарыях да гэтага паста."
|
|
22
|
-
right_answers_for_stats = "Правільных адказаў"
|
|
21
|
+
right_answers_for_stats = "Правільных адказаў"
|
|
@@ -9,7 +9,6 @@ sources = "Sources"
|
|
|
9
9
|
author = "Author"
|
|
10
10
|
authors = "Authors"
|
|
11
11
|
handout = "Handout"
|
|
12
|
-
handout_short = "Handout"
|
|
13
12
|
|
|
14
13
|
[general]
|
|
15
14
|
section = "Block"
|
|
@@ -19,4 +18,4 @@ questions_in_comments = "Questions are in the comments."
|
|
|
19
18
|
handout_for_question = "Handout for question {}"
|
|
20
19
|
general_impressions_caption = "General impression"
|
|
21
20
|
general_impressions_text = "Please share your general impression of the packet in the comments to this post."
|
|
22
|
-
right_answers_for_stats = "Correct answers"
|
|
21
|
+
right_answers_for_stats = "Correct answers"
|
|
@@ -9,7 +9,6 @@ sources = "Дереккөздер"
|
|
|
9
9
|
author = "Автор"
|
|
10
10
|
authors = "Авторлар"
|
|
11
11
|
handout = "Үлестіру материалы"
|
|
12
|
-
handout_short = "Материал"
|
|
13
12
|
|
|
14
13
|
[general]
|
|
15
14
|
section = "Тур"
|
|
@@ -20,4 +19,4 @@ general_impressions_caption = "Жалпы әсер"
|
|
|
20
19
|
handout_for_question = "{}-сұрақтың үлестіру материалы"
|
|
21
20
|
general_impressions_text = "Пакеттен алған жалпы әсер — осы пост астындағы комментарийлерде."
|
|
22
21
|
right_answers_for_stats = "Алған сұрақтар"
|
|
23
|
-
cf_image = "суретті қараңыз"
|
|
22
|
+
cf_image = "суретті қараңыз"
|
|
@@ -9,7 +9,6 @@ sources = "Источники"
|
|
|
9
9
|
author = "Автор"
|
|
10
10
|
authors = "Авторы"
|
|
11
11
|
handout = "Раздаточный материал"
|
|
12
|
-
handout_short = "Раздат"
|
|
13
12
|
|
|
14
13
|
[general]
|
|
15
14
|
section = "Тур"
|
|
@@ -20,4 +19,4 @@ general_impressions_caption = "Общие впечатления"
|
|
|
20
19
|
handout_for_question = "Раздаточный материал к вопросу {}"
|
|
21
20
|
general_impressions_text = "Общее впечатление от пакета — в комментариях к этому посту."
|
|
22
21
|
right_answers_for_stats = "Взятия"
|
|
23
|
-
cf_image = "см. изображение"
|
|
22
|
+
cf_image = "см. изображение"
|
|
@@ -9,7 +9,6 @@ sources = "Izvori"
|
|
|
9
9
|
author = "Autor"
|
|
10
10
|
authors = "Autori"
|
|
11
11
|
handout = "Materijal za deljenje"
|
|
12
|
-
handout_short = "Podeljeno"
|
|
13
12
|
|
|
14
13
|
[general]
|
|
15
14
|
section = "Runda"
|
|
@@ -20,4 +19,4 @@ general_impressions_caption = "Opšti utisci"
|
|
|
20
19
|
handout_for_question = "Materijal za deljenje uz pitanje {}"
|
|
21
20
|
general_impressions_text = "Opšti utisak od paketa — u komentarima na ovu objavu."
|
|
22
21
|
right_answers_for_stats = "Pogodak"
|
|
23
|
-
cf_image = "vidi sliku"
|
|
22
|
+
cf_image = "vidi sliku"
|
|
@@ -9,7 +9,6 @@ sources = "Джерела"
|
|
|
9
9
|
author = "Автор"
|
|
10
10
|
authors = "Автори"
|
|
11
11
|
handout = "Роздатковий матеріал"
|
|
12
|
-
handout_short = "Роздат"
|
|
13
12
|
|
|
14
13
|
[general]
|
|
15
14
|
section = "Тур"
|
|
@@ -19,4 +18,4 @@ questions_in_comments = "Запитання у коментарях."
|
|
|
19
18
|
handout_for_question = "Роздатковий матеріал до запитання {}"
|
|
20
19
|
general_impressions_caption = "Загальні враження"
|
|
21
20
|
general_impressions_text = "Загальні враження про пакет — у коментарях до цього посту."
|
|
22
|
-
right_answers_for_stats = "Взяття"
|
|
21
|
+
right_answers_for_stats = "Взяття"
|
|
@@ -9,7 +9,6 @@ sources = "Manbalar"
|
|
|
9
9
|
author = "Muallif"
|
|
10
10
|
authors = "Mualliflar"
|
|
11
11
|
handout = "Tarqatma material"
|
|
12
|
-
handout_short = "Tarqat"
|
|
13
12
|
|
|
14
13
|
[general]
|
|
15
14
|
section = "Tur"
|
|
@@ -20,5 +19,3 @@ handout_for_question = "{} savolga tarqatma material."
|
|
|
20
19
|
general_impressions_caption = "Umumiy taasurotlar"
|
|
21
20
|
general_impressions_text = "To‘plamdan umumiy taasurotlar — ushbu postning izohlarida."
|
|
22
21
|
right_answers_for_stats = "To‘g‘ri javoblar foizi"
|
|
23
|
-
|
|
24
|
-
|
|
@@ -9,7 +9,6 @@ sources = "Манбалар"
|
|
|
9
9
|
author = "Муаллиф"
|
|
10
10
|
authors = "Муаллифлар"
|
|
11
11
|
handout = "Тарқатма материал"
|
|
12
|
-
handout_short = "Тарқат"
|
|
13
12
|
|
|
14
13
|
[general]
|
|
15
14
|
section = "Тур"
|
|
@@ -19,4 +18,4 @@ questions_in_comments = "Саволлар изоҳларда."
|
|
|
19
18
|
handout_for_question = "{} саволга тарқатма материал."
|
|
20
19
|
general_impressions_caption = "Умумий таасуротлар"
|
|
21
20
|
general_impressions_text = "Тўпламдан умумий таасуротлар — ушбу постнинг изоҳларида."
|
|
22
|
-
right_answers_for_stats = "Тўғри жавоблар фоизи"
|
|
21
|
+
right_answers_for_stats = "Тўғри жавоблар фоизи"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tour": "^(#\\s+)?T[Uu][Rr]\\s?№?\\s?([0-9IVXLCDM]*)([\\.:])?$",
|
|
3
|
+
"tourrev": "^([0-9IVXLCDM]+)\\s[Tt][Uu][Rr]([\\.:])?$",
|
|
4
|
+
"question": "S[Uu][Aa][Ll]\\s?[№N]?(?P<number>[0-9\\s]*)\\s*([\\.:]|\\n|\\r\\n|$)",
|
|
5
|
+
"handout": "^P[Aa][Yy][Ll][Aa][Mm][Aa]\\s+[Mm][Aa][Tt][Ee][Rr][İi][Aa][Ll][\\.:]",
|
|
6
|
+
"answer": "C[Aa][Vv][Aa][Bb]?\\s?[№N]?([0-9]+)?\\s*[\\.:]?",
|
|
7
|
+
"zachet": "S[Aa][Yy][ıI][Ll][Mm][Aa]\\s+[Mm][Ee][Yy][Aa][Rr][ıI]\\s*[\\.:]?",
|
|
8
|
+
"nezachet": "S[Aa][Yy][ıI][Ll][Mm][ıI][Rr]\\s*[\\.:]?",
|
|
9
|
+
"comment": "Ş[Əə][Rr][Hh]\\s?[№N]?([0-9]+)?\\s*[\\.:]?",
|
|
10
|
+
"author": "M[Üü][Əə][Ll][Ll][İiİı][Ff]\\s*[\\.:]?",
|
|
11
|
+
"source": "M[Əə][Nn][Bb][Əə]\\s*[\\.:]?",
|
|
12
|
+
"editor": "R[Ee][Dd][Aa]([Kk][Tt][Oo][Rr]?\\s*(\\s*[\\.:]|\\s*[\\-–—]+\\s)?)",
|
|
13
|
+
"date": "TT[Aa][Rr][İiİı][Xx]\\s*[\\.:]?",
|
|
14
|
+
"date2": "(^|\\s)[Yy][Aa][Nn][Vv][Aa][Rr]|[Ff][Ee][Vv][Rr][Aa][Ll]|[Mm][Aa][Rr][Tt]|[Aa][Pp][Rr][Ee][Ll]|[Mm][Aa][Yy]|[İi][Yy][Uu][Nn]|[İi][Yy][Uu][Ll]|[Aa][Vv][Qq][Uu][Ss][Tt]|[Ss][Ee][Nn][Tt][Yy][Aa][Bb][Rr]|[Oo][Kk][Tt][Yy][Aa][Bb][Rr]|[Nn][Oo][Yy][Aa][Bb][Rr]|[Dd][Ee][Kk][Aa][Bb][Rr](\\s|$)",
|
|
15
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
16
|
+
"handout_short": "(P[Aa][Yy][Ll]|R[Ee][Kk][Vv][Ii][Zz][Ii][Tt])"
|
|
17
|
+
}
|
|
@@ -12,5 +12,6 @@
|
|
|
12
12
|
"editor": "[Рр][Ээ][Дд][Аа][Кк][Тт][Аа][Рр]([Ыы])?(\\s?[\\.:]|\\s[\\-–—]+\\s)",
|
|
13
13
|
"date": "Д[Аа][Тт][Аа]\\s?[\\.:]",
|
|
14
14
|
"date2": "(^|\\s)студзеня|лютага|сакавіка|красавіка|мая|чэрвеня|ліпеня|жніўня|верасня|кастрычніка|лістапада|снежня(\\s|$)",
|
|
15
|
-
"number": "^[0-9]+[\\.\\)]\\s*"
|
|
16
|
-
|
|
15
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
16
|
+
"handout_short": "Р[Аа][Зз][Дд][Аа][Тт]"
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tour": "^(#\\s+)?Т[Уу][Рр]\\s?№?\\s?([0-9IVXLCDM]*)([\\.:])?$",
|
|
3
|
+
"tourrev": "^([0-9IVXLCDM]+)\\s[Тт][Уу][Рр]([\\.:])?$",
|
|
4
|
+
"question": "П[Ыы][Тт][Аа][Нн][Ьь][Нн][Ее]\\s?[№N]?(?P<number>[0-9\\s]*)\\s?([\\.:]|\n|\r\n|$)",
|
|
5
|
+
"handout": "Р[Аа][Зз][Дд][Аа][Тт][Кк][Аа][Вв][Ыы][\\s\\s][Мм][Аа][Тт][Ээ][Рр][Ыы][Яя][Лл][\\.:]",
|
|
6
|
+
"answer": "А[Дд][Кк][Аа][Зз][Ыы]?\\s?[№N]?([0-9]+)?\\s?[\\.:]",
|
|
7
|
+
"zachet": "З[Аа][Лл][Іі][Кк]\\s?[\\.:]",
|
|
8
|
+
"nezachet": "Н[Ее][Зз][Аа][Лл][Іі][Кк]\\s?[\\.:]",
|
|
9
|
+
"comment": "К[Аа][Мм][Ее][Нн][Тт][Аа][Рр][Ыы][Йй]\\s?[№N]?([0-9]+)?\\s?[\\.:]",
|
|
10
|
+
"author": "А[Ўў][Тт][Аа][Рр](\\(?[Ыы]?\\)?|[Кк][АаИи])?\\s?[\\.:]",
|
|
11
|
+
"source": "К[Рр][Ыы][Нн][Іі][Цц][АаЫы]\\s?[\\.:]",
|
|
12
|
+
"editor": "[Рр][Ээ][Дд][Аа][Кк][Тт][Аа][Рр]([Ыы])?(\\s?[\\.:]|\\s[\\-–—]+\\s)",
|
|
13
|
+
"date": "Д[Аа][Тт][Аа]\\s?[\\.:]",
|
|
14
|
+
"date2": "(^|\\s)студзеня|лютага|сакавіка|красавіка|мая|траўня|чэрвеня|ліпеня|жніўня|верасьня|кастрычніка|лістапада|сьнежня(\\s|$)",
|
|
15
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
16
|
+
"handout_short": "Р[Аа][Зз][Дд][Аа][Тт]"
|
|
17
|
+
}
|
|
@@ -12,5 +12,6 @@
|
|
|
12
12
|
"editor": "E[Dd][Ii][Tt]([Oo][Rr][Ss]?|[Ee][Dd]\\s[Bb][Yy])\\s?(\\s?[\\.:]|\\s[\\-–—]+\\s)",
|
|
13
13
|
"date": "D[Aa][Tt][Ee]\\s?[\\.:]",
|
|
14
14
|
"date2": "(^|\\s)Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|June?|July?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?(\\s|$)",
|
|
15
|
-
"number": "^[0-9]+[\\.\\)]\\s*"
|
|
16
|
-
|
|
15
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
16
|
+
"handout_short": "H[Aa][Nn][Dd][Oo][Uu][Tt]"
|
|
17
|
+
}
|
|
@@ -11,5 +11,6 @@
|
|
|
11
11
|
"editor": "Р[Ее][Дд][Аа][Кк][Тт][Оо][Рр]([Лл][Аа][Рр])?(\\s?[\\.:]|\\s[\\-–—]+\\s)",
|
|
12
12
|
"date": "Д[Аа][Тт][Аа]\\s?[\\.:]",
|
|
13
13
|
"date2": "(^|\\s)[Яя][Нн][Вв][Аа][Рр][ЬьЯя]|[Фф][Ее][Вв][Рр][Аа][Лл][ЬьЯя]|[Мм][Аа][Рр][Тт][Аа]?|[Аа][Пп][Рр][Ее][Лл][ЬьЯя]|[Мм][Аа][ЙйЯя]|[Ии][Юю][Нн][ЬьЯя]|[Ии][Юю][Лл][ЬьЯя]|[Аа][Вв][Гг][Уу][Сс][Тт][Аа]?|[Сс][Ее][Нн][Тт][Яя][Бб][Рр][ЬьЯя]|[Оо][Кк][Тт][Яя][Бб][Рр][ЬьЯя]|[Нн][Оо][Яя][Бб][Рр][ЬьЯя]|[Дд][Ее][Кк][Аа][Бб][Рр][ЬьЯя](\\s|$)",
|
|
14
|
-
"number": "^[0-9]+[\\.\\)]\\s*"
|
|
15
|
-
|
|
14
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
15
|
+
"handout_short": "М[Аа][Тт][Ее][Рр][Ии][Аа][Лл]"
|
|
16
|
+
}
|
|
@@ -12,5 +12,6 @@
|
|
|
12
12
|
"editor": "[Рр][Ее][Дд][Аа][Кк][Тт][Оо][Рр]([Ыы]|[Сс][Кк][Аа][Яя]\\s[Гг][Рр][Уу][Пп][Пп][Аа])?(\\s?[\\.:]|\\s[\\-–—]+\\s)",
|
|
13
13
|
"date": "Д[Аа][Тт][Аа]\\s?[\\.:]",
|
|
14
14
|
"date2": "(^|\\s)[Яя][Нн][Вв][Аа][Рр][ЬьЯя]|[Фф][Ее][Вв][Рр][Аа][Лл][ЬьЯя]|[Мм][Аа][Рр][Тт][Аа]?|[Аа][Пп][Рр][Ее][Лл][ЬьЯя]|[Мм][Аа][ЙйЯя]|[Ии][Юю][Нн][ЬьЯя]|[Ии][Юю][Лл][ЬьЯя]|[Аа][Вв][Гг][Уу][Сс][Тт][Аа]?|[Сс][Ее][Нн][Тт][Яя][Бб][Рр][ЬьЯя]|[Оо][Кк][Тт][Яя][Бб][Рр][ЬьЯя]|[Нн][Оо][Яя][Бб][Рр][ЬьЯя]|[Дд][Ее][Кк][Аа][Бб][Рр][ЬьЯя](\\s|$)",
|
|
15
|
-
"number": "^[0-9]+[\\.\\)]\\s*"
|
|
16
|
-
|
|
15
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
16
|
+
"handout_short": "Р[Аа][Зз][Дд][Аа][Тт]"
|
|
17
|
+
}
|
|
@@ -12,5 +12,6 @@
|
|
|
12
12
|
"editor": "U[Rr][Ee][Dd][Nn][Ii][Kk][Ii]?\\s?(\\s?[\\.:]|\\s[\\-–—]+\\s)",
|
|
13
13
|
"date": "D[Aa][Tt][Uu][Mm]\\s?[\\.:]",
|
|
14
14
|
"date2": "WILL_FILL_LATER",
|
|
15
|
-
"number": "^[0-9]+[\\.\\)]\\s*"
|
|
16
|
-
|
|
15
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
16
|
+
"handout_short": "P[Oo][Dd][Ee][Ll][Jj][Ee][Nn][Oo]"
|
|
17
|
+
}
|
|
@@ -12,5 +12,6 @@
|
|
|
12
12
|
"editor": "[Рр][Ее][Дд][Аа][Кк][Тт][Оо][Рр]([Ии]|[Сс][Ьь][Кк][Аа]\\s[Гг][Рр][Уу][Пп][Аа])?(\\s?[\\.:]|\\s[\\-–—]+\\s)",
|
|
13
13
|
"date": "Д[Аа][Тт][Аа]\\s?[\\.:]",
|
|
14
14
|
"date2": "(^|\\s)cічня|лютого|березня|квітня|травня|червня|липня|серпня|вересня|жовтня|листопада|грудня(\\s|$)",
|
|
15
|
-
"number": "^[0-9]+[\\.\\)]\\s*"
|
|
16
|
-
|
|
15
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
16
|
+
"handout_short": "Р[Оо][Зз][Дд][Аа][Тт]"
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tour": "^(#\\s+)?([0-9]+)\\s?[-–—]\\s?[Tt][Uu][Rr]\\s*$",
|
|
3
|
+
"question": "(?P<number>[0-9]+)\\s?[-–—]\\s?[Ss][Aa][Vv][Oo][Ll]([\\.:]|\n|\r\n|$)",
|
|
4
|
+
"answer": "[Jj][Aa][Vv][Oo][Bb]\\s?[№N]?([0-9]+)?\\s?[\\.:]",
|
|
5
|
+
"handout": "[Tt][Aa][Rr][Qq][Aa][Tt][Mm][Aa][\\s\\s][Mm][Aa][Tt][Ee][Rr][Ii][Aa][Ll][\\.:]",
|
|
6
|
+
"zachet": "[Qq][Aa][Bb][Uu][Ll]\\s?[\\.:]",
|
|
7
|
+
"nezachet": "[Qq][Aa][Bb][Uu][Ll]\\s[Ee][Mm][Aa][Ss]?[\\.:]",
|
|
8
|
+
"comment": "[Ii][Zz][Oo][Hh]\\s?[№N]?([0-9]+)?\\s?[\\.:]",
|
|
9
|
+
"author": "[Mm][Uu][Aa][Ll][Ll][Ii][Ff]([Ll][Aa][Rr])?\\s?[\\.:]",
|
|
10
|
+
"source": "[Mm][Aa][Nn][Bb][Aa]([Ll][Aa][Rr])?\\s?[\\.:]",
|
|
11
|
+
"editor": "(M|Tur\\sm)[Uu][Hh][Aa][Rr][Rr][Ii][Rr]([Ll][Aa][Rr][Ii]?)?(\\s?[\\.:]|\\s[\\-–—]+\\s)",
|
|
12
|
+
"date": "[Ss][Aa][Nn][Aa]\\s?[\\.:]",
|
|
13
|
+
"date2": "(^|\\s)[Yy]anvar|[Ff]evral|[Mm]art|[Aa]prel|[Mm]ay|[Ii]yun|[Ii]yul|[Aa]vgust|[Ss]entabr|[Oo]ktabr|[Nn]oyabr|[Dd]ekabr(\\s|$)",
|
|
14
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
15
|
+
"handout_short": "T[Aa][Rr][Qq][Aa][Tt]"
|
|
16
|
+
}
|
|
@@ -11,5 +11,6 @@
|
|
|
11
11
|
"editor": "(М|Тур\\sм)[Уу][Ҳҳ][Аа][Рр][Рр][Ии][Рр]([Лл][Аа][Рр][Ии]?)?(\\s?[\\.:]|\\s[\\-–—]+\\s)",
|
|
12
12
|
"date": "С[Аа][Нн][Аа]\\s?[\\.:]",
|
|
13
13
|
"date2": "(^|\\s)январь|февраль|март|апрель|май|июнь|июль|август|сентябрь|октябрь|ноябрь|декабрь(\\s|$)",
|
|
14
|
-
"number": "^[0-9]+[\\.\\)]\\s*"
|
|
15
|
-
|
|
14
|
+
"number": "^[0-9]+[\\.\\)]\\s*",
|
|
15
|
+
"handout_short": "Т[Аа][Рр][Ққ][Аа][Тт]"
|
|
16
|
+
}
|
chgksuite/trello.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
|
-
import codecs
|
|
4
3
|
import json
|
|
5
4
|
import os
|
|
6
5
|
import pdb
|
|
@@ -52,7 +51,7 @@ def upload_file(filepath, trello, list_name=None):
|
|
|
52
51
|
assert lid is not None
|
|
53
52
|
print(f"uploading to list '{list_['name']}'")
|
|
54
53
|
content = ""
|
|
55
|
-
with
|
|
54
|
+
with open(filepath, "r", encoding="utf-8") as f:
|
|
56
55
|
content = f.read()
|
|
57
56
|
cards = re.split(r"(\r?\n){2,}", content)
|
|
58
57
|
cards = [x for x in cards if x != "" and x != "\n" and x != "\r\n"]
|
|
@@ -255,7 +254,7 @@ def gui_trello_download(args):
|
|
|
255
254
|
|
|
256
255
|
board_id_path = os.path.join(args.folder, ".board_id")
|
|
257
256
|
if os.path.isfile(board_id_path):
|
|
258
|
-
with
|
|
257
|
+
with open(board_id_path, "r", encoding="utf-8") as f:
|
|
259
258
|
board_id = f.read().rstrip()
|
|
260
259
|
else:
|
|
261
260
|
board_id = get_board_id(path=args.folder)
|
|
@@ -401,14 +400,14 @@ def gui_trello_download(args):
|
|
|
401
400
|
result.extend(_lists[_list["name"]])
|
|
402
401
|
filename = "singlefile.4s"
|
|
403
402
|
print("outputting {}".format(filename))
|
|
404
|
-
with
|
|
403
|
+
with open(filename, "w", encoding="utf-8") as f:
|
|
405
404
|
for item in result:
|
|
406
405
|
f.write("\n" + item + "\n")
|
|
407
406
|
else:
|
|
408
407
|
for _list in _lists:
|
|
409
408
|
filename = "{}.4s".format(_list)
|
|
410
409
|
print("outputting {}".format(filename))
|
|
411
|
-
with
|
|
410
|
+
with open(filename, "w", encoding="utf-8") as f:
|
|
412
411
|
for item in _lists[_list]:
|
|
413
412
|
f.write("\n" + item + "\n")
|
|
414
413
|
|
|
@@ -421,12 +420,12 @@ def get_board_id(path=None):
|
|
|
421
420
|
print(" board_id")
|
|
422
421
|
print()
|
|
423
422
|
board_id = input(
|
|
424
|
-
"Please paste your board_id
|
|
423
|
+
"Please paste your board_id (or the board link, we'll parse it): "
|
|
425
424
|
).rstrip()
|
|
426
425
|
if "trello.com" in board_id:
|
|
427
426
|
board_id = re_bi.search(board_id).group(1)
|
|
428
427
|
if path:
|
|
429
|
-
with
|
|
428
|
+
with open(os.path.join(path, ".board_id"), "w", encoding="utf-8") as f:
|
|
430
429
|
f.write(board_id)
|
|
431
430
|
return board_id
|
|
432
431
|
|
|
@@ -437,7 +436,7 @@ def get_token(tokenpath, args):
|
|
|
437
436
|
else:
|
|
438
437
|
webbrowser.open(TRELLO_URL)
|
|
439
438
|
token = input("Please paste the obtained token: ").rstrip()
|
|
440
|
-
with
|
|
439
|
+
with open(tokenpath, "w", encoding="utf-8") as f:
|
|
441
440
|
f.write(token)
|
|
442
441
|
return token
|
|
443
442
|
|
|
@@ -452,7 +451,7 @@ def gui_trello(args):
|
|
|
452
451
|
if not os.path.isfile(tokenpath):
|
|
453
452
|
token = get_token(tokenpath, args)
|
|
454
453
|
else:
|
|
455
|
-
with
|
|
454
|
+
with open(tokenpath, "r", encoding="utf-8") as f:
|
|
456
455
|
token = f.read().rstrip()
|
|
457
456
|
|
|
458
457
|
with open(os.path.join(resourcedir, "trello.json")) as f:
|