]> git.phdru.name Git - m_lib.git/commitdiff
Fix UserList for Py3 compatibility
authorOleg Broytman <phd@phdru.name>
Mon, 25 Jul 2016 16:05:26 +0000 (19:05 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 25 Jul 2016 21:02:46 +0000 (00:02 +0300)
m_lib/flad/flad.py

index b2446d824bfa8cdeac042995405c0e4ca6f4a159..a058fabbea34c0f9a64feb7d22483dcce6dd85ca 100644 (file)
@@ -5,7 +5,6 @@
 
 
 import string
-from UserList import UserList
 
 
 # Flad restriction error
@@ -15,7 +14,7 @@ checking_error = "flad.checking_error"
 def_keysep = ": "
 
 
-class Flad(UserList):
+class Flad(list):
    """
       Class to represent memory database.
       FLAD database is a list of records,
@@ -27,7 +26,7 @@ class Flad(UserList):
    # field_sep = rec_sep = '\n'
 
    def __init__(self, check_record_func = None, key_sep = def_keysep):
-      UserList.__init__(self)
+      list.__init__(self)
       self.check_record_func = check_record_func
       self.key_sep = key_sep
 
@@ -53,31 +52,31 @@ class Flad(UserList):
       if not self.check_record(item):
          self.checking_error()
       else:
-         UserList.__setitem__(self, i, item)
+         list.__setitem__(self, i, item)
 
 
-   def __setslice__(self, i, j, list):
-      if list:
-         copy_list = list[:]
-         for item in list:
+   def __setslice__(self, i, j, v_list):
+      if v_list:
+         copy_list = v_list[:]
+         for item in v_list:
             if not self.check_record(item):
                self.checking_error()
                del copy_list[copy_list.index(item)]
-         UserList.__setslice__(self, i, j, copy_list)
+         list.__setslice__(self, i, j, copy_list)
 
 
    def append(self, item):
       if not self.check_record(item):
          self.checking_error()
       else:
-         UserList.append(self, item)
+         list.append(self, item)
 
 
    def insert(self, i, item):
       if not self.check_record(item):
          self.checking_error()
       else:
-         UserList.insert(self, i, item)
+         list.insert(self, i, item)
 
 
    def split_key(self, line):