]> git.phdru.name Git - m_lib.git/blobdiff - m_lib/flad/flad.py
Fix exceptions for Py3 compatibility
[m_lib.git] / m_lib / flad / flad.py
index a058fabbea34c0f9a64feb7d22483dcce6dd85ca..8ca1093607a4b3d1f7b5fa5ca77ed07d5d93b637 100644 (file)
@@ -4,11 +4,9 @@
 """
 
 
-import string
-
-
 # Flad restriction error
-checking_error = "flad.checking_error"
+class checking_error(Exception):
+    pass
 
 # Default key/value separator
 def_keysep = ": "
@@ -83,7 +81,7 @@ class Flad(list):
       """
          Split input line to key/value pair and add the pair to dictionary
       """
-      ###line = string.lstrip(line) # Do not rstrip - if empty value, this will remove space from key
+      ###line = line.lstrip() # Do not rstrip - if empty value, this will remove space from key
       if line[-1] == '\n':
          line = line[:-1] # Chop
 
@@ -118,12 +116,12 @@ class Flad(list):
    def feed(self, record, line): # Method can be overriden in subclasses
       if line:
          if self.wait_comment:
-            if string.strip(line) == '':
+            if line.strip() == '':
                self.comment = self.comment + '\n'
                self.wait_string = 0
                return 0
 
-            elif string.lstrip(line)[0] == '#':
+            elif line.lstrip()[0] == '#':
                self.comment = self.comment + line
                return 0
 
@@ -227,7 +225,7 @@ class Flad(list):
             flush_record = 1    # Set flag for all but 1st record
 
          if copy_rec:
-            for key in copy_rec.keys():
+            for key in list(copy_rec.keys()):
                outfile.write(key + self.key_sep + copy_rec[key] + '\n')
                del copy_rec[key]