Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
StringIO Class Reference

Public Member Functions

def __init__
 
def __iter__
 
def close
 
def isatty
 
def seek
 
def tell
 
def read
 
def readline
 
def readlines
 
def truncate
 
def write
 
def writelines
 
def flush
 
def getvalue
 

Data Fields

 buf
 
 len
 
 buflist
 
 pos
 
 closed
 
 softspace
 

Detailed Description

Definition at line 39 of file StringIO.py.

Constructor & Destructor Documentation

def __init__ (   self,
  buf = '' 
)

Definition at line 40 of file StringIO.py.

References locale.str().

40 
41  def __init__(self, buf = ''):
42  # Force self.buf to be a string or unicode
43  if type(buf) not in types.StringTypes:
44  buf = str(buf)
45  self.buf = buf
46  self.len = len(buf)
47  self.buflist = []
48  self.pos = 0
49  self.closed = 0
50  self.softspace = 0

Member Function Documentation

def __iter__ (   self)
def close (   self)

Definition at line 54 of file StringIO.py.

References StringIO.buf, _SpoofOut.buf, StringIO.closed, Chunk.closed, _Subfile.pos, StringIO.pos, MatchObject.pos, and AddrlistClass.pos.

54 
55  def close(self):
56  if not self.closed:
57  self.closed = 1
58  del self.buf, self.pos
def flush (   self)

Definition at line 163 of file StringIO.py.

References StringIO.closed, and Chunk.closed.

164  def flush(self):
165  if self.closed:
166  raise ValueError, "I/O operation on closed file"
def getvalue (   self)

Definition at line 167 of file StringIO.py.

References StringIO.buf, _SpoofOut.buf, StringIO.buflist, and dospath.join().

168  def getvalue(self):
169  if self.buflist:
170  self.buf += ''.join(self.buflist)
171  self.buflist = []
172  return self.buf
173 
174 
175 # A little test suite
def isatty (   self)

Definition at line 59 of file StringIO.py.

References StringIO.closed, and Chunk.closed.

59 
60  def isatty(self):
61  if self.closed:
62  raise ValueError, "I/O operation on closed file"
63  return 0
def read (   self,
  n = -1 
)

Definition at line 81 of file StringIO.py.

References StringIO.buf, _SpoofOut.buf, StringIO.buflist, StringIO.closed, Chunk.closed, dospath.join(), StringIO.len, sre_parse.min, _Subfile.pos, StringIO.pos, MatchObject.pos, and AddrlistClass.pos.

81 
82  def read(self, n = -1):
83  if self.closed:
84  raise ValueError, "I/O operation on closed file"
85  if self.buflist:
86  self.buf += ''.join(self.buflist)
87  self.buflist = []
88  if n < 0:
89  newpos = self.len
90  else:
91  newpos = min(self.pos+n, self.len)
92  r = self.buf[self.pos:newpos]
93  self.pos = newpos
94  return r
def readline (   self,
  length = None 
)

Definition at line 95 of file StringIO.py.

References StringIO.buf, _SpoofOut.buf, StringIO.buflist, StringIO.closed, Chunk.closed, dospath.join(), StringIO.len, _Subfile.pos, StringIO.pos, MatchObject.pos, and AddrlistClass.pos.

95 
96  def readline(self, length=None):
97  if self.closed:
98  raise ValueError, "I/O operation on closed file"
99  if self.buflist:
100  self.buf += ''.join(self.buflist)
101  self.buflist = []
102  i = self.buf.find('\n', self.pos)
103  if i < 0:
104  newpos = self.len
105  else:
106  newpos = i+1
107  if length is not None:
108  if self.pos + length < newpos:
109  newpos = self.pos + length
110  r = self.buf[self.pos:newpos]
111  self.pos = newpos
112  return r
def readlines (   self,
  sizehint = 0 
)

Definition at line 113 of file StringIO.py.

References StringIO.len, _Subfile.readline(), MultiFile.readline(), StringIO.readline(), SSLFakeFile.readline(), FileInput.readline(), StreamReader.readline(), _fileobject.readline(), GzipFile.readline(), StreamReaderWriter.readline(), StreamRecoder.readline(), ListReader.readline(), Unpickler.readline, and addbase.readline.

