From d594d5acd1c256017e0343ba7910a127a319e2bd Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 20 Oct 2017 21:38:32 +0300 Subject: [PATCH] Feat(subproc.py): Get rid of module string Use string methods instead of functions. --- subproc.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/subproc.py b/subproc.py index 886dc47..e3c2717 100755 --- a/subproc.py +++ b/subproc.py @@ -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) -- 2.39.2