-
Notifications
You must be signed in to change notification settings - Fork 0
/
yamlfile.py
60 lines (42 loc) · 1.31 KB
/
yamlfile.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import logging, yaml
class Section(object):
def __init__(self, x):
_, section = x
self._section = section
def has_example(self):
return False
def get_drills(self):
if 'sentences' in self._section:
return map(Drill, self._section['sentences'])
else:
return list()
class Drill(object):
def __init__(self, sentence):
self._german = sentence['german']
self._korean = sentence['korean']
def get_student(self):
return Sentence(self._korean)
def get_teacher(self):
return Sentence(self._german)
def play(self):
logging.info('nothing to play')
class Sentence(object):
def __init__(self, sentence):
self._sentence = sentence
def get_text(self):
if type(self._sentence) is list:
return '<br>'.join(self._sentence)
else:
return self._sentence
def play(self):
logging.info('nothing to play')
class YamlFile(object):
def __init__(self, path):
logging.info('opening {}'.format(path))
with open(path) as fp:
data = yaml.load(fp.read())
self._sections = data['sections'].items()
def parse(self):
pass
def get_drill_sections(self):
return map(Section, self._sections)