if self.first_section:
if string.strip(line) != '':
- raise error, "non-empty line before 1st section"
+ raise error("non-empty line before 1st section")
elif (string.strip(line) == '') or (string.lstrip(line)[0] == ';') : # Empty line or comment
record[0].append(line)
# so it is not ready to be checked :(
# And, of course, two keys with the same name
# cannot be added to dictionary
- raise KeyError, "field key \"" + key + "\" already in record"
+ raise KeyError("field key \"" + key + "\" already in record")
record[0].append(key)
record[1][key] = value
else:
if self.first_section and (string.strip(line) != ''):
- raise error, "non-empty line before 1st section"
+ raise error("non-empty line before 1st section")
# else: line had been appended to section in __parse_line()
else: # This called after last line of the source file
def add_section(self, section):
rec_no = self.find_section(section)
if rec_no >= 0:
- raise section_error, "section [%s] already exists" % section
+ raise section_error("section [%s] already exists" % section)
self.append((section, [], {}))
def del_section(self, section):
rec_no = self.find_section(section)
if rec_no < 0:
- raise section_error, "section [%s] does not exists" % section
+ raise section_error("section [%s] does not exists" % section)
del self[rec_no]
def get_keyvalue(self, section, key):
rec_no = self.find_section(section)
if rec_no < 0:
- raise section_error, "section [%s] does not exists" % section
+ raise section_error("section [%s] does not exists" % section)
record = self[rec_no]
if key not in record[1]:
- raise KeyError, "section [%s] does not has `%s' key" % (section, key)
+ raise KeyError("section [%s] does not has `%s' key" % (section, key))
return record[2][key]
def del_key(self, section, key):
rec_no = self.find_section(section)
if rec_no < 0:
- raise section_error, "section [%s] does not exists" % section
+ raise section_error("section [%s] does not exists" % section)
record = self[rec_no]
if key not in record[1]:
- raise KeyError, "section [%s] does not has `%s' key" % (section, key)
+ raise KeyError("section [%s] does not has `%s' key" % (section, key))
klist = record[1]
del klist[klist.index(key)]