[Python-checkins] python/dist/src/Lib shlex.py,1.19,1.20
nnorwitz@users.sourceforge.net
nnorwitz@users.sourceforge.net
Thu, 17 Apr 2003 16:09:10 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv8654/Lib
Modified Files:
shlex.py
Log Message:
Use True in a few more places.
Use isinstance(somestring, basestring) instead of type() as per PEP 8
Index: shlex.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/shlex.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** shlex.py 17 Apr 2003 22:01:17 -0000 1.19
--- shlex.py 17 Apr 2003 23:09:08 -0000 1.20
***************
*** 11,16 ****
import sys
- from types import StringTypes
-
try:
from cStringIO import StringIO
--- 11,14 ----
***************
*** 23,27 ****
"A lexical analyzer class for simple shell-like syntaxes."
def __init__(self, instream=None, infile=None, posix=False):
! if type(instream) in StringTypes:
instream = StringIO(instream)
if instream is not None:
--- 21,25 ----
"A lexical analyzer class for simple shell-like syntaxes."
def __init__(self, instream=None, infile=None, posix=False):
! if isinstance(instream, basestring):
instream = StringIO(instream)
if instream is not None:
***************
*** 66,70 ****
def push_source(self, newstream, newfile=None):
"Push an input source onto the lexer's input source stack."
! if type(newstream) in StringTypes:
newstream = StringIO(newstream)
self.filestack.insert(0, (self.infile, self.instream, self.lineno))
--- 64,68 ----
def push_source(self, newstream, newfile=None):
"Push an input source onto the lexer's input source stack."
! if isinstance(newstream, basestring):
newstream = StringIO(newstream)
self.filestack.insert(0, (self.infile, self.instream, self.lineno))
***************
*** 123,127 ****
quoted = False
escapedstate = ' '
! while 1:
nextchar = self.instream.read(1)
if nextchar == '\n':
--- 121,125 ----
quoted = False
escapedstate = ' '
! while True:
nextchar = self.instream.read(1)
if nextchar == '\n':
***************
*** 253,257 ****
newfile = newfile[1:-1]
# This implements cpp-like semantics for relative-path inclusion.
! if type(self.infile) in StringTypes and not os.path.isabs(newfile):
newfile = os.path.join(os.path.dirname(self.infile), newfile)
return (newfile, open(newfile, "r"))
--- 251,255 ----
newfile = newfile[1:-1]
# This implements cpp-like semantics for relative-path inclusion.
! if isinstance(self.infile, basestring) and not os.path.isabs(newfile):
newfile = os.path.join(os.path.dirname(self.infile), newfile)
return (newfile, open(newfile, "r"))
***************
*** 274,278 ****
return token
! def split(s, posix=1, spaces=1):
lex = shlex(s, posix=posix)
lex.whitespace_split = spaces
--- 272,276 ----
return token
! def split(s, posix=True, spaces=True):
lex = shlex(s, posix=posix)
lex.whitespace_split = spaces