]> git.phdru.name Git - bookmarks_db.git/commitdiff
Feat(subproc.py): Get rid of module string
authorOleg Broytman <phd@phdru.name>
Fri, 20 Oct 2017 18:38:32 +0000 (21:38 +0300)
committerOleg Broytman <phd@phdru.name>
Fri, 20 Oct 2017 18:38:32 +0000 (21:38 +0300)
Use string methods instead of functions.

subproc.py

index 886dc4727a32f7c956ef255fbb00361916c9b996..e3c2717da8a4207ba0a099e02d9278bebeda7dd0 100755 (executable)
@@ -49,7 +49,6 @@ __version__ = "Revision: 2.0 "
 import os
 import select
 import signal
-import string
 import sys
 import time
 
@@ -101,7 +100,7 @@ class Subprocess:
         """Fork a subprocess with designated COMMAND (default, self.cmd)."""
         if cmd:
             self.cmd = cmd
-        cmd = string.split(self.cmd)
+        cmd = self.cmd.split()
         pRc, cWp = os.pipe()            # parent-read-child, child-write-parent
         cRp, pWc = os.pipe()            # child-read-parent, parent-write-child
         pRe, cWe = os.pipe()            # parent-read-error, child-write-error
@@ -472,7 +471,7 @@ class ReadBuf:
         any newline."""
 
         if self.buf:
-            to = string.find(self.buf, '\n')
+            to = self.buf.find('\n')
             if to != -1:
                 got, self.buf = self.buf[:to+1], self.buf[to+1:]
                 return got                                              # ===>
@@ -493,7 +492,7 @@ class ReadBuf:
             if sel[0]:
                 got = got + os.read(self.fd, self.chunkSize)
 
-            to = string.find(got, '\n')
+            to = got.find('\n')
             if to != -1:
                 got, self.buf = got[:to+1], got[to+1:]
                 return got                                              # ===>
@@ -541,7 +540,7 @@ class RecordFile:
         line = f.readline()[:-1]
         if line:
             try:
-                l = string.atoi(line)
+                l = int(line)
             except ValueError:
                 raise IOError(("corrupt %s file structure"
                                % self.__class__.__name__))
@@ -627,9 +626,8 @@ class Ph:
                 raise ValueError("ph failed match: '%s'" % response)    # ===>
             for line in response:
                 # convert to a dict:
-                line = string.splitfields(line, ':')
-                it[string.strip(line[0])] = (
-                    string.strip(string.join(line[1:])))
+                line = line.split(':')
+                it[line.strip([0])] = (''.join(line[1:])).strip()
 
     def getreply(self):
         """Consume next response from ph, returning list of lines or string
@@ -675,7 +673,7 @@ class Ph:
         while iterations < maxIter:
             got = got + self.proc.readPendingChars()
             # Strip out all but the last incomplete line:
-            got = string.splitfields(got, '\n')[-1]
+            got = got.split('\n')[-1]
             if got == 'ph> ':
                 return    # Ok.                             ===>
             time.sleep(pause)