The PEAK Developers' Center   PythonEggs UserPreferences
 
HelpContents Search Diffs Info Edit Subscribe XML Print View
Version as of 2005-01-28 18:40:12

Clear message


Distribution Format

(Just notes so far)

Package Resource API

The following API routines will be available in the package_resources module as module-level functions, and as methods of the ResourceManager class. An application may create its own ResourceManager instance(s), or use the default global instance by calling the module-level versions of these routines.

iter_distributions(name=None,path=None)
Searching the list of locations specified by path, yield Distribution instances whose names match name. If name is None, all recognized distributions are yielded. If path is None, the resource manager's default path is searched. If the resource manager has no default path, sys.path is searched. Distribution objects yielded by this routine may be added to sys.metapath in order to make them accessible for importing, as they are PEP 302-compatible "importer" objects.
resource_string(package_name,resource_name)
Return the named resource as a binary string.
resource_stream(package_name,resource_name,mode='b')
Open the named resource as a file-like object, using the specified mode ('t', 'b', or 'U'). (Note that this does not necessarily return an actual file; if you need a fileno() or an actual operating system file, you should use resource_filename() instead.)
resource_filename(package_name,resource_name)
Return a platform file or directory name for the named resource. If the package is in an egg distribution, the resource will be unpacked before the filename is returned. If the named resource is a directory, the entire directory's contents will be extracted before the directory name is returned. Also, if the named resource is an "eager" resource such as a Python extension or shared library, then all "eager" resources will be extracted before the resource's filename is returned. (This is to ensure that shared libraries that link to other included libraries will have their dependencies available before loading.)
set_extraction_path(path)
Set the base path where resources will be extracted to. If not set, this defaults to os.expanduser("~/.python-eggs"). Resources are extracted to subdirectories of this path, named for the corresponding .egg file. You may set this to a temporary directory, but then you must call cleanup_resources() to delete the extracted files when done. (Note: you may not change the extraction path for a given resource manager once resources have been extracted, unless you first call cleanup_resources().)
cleanup_resources(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.
ResourceManager(search_path=None, extract_to=None)
Create a resource manager instance, using search_path as its default search path for iter_distributions() and extract_to as its initial set_extraction_path().

Distribution Objects

These need name, version, python version, absolute path, and a metadata API, as well as PEP 302 "importer" methods.


PythonPowered
EditText of this page (last modified 2005-01-28 18:40:12)
FindPage by browsing, title search , text search or an index
Or try one of these actions: AttachFile, DeletePage, LikePages, LocalSiteMap, SpellCheck