chgksuite 0.27.1__py3-none-any.whl → 0.27.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 +14 -2
- chgksuite/composer/__init__.py +2 -3
- chgksuite/parser.py +8 -3
- chgksuite/trello.py +2 -3
- chgksuite/version.py +1 -1
- {chgksuite-0.27.1.dist-info → chgksuite-0.27.2.dist-info}/METADATA +1 -1
- {chgksuite-0.27.1.dist-info → chgksuite-0.27.2.dist-info}/RECORD +10 -10
- {chgksuite-0.27.1.dist-info → chgksuite-0.27.2.dist-info}/WHEEL +0 -0
- {chgksuite-0.27.1.dist-info → chgksuite-0.27.2.dist-info}/entry_points.txt +0 -0
- {chgksuite-0.27.1.dist-info → chgksuite-0.27.2.dist-info}/licenses/LICENSE +0 -0
chgksuite/common.py
CHANGED
|
@@ -27,7 +27,7 @@ QUESTION_LABELS = [
|
|
|
27
27
|
"number",
|
|
28
28
|
"setcounter",
|
|
29
29
|
]
|
|
30
|
-
SEP =
|
|
30
|
+
SEP = "\n"
|
|
31
31
|
try:
|
|
32
32
|
ENC = sys.stdout.encoding or "utf8"
|
|
33
33
|
except AttributeError:
|
|
@@ -152,6 +152,19 @@ def ensure_utf8(s):
|
|
|
152
152
|
return s
|
|
153
153
|
|
|
154
154
|
|
|
155
|
+
def read_text_file(filepath, encoding="utf-8"):
|
|
156
|
+
"""Read a text file, fixing corrupted line endings (\r\r\n -> \n) if present."""
|
|
157
|
+
with open(filepath, "rb") as f:
|
|
158
|
+
raw = f.read()
|
|
159
|
+
# Fix corrupted line endings at byte level before decoding
|
|
160
|
+
if b"\r\r\n" in raw:
|
|
161
|
+
raw = raw.replace(b"\r\r\n", b"\n")
|
|
162
|
+
text = raw.decode(encoding)
|
|
163
|
+
# Normalize any remaining line endings
|
|
164
|
+
text = text.replace("\r\n", "\n").replace("\r", "\n")
|
|
165
|
+
return text
|
|
166
|
+
|
|
167
|
+
|
|
155
168
|
class DummyLogger(object):
|
|
156
169
|
def info(self, *args, **kwargs):
|
|
157
170
|
pass
|
|
@@ -370,6 +383,5 @@ def compose_4s(structure, args=None):
|
|
|
370
383
|
+ SEP
|
|
371
384
|
)
|
|
372
385
|
tmp = re.sub(r"{}+".format(SEP), SEP, tmp)
|
|
373
|
-
tmp = tmp.replace("\r\r", "\r")
|
|
374
386
|
result += tmp + SEP
|
|
375
387
|
return result
|
chgksuite/composer/__init__.py
CHANGED
|
@@ -12,6 +12,7 @@ from chgksuite.common import (
|
|
|
12
12
|
get_source_dirs,
|
|
13
13
|
init_logger,
|
|
14
14
|
log_wrap,
|
|
15
|
+
read_text_file,
|
|
15
16
|
set_lastdir,
|
|
16
17
|
)
|
|
17
18
|
from chgksuite.composer.chgksuite_parser import parse_4s
|
|
@@ -74,9 +75,7 @@ def process_file_wrapper(filename, sourcedir, targetdir, args):
|
|
|
74
75
|
|
|
75
76
|
def parse_filepath(filepath, args=None):
|
|
76
77
|
args = args or DefaultArgs()
|
|
77
|
-
|
|
78
|
-
input_text = input_file.read()
|
|
79
|
-
input_text = input_text.replace("\r", "")
|
|
78
|
+
input_text = read_text_file(filepath)
|
|
80
79
|
debug_dir = os.path.dirname(os.path.abspath(filepath))
|
|
81
80
|
return parse_4s(
|
|
82
81
|
input_text, randomize=args.randomize, debug=args.debug, debug_dir=debug_dir
|
chgksuite/parser.py
CHANGED
|
@@ -38,6 +38,7 @@ from chgksuite.common import (
|
|
|
38
38
|
init_logger,
|
|
39
39
|
load_settings,
|
|
40
40
|
log_wrap,
|
|
41
|
+
read_text_file,
|
|
41
42
|
set_lastdir,
|
|
42
43
|
)
|
|
43
44
|
from chgksuite.composer import gui_compose
|
|
@@ -47,7 +48,7 @@ from chgksuite.typotools import re_url
|
|
|
47
48
|
from chgksuite.typotools import remove_excessive_whitespace as rew
|
|
48
49
|
|
|
49
50
|
|
|
50
|
-
SEP =
|
|
51
|
+
SEP = "\n"
|
|
51
52
|
EDITORS = {
|
|
52
53
|
"win32": "notepad",
|
|
53
54
|
"linux2": "xdg-open", # python2
|
|
@@ -916,6 +917,9 @@ class UnknownEncodingException(Exception):
|
|
|
916
917
|
|
|
917
918
|
def chgk_parse_txt(txtfile, encoding=None, defaultauthor="", args=None, logger=None):
|
|
918
919
|
raw = open(txtfile, "rb").read()
|
|
920
|
+
# Fix corrupted line endings at byte level before decoding
|
|
921
|
+
if b"\r\r\n" in raw:
|
|
922
|
+
raw = raw.replace(b"\r\r\n", b"\n")
|
|
919
923
|
if not encoding:
|
|
920
924
|
if chardet.detect(raw)["confidence"] > 0.7:
|
|
921
925
|
encoding = chardet.detect(raw)["encoding"]
|
|
@@ -926,9 +930,10 @@ def chgk_parse_txt(txtfile, encoding=None, defaultauthor="", args=None, logger=N
|
|
|
926
930
|
"or resave with a less exotic encoding".format(txtfile)
|
|
927
931
|
)
|
|
928
932
|
text = raw.decode(encoding)
|
|
929
|
-
|
|
933
|
+
# Normalize any remaining line endings
|
|
934
|
+
text = text.replace("\r\n", "\n").replace("\r", "\n")
|
|
930
935
|
if text[0:10] == "Чемпионат:":
|
|
931
|
-
return chgk_parse_db(text
|
|
936
|
+
return chgk_parse_db(text, debug=args.debug, logger=logger)
|
|
932
937
|
return chgk_parse(text.replace("_", "\\_"), defaultauthor=defaultauthor, args=args)
|
|
933
938
|
|
|
934
939
|
|
chgksuite/trello.py
CHANGED
|
@@ -15,6 +15,7 @@ from chgksuite.common import (
|
|
|
15
15
|
get_lastdir,
|
|
16
16
|
get_source_dirs,
|
|
17
17
|
log_wrap,
|
|
18
|
+
read_text_file,
|
|
18
19
|
set_lastdir,
|
|
19
20
|
)
|
|
20
21
|
|
|
@@ -50,9 +51,7 @@ def upload_file(filepath, trello, list_name=None):
|
|
|
50
51
|
raise Exception(f"list '{list_name}' not found")
|
|
51
52
|
assert lid is not None
|
|
52
53
|
print(f"uploading to list '{list_['name']}'")
|
|
53
|
-
content =
|
|
54
|
-
with open(filepath, "r", encoding="utf-8") as f:
|
|
55
|
-
content = f.read()
|
|
54
|
+
content = read_text_file(filepath)
|
|
56
55
|
cards = re.split(r"(\r?\n){2,}", content)
|
|
57
56
|
cards = [x for x in cards if x != "" and x != "\n" and x != "\r\n"]
|
|
58
57
|
for card in cards:
|
chgksuite/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.27.
|
|
1
|
+
__version__ = "0.27.2"
|
|
@@ -2,15 +2,15 @@ chgksuite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
2
2
|
chgksuite/__main__.py,sha256=0-_jfloveTW3SZYW5XEagbyaHKGCiDhGNgcLxsT_dMs,140
|
|
3
3
|
chgksuite/_html2md.py,sha256=IzPlRo4dVZNVdlnoCQFjSEfvpFZ0KdvVzfKSeIt15lM,2454
|
|
4
4
|
chgksuite/cli.py,sha256=fHa7HNJeQeUNXpbqnMnSXHOMpbxpaph6d3KdVNx9uNg,41257
|
|
5
|
-
chgksuite/common.py,sha256=
|
|
5
|
+
chgksuite/common.py,sha256=27HEx5Us0xXywUAWtjlkhsXs67-Cx7ylJSlUViUsOgU,11778
|
|
6
6
|
chgksuite/lastdir,sha256=BbZVRYZnXBQzJUrl7a2e4xuUcfmq6asNI705pTxBfD4,49
|
|
7
|
-
chgksuite/parser.py,sha256=
|
|
7
|
+
chgksuite/parser.py,sha256=JJ_koqLDHAl-IHUe4sTyOK2gySL6uVW5HJmO1xcqD8Q,46042
|
|
8
8
|
chgksuite/parser_db.py,sha256=Ngh2ZYhAyetb6Sa-5xC9aX8quX9Ar1WheSfhSy-JADw,11105
|
|
9
|
-
chgksuite/trello.py,sha256=
|
|
9
|
+
chgksuite/trello.py,sha256=hc_RMlWrNrPzg9AsgC8KE9ow3JUbetMJM_HuiJlBSIk,14693
|
|
10
10
|
chgksuite/typotools.py,sha256=J2AEQbfcR0HHSu5WCALpj4Ya_ngOMXRh7esJgcybWQM,12797
|
|
11
|
-
chgksuite/version.py,sha256=
|
|
11
|
+
chgksuite/version.py,sha256=_CerHyxnUJ2hU0sB7noT3JBjjI0ohEM5boAPBoFxOg4,23
|
|
12
12
|
chgksuite/vulture_whitelist.py,sha256=P__p_X0zt10ivddIf81uyxsobV14vFg8uS2lt4foYpc,3582
|
|
13
|
-
chgksuite/composer/__init__.py,sha256=
|
|
13
|
+
chgksuite/composer/__init__.py,sha256=a02nOz1QqPi84621-v3JD0Nn1_M0_fHyzKqG5Wp2ahI,6511
|
|
14
14
|
chgksuite/composer/chgksuite_parser.py,sha256=ItlTenviFDuqP-f1960nzD-gRPFDQy4RdOL39PswTvg,9044
|
|
15
15
|
chgksuite/composer/composer_common.py,sha256=kc-_Tc9NjevfXGj4fXoa9fye9AO0EuMSnEPJnS0n-aQ,16281
|
|
16
16
|
chgksuite/composer/db.py,sha256=DI-goR4V69S8bufNfW5smTFG9puiyjcxC1u1TFuhfYs,8162
|
|
@@ -56,8 +56,8 @@ chgksuite/resources/regexes_uz_cyr.json,sha256=D4AyaEPEY753I47Ky2Fwol_4kxQsl-Yu9
|
|
|
56
56
|
chgksuite/resources/template.docx,sha256=Do29TAsg3YbH0rRSaXhVzKEoh4pwXkklW_idWA34HVE,11189
|
|
57
57
|
chgksuite/resources/template.pptx,sha256=hEFWqE-yYpwZ8ejrMCJIPEyoMT3eDqaqtiEeQ7I4fyk,29777
|
|
58
58
|
chgksuite/resources/trello.json,sha256=M5Q9JR-AAJF1u16YtNAxDX-7c7VoVTXuq4POTqYvq8o,555
|
|
59
|
-
chgksuite-0.27.
|
|
60
|
-
chgksuite-0.27.
|
|
61
|
-
chgksuite-0.27.
|
|
62
|
-
chgksuite-0.27.
|
|
63
|
-
chgksuite-0.27.
|
|
59
|
+
chgksuite-0.27.2.dist-info/METADATA,sha256=zGPoXuzOtUiNMdE7NDeSJE25K6XHaoQ4pPLBkfBLz_c,1152
|
|
60
|
+
chgksuite-0.27.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
61
|
+
chgksuite-0.27.2.dist-info/entry_points.txt,sha256=lqjX6ULQZGDt0rgouTXBuwEPiwKkDQkSiNsT877A_Jg,54
|
|
62
|
+
chgksuite-0.27.2.dist-info/licenses/LICENSE,sha256=_a1yfntuPmctLsuiE_08xMSORuCfGS8X5hQph2U_PUw,1081
|
|
63
|
+
chgksuite-0.27.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|