generate_tsv.py 766 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python

import dominate
from dominate import tags
import os
import yaml

data = list(yaml.load_all(open('/home/me/documents/anki/factory/Cymraeg/signs/deck.yaml'), Loader=yaml.SafeLoader))

id = 0

for img in data[0]:
    for line in img['text']:
        print(id, end="\t")
        print("<img src=\"arwyddion-" + img['file'] + "\" />", end="\t")
        print(line['cy'], end="\t")
        if 'en' in line:
            print(line['en'], end="\t")
        else:
            print("", end="\t")
        if 'en-translation' in line:
            print(line['en-translation'], end="\t")
        else:
            print("", end="\t")
        if 'verbatim' in line:
            print(line['verbatim'])
        else:
            print()
        id = id + 1