Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
GenericSetup.context.TarballImportContext Class Reference
Inheritance diagram for GenericSetup.context.TarballImportContext:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.context.TarballImportContext:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def readDataFile
def getLastModified
def isDirectory
def listDirectory
def shouldPurge
def getSite
def getSetupTool
def getEncoding
def getLogger
def listNotes
def clearNotes

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _getTarInfo

Private Attributes

 _archive_stream
 _archive
 _should_purge

Detailed Description

Definition at line 301 of file context.py.


Constructor & Destructor Documentation

def GenericSetup.context.TarballImportContext.__init__ (   self,
  tool,
  archive_bits,
  encoding = None,
  should_purge = False 
)

Definition at line 308 of file context.py.

00308 
00309                   should_purge=False ):
00310         BaseContext.__init__( self, tool, encoding )
00311         timestamp = time.gmtime()
00312         self._archive_stream = StringIO(archive_bits)
00313         self._archive = TarFile.open( 'foo.bar', 'r:gz'
00314                                     , self._archive_stream )
00315         self._should_purge = bool( should_purge )


Member Function Documentation

def GenericSetup.context.TarballImportContext._getTarInfo (   self,
  path 
) [private]

Definition at line 381 of file context.py.

00381 
00382     def _getTarInfo( self, path ):
00383         if path[-1] == '/':
00384             path = path[:-1]
00385         try:
00386             return self._archive.getmember( path )
00387         except KeyError:
00388             pass
00389         try:
00390             return self._archive.getmember( path + '/' )
00391         except KeyError:
00392             return None
00393 

Here is the caller graph for this function:

def GenericSetup.context.BaseContext.clearNotes (   self) [inherited]
See ISetupContext.

Definition at line 172 of file context.py.

00172 
00173     def clearNotes(self):
00174 
00175         """ See ISetupContext.
00176         """
00177         self._messages[:] = []
00178 

See ISetupContext.

Definition at line 152 of file context.py.

00152 
00153     def getEncoding( self ):
00154 
00155         """ See ISetupContext.
00156         """
00157         return self._encoding

Here is the caller graph for this function:

See IImportContext.

Definition at line 330 of file context.py.

00330 
00331     def getLastModified( self, path ):
00332 
00333         """ See IImportContext.
00334         """
00335         info = self._getTarInfo( path )
00336         return info and info.mtime or None

Here is the call graph for this function:

def GenericSetup.context.BaseContext.getLogger (   self,
  name 
) [inherited]
See ISetupContext.

Reimplemented from GenericSetup.context.SetupEnviron.

Definition at line 159 of file context.py.

00159 
00160     def getLogger( self, name ):
00161         """ See ISetupContext.
00162         """
00163         return self._loggers.setdefault(name, Logger(name, self._messages))

See ISetupContext.

Definition at line 145 of file context.py.

00145 
00146     def getSetupTool( self ):
00147 
00148         """ See ISetupContext.
00149         """
00150         return self._tool

def GenericSetup.context.BaseContext.getSite (   self) [inherited]
See ISetupContext.

Definition at line 138 of file context.py.

00138 
00139     def getSite( self ):
00140 
00141         """ See ISetupContext.
00142         """
00143         return aq_self(self._site)

See IImportContext.

Definition at line 337 of file context.py.

00337 
00338     def isDirectory( self, path ):
00339 
00340         """ See IImportContext.
00341         """
00342         info = self._getTarInfo( path )
00343 
00344         if info is not None:
00345             return info.isdir()

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.context.TarballImportContext.listDirectory (   self,
  path,
  skip = SKIPPED_FILES,
  skip_suffixes = SKIPPED_SUFFIXES 
)
See IImportContext.

Definition at line 347 of file context.py.

00347 
00348                       skip_suffixes=SKIPPED_SUFFIXES):
00349 
00350         """ See IImportContext.
00351         """
00352         if path is None:  # root is special case:  no leading '/'
00353             path = ''
00354         else:
00355             if not self.isDirectory(path):
00356                 return None
00357 
00358             if path[-1] != '/':
00359                 path = path + '/'
00360 
00361         pfx_len = len(path)
00362 
00363         names = []
00364         for name in self._archive.getnames():
00365             if name == path or not name.startswith(path):
00366                 continue
00367             name = name[pfx_len:]
00368             if '/' in name or name in skip:
00369                 continue
00370             if [s for s in skip_suffixes if name.endswith(s)]:
00371                 continue
00372             names.append(name)
00373 
00374         return names

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.context.BaseContext.listNotes (   self) [inherited]
See ISetupContext.

Definition at line 165 of file context.py.

00165 
00166     def listNotes(self):
00167 
00168         """ See ISetupContext.
00169         """
00170         return self._messages[:]

def GenericSetup.context.TarballImportContext.readDataFile (   self,
  filename,
  subdir = None 
)
See IImportContext.

Definition at line 316 of file context.py.

00316 
00317     def readDataFile( self, filename, subdir=None ):
00318 
00319         """ See IImportContext.
00320         """
00321         if subdir is not None:
00322             filename = '/'.join( ( subdir, filename ) )
00323 
00324         try:
00325             file = self._archive.extractfile( filename )
00326         except KeyError:
00327             return None
00328 
00329         return file.read()

See IImportContext.

Reimplemented from GenericSetup.context.SetupEnviron.

Definition at line 375 of file context.py.

00375 
00376     def shouldPurge( self ):
00377 
00378         """ See IImportContext.
00379         """
00380         return self._should_purge


Member Data Documentation

Definition at line 312 of file context.py.

Definition at line 311 of file context.py.

Reimplemented from GenericSetup.context.BaseContext.

Definition at line 314 of file context.py.

tuple GenericSetup.context.TarballImportContext.security = ClassSecurityInfo() [static]

Reimplemented from GenericSetup.context.BaseContext.

Definition at line 305 of file context.py.


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