]> git.phdru.name Git - m_lib.git/commitdiff
Remove import string 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:06:36 +0000 (00:06 +0300)
m_lib/flad/flad.py
m_lib/flad/fladw.py
m_lib/tty_menu.py

index a058fabbea34c0f9a64feb7d22483dcce6dd85ca..232852f78dd20b63eb48491465360d738c4cf7f2 100644 (file)
@@ -4,9 +4,6 @@
 """
 
 
-import string
-
-
 # Flad restriction error
 checking_error = "flad.checking_error"
 
@@ -83,7 +80,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 +115,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
 
index ccbd5d53ed4202f1e985b9c30417ad4f9ba16964..fa0007443d7060a54257a416ab60d2d6160f11b5 100644 (file)
@@ -3,7 +3,7 @@
 """
 
 
-import string, re
+import re
 from m_lib.flad import flad
 
 
@@ -33,10 +33,10 @@ 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) != '':
+         if line.strip() != '':
             raise error("non-empty line before 1st section")
 
-      elif (string.strip(line) == '') or (string.lstrip(line)[0] == ';') : # Empty line or comment
+      elif (line.strip() == '') or (line.lstrip()[0] == ';') : # Empty line or comment
          record[0].append(line)
 
       else:
@@ -72,7 +72,7 @@ class Flad_WIni(flad.Flad):
                self.section = section
 
          else:
-            if self.first_section and (string.strip(line) != ''):
+            if self.first_section and (line.strip() != ''):
                raise error("non-empty line before 1st section")
             # else: line had been appended to section in __parse_line()
 
@@ -85,7 +85,7 @@ class Flad_WIni(flad.Flad):
             klist = record[1]
             if klist:
                l = len(klist) - 1
-               if string.strip(klist[l]) == '':
+               if klist[l].strip() == '':
                   del klist[l]
 
       return 0
@@ -110,7 +110,7 @@ class Flad_WIni(flad.Flad):
 
          if record[1]:
             for key in record[1]:
-               if string.strip(key) == '' or string.lstrip(key)[0] == ';' :
+               if key.strip() == '' or key.lstrip()[0] == ';' :
                   outfile.write(key)
                else:
                   outfile.write(key + self.key_sep + record[2][key] + '\n')
index 852de1d601929faf2e3a4ec6b9328f9011bd51cb..d6fd92069f1f20ebd8a2400721337a57fb5d27bd 100755 (executable)
@@ -3,7 +3,6 @@
 
 
 from __future__ import print_function
-import string
 
 
 try: