Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
tarfile.TarIter Class Reference

List of all members.

Public Member Functions

def __init__
def __iter__
def __next__

Public Attributes

 tarfile
 index

Detailed Description

Iterator Class.

   for tarinfo in TarFile(...):
       suite...

Definition at line 2550 of file tarfile.py.


Constructor & Destructor Documentation

def tarfile.TarIter.__init__ (   self,
  tarfile 
)
Construct a TarIter object.

Definition at line 2557 of file tarfile.py.

02557 
02558     def __init__(self, tarfile):
02559         """Construct a TarIter object.
02560         """
02561         self.tarfile = tarfile
        self.index = 0

Here is the caller graph for this function:


Member Function Documentation

def tarfile.TarIter.__iter__ (   self)
Return iterator object.

Definition at line 2562 of file tarfile.py.

02562 
02563     def __iter__(self):
02564         """Return iterator object.
02565         """
        return self
def tarfile.TarIter.__next__ (   self)
Return the next item using TarFile's next() method.
   When all members have been read, set TarFile as _loaded.

Definition at line 2566 of file tarfile.py.

02566 
02567     def __next__(self):
02568         """Return the next item using TarFile's next() method.
02569            When all members have been read, set TarFile as _loaded.
02570         """
02571         # Fix for SF #1100429: Under rare circumstances it can
02572         # happen that getmembers() is called during iteration,
02573         # which will cause TarIter to stop prematurely.
02574         if not self.tarfile._loaded:
02575             tarinfo = self.tarfile.next()
02576             if not tarinfo:
02577                 self.tarfile._loaded = True
02578                 raise StopIteration
02579         else:
02580             try:
02581                 tarinfo = self.tarfile.members[self.index]
02582             except IndexError:
02583                 raise StopIteration
02584         self.index += 1
02585         return tarinfo
02586 
02587 #--------------------
02588 # exported functions
#--------------------

Member Data Documentation

Definition at line 2561 of file tarfile.py.

Definition at line 2560 of file tarfile.py.


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