-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsection_option.py
59 lines (43 loc) · 1.21 KB
/
section_option.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
__author__ = 'faebser'
class Option(object):
value = None
choices = None
reference = None
def __unicode__(self):
return unicode(self.value)
def __str__(self):
return self.__unicode__()
def has_choices(self):
if self.choices is None or len(self.choices) is 0:
return False
else:
return True
def update_value(self, value):
self.reference.value = value
self.value = value
def __init__(self, ref, choices=None, ):
self.value = ref.value
self.choices = choices
self.reference = ref
def __repr__(self):
return str(self.value)
class Section(object):
options = None
template = None
def update(self, option, value):
self.options[option].update_value(value)
def __unicode__(self):
return unicode(self.options)
def __str__(self):
return self.__unicode__()
def __init__(self):
pass
def to_dict(self):
data = dict()
for key in self.options.iterkeys():
data.update({
key: self.options[key].value
})
return data
def __repr__(self):
return unicode(self.options)