114  def readlines(self, sizehint = 0):
115  total = 0
116  lines = []
117  line = self.readline()
118  while line:
119  lines.append(line)
120  total += len(line)
121  if 0 < sizehint <= total:
122  break
123  line = self.readline()
124  return lines
def seek (   self,
  pos,
  mode = 0 
)

Definition at line 64 of file StringIO.py.

References StringIO.buf, _SpoofOut.buf, StringIO.buflist, StringIO.closed, Chunk.closed, dospath.join(), StringIO.len, sre_parse.max, _Subfile.pos, StringIO.pos, MatchObject.pos, and AddrlistClass.pos.

64 
65  def seek(self, pos, mode = 0):
66  if self.closed:
67  raise ValueError, "I/O operation on closed file"
68  if self.buflist:
69  self.buf += ''.join(self.buflist)
70  self.buflist = []
71  if mode == 1:
72  pos += self.pos
73  elif mode == 2:
74  pos += self.len
75  self.pos = max(0, pos)
def tell (   self)

Definition at line 76 of file StringIO.py.

References StringIO.closed, Chunk.closed, _Subfile.pos, StringIO.pos, MatchObject.pos, and AddrlistClass.pos.

76 
77  def tell(self):
78  if self.closed:
79  raise ValueError, "I/O operation on closed file"
80  return self.pos
def truncate (   self,
  size = None 
)

Definition at line 125 of file StringIO.py.

References StringIO.buf, _SpoofOut.buf, StringIO.closed, Chunk.closed, StringIO.getvalue(), FieldStorage.getvalue(), _Subfile.pos, StringIO.pos, MatchObject.pos, and AddrlistClass.pos.

126  def truncate(self, size=None):
127  if self.closed:
128  raise ValueError, "I/O operation on closed file"
129  if size is None:
130  size = self.pos
131  elif size < 0:
132  raise IOError(EINVAL, "Negative size not allowed")
133  elif size < self.pos:
134  self.pos = size
135  self.buf = self.getvalue()[:size]
def write (   self,
  s 
)

Definition at line 136 of file StringIO.py.

References StringIO.buf, _SpoofOut.buf, StringIO.buflist, StringIO.closed, Chunk.closed, dospath.join(), StringIO.len, _Subfile.pos, StringIO.pos, MatchObject.pos, AddrlistClass.pos, and locale.str().

137  def write(self, s):
138  if self.closed:
139  raise ValueError, "I/O operation on closed file"
140  if not s: return
141  # Force s to be a string or unicode
142  if type(s) not in types.StringTypes:
143  s = str(s)
144  if self.pos > self.len:
145  self.buflist.append('\0'*(self.pos - self.len))
146  self.len = self.pos
147  newpos = self.pos + len(s)
148  if self.pos < self.len:
149  if self.buflist:
150  self.buf += ''.join(self.buflist)
151  self.buflist = []
152  self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]]
153  self.buf = ''
154  if newpos > self.len:
155  self.len = newpos
156  else:
157  self.buflist.append(s)
158  self.len = newpos
159  self.pos = newpos
def writelines (   self,
  list 
)

Definition at line 160 of file StringIO.py.

References dospath.join(), Devnull.write(), Pickler.write, openrsrc.write(), _Hqxcoderengine.write(), StreamWriter.write(), GzipFile.write(), StringIO.write(), _Rlecoderengine.write(), InteractiveInterpreter.write(), _fileobject.write(), BinHex.write(), StreamReaderWriter.write(), ConfigParser.write(), _SpoofOut.write(), StreamRecoder.write(), Marshaller.write, and file_wrapper.write.

161  def writelines(self, list):
162  self.write(''.join(list))

Field Documentation

buf

Definition at line 44 of file StringIO.py.

buflist

Definition at line 46 of file StringIO.py.

closed

Definition at line 48 of file StringIO.py.

len

Definition at line 45 of file StringIO.py.

pos

Definition at line 47 of file StringIO.py.

softspace

Definition at line 49 of file StringIO.py.


The documentation for this class was generated from the following file: