vocably2anki 0.1.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.
v2a.py
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
import arguably
|
3
|
+
import sys
|
4
|
+
|
5
|
+
|
6
|
+
@arguably.command
|
7
|
+
def convert(
|
8
|
+
input: Path, output: str, vocably_separator: str = "\t", anki_separator: str = ": "
|
9
|
+
):
|
10
|
+
"""
|
11
|
+
converts a Vocably export file to Anki deck
|
12
|
+
|
13
|
+
Args:
|
14
|
+
input: the input Vocably file
|
15
|
+
output: the output Anki file (use "-" for stdout). File is overwritten.
|
16
|
+
vocably_separator: the characters separating the vocably columns
|
17
|
+
anki_separator: the characters separating two sides of the deck card
|
18
|
+
"""
|
19
|
+
|
20
|
+
if output == "-":
|
21
|
+
out = sys.stdout
|
22
|
+
else:
|
23
|
+
out = open(output, encoding="utf-8", mode="w")
|
24
|
+
|
25
|
+
try:
|
26
|
+
with open(input, encoding="utf-8") as f:
|
27
|
+
first = True
|
28
|
+
for line in f.readlines():
|
29
|
+
if first:
|
30
|
+
first = False
|
31
|
+
continue
|
32
|
+
line = line.strip()
|
33
|
+
# some usage colums contain newlines with *-delimited bullet points. Just skip for now, we're not exporting them at all
|
34
|
+
if line.startswith("*"):
|
35
|
+
continue
|
36
|
+
|
37
|
+
parts = line.split(vocably_separator)
|
38
|
+
|
39
|
+
word = parts[0]
|
40
|
+
translation = parts[1]
|
41
|
+
part_of_speech = parts[2]
|
42
|
+
|
43
|
+
print(f"{word} <i>({part_of_speech})</i>{anki_separator}{translation} <i>({part_of_speech})</i>", file=out)
|
44
|
+
finally:
|
45
|
+
out.close()
|
46
|
+
|
47
|
+
|
48
|
+
if __name__ == "__main__":
|
49
|
+
arguably.run()
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: vocably2anki
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Add your description here
|
5
|
+
Requires-Python: >=3.12
|
6
|
+
Description-Content-Type: text/markdown
|
7
|
+
Requires-Dist: arguably>=1.3.0
|
8
|
+
|
9
|
+
A quick converter of Vocably-export files into my own Anki format. Extremely hard-coded.
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
|
13
|
+
```
|
14
|
+
❯ uv run .\v2a.py -h
|
15
|
+
usage: v2a.py [-h] vocably [vocably-separator] [anki-separator]
|
16
|
+
|
17
|
+
converts a Vocably export file to Anki deck
|
18
|
+
|
19
|
+
positional arguments:
|
20
|
+
vocably the input CSV file (type: Path)
|
21
|
+
vocably-separator the characters separating the vocably columns (type: str, default: |)
|
22
|
+
anki-separator the characters separating two sides of the deck card (type: str, default: ': ')
|
23
|
+
|
24
|
+
options:
|
25
|
+
-h, --help show this help message and exit
|
26
|
+
```
|
@@ -0,0 +1,5 @@
|
|
1
|
+
v2a.py,sha256=pBBXftJVuh5xO3VEp8mu_2iCx_rqtx4_7FEZxIfAQ7I,1463
|
2
|
+
vocably2anki-0.1.0.dist-info/METADATA,sha256=0UaylVI-19LRgUs5ytkslGjmfkJ2YDkK5Cx6BHcIThE,783
|
3
|
+
vocably2anki-0.1.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
4
|
+
vocably2anki-0.1.0.dist-info/top_level.txt,sha256=_bVl2RnSFCvyWVROPWM2SgHP4dEiqvSk1-9Aoxs9PNU,4
|
5
|
+
vocably2anki-0.1.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
v2a
|