X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_lib%2Fflad%2Ffladw.py;h=781c472b0437ce4cfc3f0f2358fcc2941d677956;hb=e75d2c94f9bd326ebaace635a06599a1be35b024;hp=fe48b007c25b0ca65d9c3d62edd7f1f60378d435;hpb=13a21366e5dbeb344656cbfd00432be176ae5cdb;p=m_lib.git diff --git a/m_lib/flad/fladw.py b/m_lib/flad/fladw.py index fe48b00..781c472 100644 --- a/m_lib/flad/fladw.py +++ b/m_lib/flad/fladw.py @@ -1,7 +1,5 @@ """ Flat ASCII Database to load WIN.INI-like files. - - Written by Broytman. Copyright (C) 1997-2005 PhiloSoft Design """ @@ -35,8 +33,8 @@ class Flad_WIni(flad.Flad): return match.group(1) # Signal to stop filling the record (section) and start a new one if self.first_section: - if string.strip(line) <> '': - raise error, "non-empty line before 1st section" + if string.strip(line) != '': + 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) @@ -48,7 +46,7 @@ class Flad_WIni(flad.Flad): # 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 @@ -74,8 +72,8 @@ class Flad_WIni(flad.Flad): self.section = section else: - if self.first_section and (string.strip(line) <> ''): - raise error, "non-empty line before 1st section" + if self.first_section and (string.strip(line) != ''): + 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 @@ -133,7 +131,7 @@ class Flad_WIni(flad.Flad): 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, [], {})) @@ -141,7 +139,7 @@ class Flad_WIni(flad.Flad): 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] @@ -162,11 +160,11 @@ class Flad_WIni(flad.Flad): 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] @@ -186,11 +184,11 @@ class Flad_WIni(flad.Flad): 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)]