Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
tempfile.SpooledTemporaryFile Class Reference

List of all members.

Public Member Functions

def __init__
def rollover
def __enter__
def __exit__
def __iter__
def close
def closed
def encoding
def fileno
def flush
def isatty
def mode
def name
def newlines
def next
def read
def readline
def readlines
def seek
def softspace
def tell
def truncate
def write
def writelines
def xreadlines

Private Member Functions

def _check

Private Attributes

 _file
 _max_size
 _TemporaryFileArgs

Static Private Attributes

 _rolled = False

Detailed Description

Temporary file wrapper, specialized to switch from
StringIO to a real file when it exceeds a certain size or
when a fileno is needed.

Definition at line 476 of file tempfile.py.


Constructor & Destructor Documentation

def tempfile.SpooledTemporaryFile.__init__ (   self,
  max_size = 0,
  mode = 'w+b',
  buffering = -1,
  encoding = None,
  newline = None,
  suffix = "",
  prefix = template,
  dir = None 
)

Definition at line 485 of file tempfile.py.

00485 
00486                  suffix="", prefix=template, dir=None):
00487         if 'b' in mode:
00488             self._file = _io.BytesIO()
00489         else:
00490             # Setting newline="\n" avoids newline translation;
00491             # this is important because otherwise on Windows we'd
00492             # hget double newline translation upon rollover().
00493             self._file = _io.StringIO(newline="\n")
00494         self._max_size = max_size
00495         self._rolled = False
00496         self._TemporaryFileArgs = {'mode': mode, 'buffering': buffering,
00497                                    'suffix': suffix, 'prefix': prefix,
00498                                    'encoding': encoding, 'newline': newline,
00499                                    'dir': dir}

Here is the caller graph for this function:


Member Function Documentation

Definition at line 523 of file tempfile.py.

00523 
00524     def __enter__(self):
00525         if self._file.closed:
00526             raise ValueError("Cannot enter context with closed file")
00527         return self

def tempfile.SpooledTemporaryFile.__exit__ (   self,
  exc,
  value,
  tb 
)

Definition at line 528 of file tempfile.py.

00528 
00529     def __exit__(self, exc, value, tb):
00530         self._file.close()

Here is the caller graph for this function:

Definition at line 532 of file tempfile.py.

00532 
00533     def __iter__(self):
00534         return self._file.__iter__()

def tempfile.SpooledTemporaryFile._check (   self,
  file 
) [private]

Definition at line 500 of file tempfile.py.

00500 
00501     def _check(self, file):
00502         if self._rolled: return
00503         max_size = self._max_size
00504         if max_size and file.tell() > max_size:
00505             self.rollover()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 535 of file tempfile.py.

00535 
00536     def close(self):
00537         self._file.close()

Here is the caller graph for this function:

Definition at line 539 of file tempfile.py.

00539 
00540     def closed(self):
00541         return self._file.closed

Here is the caller graph for this function:

Definition at line 543 of file tempfile.py.

00543 
00544     def encoding(self):
00545         return self._file.encoding

Here is the caller graph for this function:

Definition at line 546 of file tempfile.py.

00546 
00547     def fileno(self):
00548         self.rollover()
00549         return self._file.fileno()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 550 of file tempfile.py.

00550 
00551     def flush(self):
00552         self._file.flush()

Here is the caller graph for this function:

Definition at line 553 of file tempfile.py.

00553 
00554     def isatty(self):
00555         return self._file.isatty()

Definition at line 557 of file tempfile.py.

00557 
00558     def mode(self):
00559         return self._file.mode

Here is the caller graph for this function:

Definition at line 561 of file tempfile.py.

00561 
00562     def name(self):
00563         return self._file.name

Here is the caller graph for this function:

Definition at line 565 of file tempfile.py.

00565 
00566     def newlines(self):
00567         return self._file.newlines

Definition at line 568 of file tempfile.py.

00568 
00569     def next(self):
00570         return self._file.next

def tempfile.SpooledTemporaryFile.read (   self,
  args 
)

Definition at line 571 of file tempfile.py.

00571 
00572     def read(self, *args):
00573         return self._file.read(*args)

Here is the caller graph for this function:

def tempfile.SpooledTemporaryFile.readline (   self,
  args 
)

Definition at line 574 of file tempfile.py.

00574 
00575     def readline(self, *args):
00576         return self._file.readline(*args)

Here is the caller graph for this function:

def tempfile.SpooledTemporaryFile.readlines (   self,
  args 
)

Definition at line 577 of file tempfile.py.

00577 
00578     def readlines(self, *args):
00579         return self._file.readlines(*args)

Definition at line 506 of file tempfile.py.

00506 
00507     def rollover(self):
00508         if self._rolled: return
00509         file = self._file
00510         newfile = self._file = TemporaryFile(**self._TemporaryFileArgs)
00511         del self._TemporaryFileArgs
00512 
00513         newfile.write(file.getvalue())
00514         newfile.seek(file.tell(), 0)
00515 
00516         self._rolled = True

Here is the caller graph for this function:

def tempfile.SpooledTemporaryFile.seek (   self,
  args 
)

Definition at line 580 of file tempfile.py.

00580 
00581     def seek(self, *args):
00582         self._file.seek(*args)

Here is the caller graph for this function:

Definition at line 584 of file tempfile.py.

00584 
00585     def softspace(self):
00586         return self._file.softspace

Definition at line 587 of file tempfile.py.

00587 
00588     def tell(self):
00589         return self._file.tell()

Definition at line 590 of file tempfile.py.

00590 
00591     def truncate(self):
00592         self._file.truncate()

def tempfile.SpooledTemporaryFile.write (   self,
  s 
)

Definition at line 593 of file tempfile.py.

00593 
00594     def write(self, s):
00595         file = self._file
00596         rv = file.write(s)
00597         self._check(file)
00598         return rv

Here is the call graph for this function:

def tempfile.SpooledTemporaryFile.writelines (   self,
  iterable 
)

Definition at line 599 of file tempfile.py.

00599 
00600     def writelines(self, iterable):
00601         file = self._file
00602         rv = file.writelines(iterable)
00603         self._check(file)
00604         return rv

Here is the call graph for this function:

def tempfile.SpooledTemporaryFile.xreadlines (   self,
  args 
)

Definition at line 605 of file tempfile.py.

00605 
00606     def xreadlines(self, *args):
00607         return self._file.xreadlines(*args)
00608 


Member Data Documentation

Definition at line 487 of file tempfile.py.

Definition at line 493 of file tempfile.py.

tempfile.SpooledTemporaryFile._rolled = False [static, private]

Definition at line 481 of file tempfile.py.

Definition at line 495 of file tempfile.py.


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