mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Change the file's indentation from tabs to 4 spaces per level.
This commit is contained in:
parent
c7ed0e3c13
commit
c140131995
1 changed files with 163 additions and 151 deletions
|
@ -44,14 +44,17 @@ class StringIO:
|
|||
self.pos = 0
|
||||
self.closed = 0
|
||||
self.softspace = 0
|
||||
|
||||
def close(self):
|
||||
if not self.closed:
|
||||
self.closed = 1
|
||||
del self.buf, self.pos
|
||||
|
||||
def isatty(self):
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
return 0
|
||||
|
||||
def seek(self, pos, mode = 0):
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
|
@ -63,10 +66,12 @@ class StringIO:
|
|||
elif mode == 2:
|
||||
pos += self.len
|
||||
self.pos = max(0, pos)
|
||||
|
||||
def tell(self):
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
return self.pos
|
||||
|
||||
def read(self, n = -1):
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
|
@ -80,6 +85,7 @@ class StringIO:
|
|||
r = self.buf[self.pos:newpos]
|
||||
self.pos = newpos
|
||||
return r
|
||||
|
||||
def readline(self, length=None):
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
|
@ -97,6 +103,7 @@ class StringIO:
|
|||
r = self.buf[self.pos:newpos]
|
||||
self.pos = newpos
|
||||
return r
|
||||
|
||||
def readlines(self, sizehint = 0):
|
||||
total = 0
|
||||
lines = []
|
||||
|
@ -108,6 +115,7 @@ class StringIO:
|
|||
break
|
||||
line = self.readline()
|
||||
return lines
|
||||
|
||||
def truncate(self, size=None):
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
|
@ -118,6 +126,7 @@ class StringIO:
|
|||
elif size < self.pos:
|
||||
self.pos = size
|
||||
self.buf = self.getvalue()[:size]
|
||||
|
||||
def write(self, s):
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
|
@ -138,11 +147,14 @@ class StringIO:
|
|||
self.buflist.append(s)
|
||||
self.len = newpos
|
||||
self.pos = newpos
|
||||
|
||||
def writelines(self, list):
|
||||
self.write(EMPTYSTRING.join(list))
|
||||
|
||||
def flush(self):
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
|
||||
def getvalue(self):
|
||||
if self.buflist:
|
||||
self.buf += EMPTYSTRING.join(self.buflist)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue