-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSection.py
More file actions
33 lines (31 loc) · 981 Bytes
/
Section.py
File metadata and controls
33 lines (31 loc) · 981 Bytes
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
from Attribute import Attribute
import sys
class Section:
def __init__(self,name):
self.name = name
self.attributes = {}
def addAttribute(self,name,value,category):
attribute = Attribute(name,value,category)
self.attributes[name] = attribute
def getAttributeValue(self,name):
return self.attributes[name]
def setAttributeValue(self,name,value):
if name not in self.attributes:
try:
Error = ValueError()
Error.msg = 'Error Attribute:' + name + ' not valid in Section:' + self.name + ', the available Attributes are ' + str(self.attributes.keys())
raise Error
except ValueError as e:
print("Attribute value error:", e.msg)
sys.exit(1)
else:
self.attributes[name].setValue(value)
# def isOK():
# for key, value in self.attributes.iteritems():
def toString(self):
print self.name
for key, value in self.attributes.iteritems():
print 'Attribute key:' + str(key)
print 'value:'
value.toString()
print '-------'