Back to index

enigmail  1.4.3
Public Member Functions | Private Member Functions | Private Attributes
build.automationutils.ZipFileReader Class Reference

List of all members.

Public Member Functions

def __init__
def __del__
def namelist
def read
def extract
def extractall

Private Member Functions

def _getnormalizedpath
def _extractname

Private Attributes

 _zipfile

Detailed Description

Class to read zip files in Python 2.5 and later. Limited to only what we
actually use.

Definition at line 77 of file automationutils.py.


Constructor & Destructor Documentation

def build.automationutils.ZipFileReader.__init__ (   self,
  filename 
)

Definition at line 83 of file automationutils.py.

00083 
00084   def __init__(self, filename):
00085     self._zipfile = zipfile.ZipFile(filename, "r")

Definition at line 86 of file automationutils.py.

00086 
00087   def __del__(self):
00088     self._zipfile.close()


Member Function Documentation

def build.automationutils.ZipFileReader._extractname (   self,
  name,
  path 
) [private]
Extracts a file with the given name from the zip file to the given path.
Also creates any directories needed along the way.

Definition at line 100 of file automationutils.py.

00100 
00101   def _extractname(self, name, path):
00102     """
00103     Extracts a file with the given name from the zip file to the given path.
00104     Also creates any directories needed along the way.
00105     """
00106     filename = os.path.normpath(os.path.join(path, name))
00107     if name.endswith("/"):
00108       os.makedirs(filename)
00109     else:
00110       path = os.path.split(filename)[0]
00111       if not os.path.isdir(path):
00112         os.makedirs(path)
00113       with open(filename, "wb") as dest:
00114         dest.write(self._zipfile.read(name))

Here is the caller graph for this function:

def build.automationutils.ZipFileReader._getnormalizedpath (   self,
  path 
) [private]
Gets a normalized path from 'path' (or the current working directory if
'path' is None). Also asserts that the path exists.

Definition at line 89 of file automationutils.py.

00089 
00090   def _getnormalizedpath(self, path):
00091     """
00092     Gets a normalized path from 'path' (or the current working directory if
00093     'path' is None). Also asserts that the path exists.
00094     """
00095     if path is None:
00096       path = os.curdir
00097     path = os.path.normpath(os.path.expanduser(path))
00098     assert os.path.isdir(path)
00099     return path

Here is the caller graph for this function:

def build.automationutils.ZipFileReader.extract (   self,
  name,
  path = None 
)

Definition at line 121 of file automationutils.py.

00121 
00122   def extract(self, name, path = None):
00123     if hasattr(self._zipfile, "extract"):
00124       return self._zipfile.extract(name, path)
00125 
00126     # This will throw if name is not part of the zip file.
00127     self._zipfile.getinfo(name)
00128 
00129     self._extractname(name, self._getnormalizedpath(path))

Here is the call graph for this function:

def build.automationutils.ZipFileReader.extractall (   self,
  path = None 
)

Definition at line 130 of file automationutils.py.

00130 
00131   def extractall(self, path = None):
00132     if hasattr(self._zipfile, "extractall"):
00133       return self._zipfile.extractall(path)
00134 
00135     path = self._getnormalizedpath(path)
00136 
00137     for name in self._zipfile.namelist():
00138       self._extractname(name, path)

Here is the call graph for this function:

Definition at line 115 of file automationutils.py.

00115 
00116   def namelist(self):
00117     return self._zipfile.namelist()

def build.automationutils.ZipFileReader.read (   self,
  name 
)

Definition at line 118 of file automationutils.py.

00118 
00119   def read(self, name):
00120     return self._zipfile.read(name)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 84 of file automationutils.py.


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