Orbits  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
Public Member Functions | Public Attributes | Static Public Attributes | Static Private Member Functions | List of all members
pkg_resources.ResourceManager Class Reference

Public Member Functions

def __init__
 
def resource_exists
 
def resource_isdir
 
def resource_filename
 
def resource_stream
 
def resource_string
 
def resource_listdir
 
def extraction_error
 
def get_cache_path
 
def postprocess
 
def set_extraction_path
 
def cleanup_resources
 

Public Attributes

 cached_files
 

Static Public Attributes

 extraction_path = None
 

Static Private Member Functions

def _warn_unsafe_extraction_path
 

Detailed Description

Manage resource extraction and packages

Constructor & Destructor Documentation

def pkg_resources.ResourceManager.__init__ (   self)

Member Function Documentation

def pkg_resources.ResourceManager._warn_unsafe_extraction_path (   path)
staticprivate
If the default extraction path is overridden and set to an insecure
location, such as /tmp, it opens up an opportunity for an attacker to
replace an extracted file with an unauthorized payload. Warn the user
if a known insecure location is used.

See Distribute #375 for more details.
def pkg_resources.ResourceManager.cleanup_resources (   self,
  force = False 
)
Delete all extracted resource files and directories, returning a list
of the file and directory names that could not be successfully removed.
This function does not have any concurrency protection, so it should
generally only be called when the extraction path is a temporary
directory exclusive to a single process.  This method is not
automatically called; you must call it explicitly or register it as an
``atexit`` function if you wish to ensure cleanup of a temporary
directory used for extractions.
def pkg_resources.ResourceManager.extraction_error (   self)
Give an error message for problems extracting file(s)
def pkg_resources.ResourceManager.get_cache_path (   self,
  archive_name,
  names = () 
)
Return absolute location in cache for `archive_name` and `names`

The parent directory of the resulting path will be created if it does
not already exist.  `archive_name` should be the base filename of the
enclosing egg (which may not be the name of the enclosing zipfile!),
including its ".egg" extension.  `names`, if provided, should be a
sequence of path name parts "under" the egg's extraction location.

This method should only be called by resource providers that need to
obtain an extraction location, and only for names they intend to
extract, as it tracks the generated names for possible cleanup later.
def pkg_resources.ResourceManager.postprocess (   self,
  tempname,
  filename 
)
Perform any platform-specific postprocessing of `tempname`

This is where Mac header rewrites should be done; other platforms don't
have anything special they should do.

Resource providers should call this method ONLY after successfully
extracting a compressed resource.  They must NOT call it on resources
that are already in the filesystem.

`tempname` is the current (temporary) name of the file, and `filename`
is the name it will be renamed to by the caller after this routine
returns.
def pkg_resources.ResourceManager.resource_exists (   self,
  package_or_requirement,
  resource_name 
)
Does the named resource exist?
def pkg_resources.ResourceManager.resource_filename (   self,
  package_or_requirement,
  resource_name 
)
Return a true filesystem path for specified resource
def pkg_resources.ResourceManager.resource_isdir (   self,
  package_or_requirement,
  resource_name 
)
Is the named resource an existing directory?
def pkg_resources.ResourceManager.resource_listdir (   self,
  package_or_requirement,
  resource_name 
)
List the contents of the named resource directory
def pkg_resources.ResourceManager.resource_stream (   self,
  package_or_requirement,
  resource_name 
)
Return a readable file-like object for specified resource
def pkg_resources.ResourceManager.resource_string (   self,
  package_or_requirement,
  resource_name 
)
Return specified resource as a string
def pkg_resources.ResourceManager.set_extraction_path (   self,
  path 
)
Set the base path where resources will be extracted to, if needed.

If you do not call this routine before any extractions take place, the
path defaults to the return value of ``get_default_cache()``.  (Which
is based on the ``PYTHON_EGG_CACHE`` environment variable, with various
platform-specific fallbacks.  See that routine's documentation for more
details.)

Resources are extracted to subdirectories of this path based upon
information given by the ``IResourceProvider``.  You may set this to a
temporary directory, but then you must call ``cleanup_resources()`` to
delete the extracted files when done.  There is no guarantee that
``cleanup_resources()`` will be able to remove all extracted files.

(Note: you may not change the extraction path for a given resource
manager once resources have been extracted, unless you first call
``cleanup_resources()``.)

Member Data Documentation

pkg_resources.ResourceManager.cached_files
pkg_resources.ResourceManager.extraction_path = None
static
Set the base path where resources will be extracted to, if needed.

If you do not call this routine before any extractions take place, the
path defaults to the return value of ``get_default_cache()``.  (Which
is based on the ``PYTHON_EGG_CACHE`` environment variable, with various
platform-specific fallbacks.  See that routine's documentation for more
details.)

Resources are extracted to subdirectories of this path based upon
information given by the ``IResourceProvider``.  You may set this to a
temporary directory, but then you must call ``cleanup_resources()`` to
delete the extracted files when done.  There is no guarantee that
``cleanup_resources()`` will be able to remove all extracted files.

(Note: you may not change the extraction path for a given resource
manager once resources have been extracted, unless you first call
``cleanup_resources()``.)

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

Copyright 2014 Google Inc. All rights reserved.