Orbits  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
Classes | Functions | Variables
pkg_resources Namespace Reference

Classes

class  ResolutionError
 
class  VersionConflict
 
class  DistributionNotFound
 
class  UnknownExtra
 
class  IMetadataProvider
 
class  IResourceProvider
 
class  WorkingSet
 
class  Environment
 
class  ExtractionError
 
class  ResourceManager
 
class  MarkerEvaluation
 
class  NullProvider
 
class  EggProvider
 
class  DefaultProvider
 
class  EmptyProvider
 
class  ZipProvider
 
class  FileMetadata
 
class  PathMetadata
 
class  EggMetadata
 
class  EntryPoint
 
class  Distribution
 
class  DistInfoDistribution
 
class  Requirement
 

Functions

def execfile
 
def _bypass_ensure_directory
 
def _declare_state
 
def __getstate__
 
def __setstate__
 
def _sget_dict
 
def _sset_dict
 
def _sget_object
 
def _sset_object
 
def get_supported_platform
 
def register_loader_type
 
def get_provider
 
def _macosx_vers
 
def _macosx_arch
 
def get_build_platform
 
def compatible_platforms
 
def run_script
 
def get_distribution
 
def load_entry_point
 
def get_entry_map
 
def get_entry_info
 
def get_default_cache
 
def safe_name
 
def safe_version
 
def safe_extra
 
def to_filename
 
def build_zipmanifest
 
def register_finder
 
def find_distributions
 
def find_eggs_in_zip
 
def find_nothing
 
def find_on_path
 
def register_namespace_handler
 
def _handle_ns
 
def declare_namespace
 
def fixup_namespace_packages
 
def file_ns_handler
 
def null_ns_handler
 
def normalize_path
 
def _normalize_cached
 
def _set_parent_ns
 
def yield_lines
 
def _parse_version_parts
 
def parse_version
 
def _remove_md5_fragment
 
def issue_warning
 
def parse_requirements
 
def _get_mro
 
def _find_adapter
 
def ensure_directory
 
def split_sections
 
def _mkstemp
 
def _initialize
 

Variables

tuple next = lambdao:o.next()
 
 basestring = str
 
 WRITE_SUPPORT = True
 
 importlib_bootstrap = None
 
dictionary _state_vars = {}
 
 _sget_none = lambda*args:None
 
list __all__
 
dictionary _provider_factories = {}
 
list PY_MAJOR = sys.version[:3]
 
int EGG_DIST = 3
 
int BINARY_DIST = 2
 
int SOURCE_DIST = 1
 
int CHECKOUT_DIST = 0
 
int DEVELOP_DIST = -1
 
tuple macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)")
 
tuple darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
 
 get_platform = get_build_platform
 
 run_main = run_script
 
 AvailableDistributions = Environment
 
 invalid_marker = MarkerEvaluation.is_invalid_marker
 
 evaluate_marker = MarkerEvaluation.evaluate_marker
 
tuple empty_provider = EmptyProvider()
 
tuple LINE_END = re.compile(r"\s*(#.*)?$")
 
tuple CONTINUE = re.compile(r"\s*\\\s*(#.*)?$")
 
tuple DISTRO = re.compile(r"\s*((\w|[-.])+)")
 
tuple VERSION = re.compile(r"\s*(<=?|>=?|==|!=)\s*((\w|[-.])+)")
 
tuple COMMA = re.compile(r"\s*,")
 
tuple OBRACKET = re.compile(r"\s*\[")
 
tuple CBRACKET = re.compile(r"\s*\]")
 
tuple MODULE = re.compile(r"\w+(\.\w+)*$")
 
tuple EGG_NAME
 
tuple component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE)
 
dictionary replace = {'pre':'c', 'preview':'c','-':'final-','rc':'c','dev':'@'}
 
dictionary _distributionImpl
 
dictionary state_machine
 
tuple _manager = ResourceManager()
 
tuple working_set = WorkingSet._build_master()
 
 require = working_set.require
 
 iter_entry_points = working_set.iter_entry_points
 
 add_activation_listener = working_set.subscribe
 
 run_script = working_set.run_script
 

Detailed Description

Package resource API
--------------------

A resource is a logical file contained within a package, or a logical
subdirectory thereof.  The package resource API expects resource names
to have their path parts separated with ``/``, *not* whatever the local
path separator is.  Do not use os.path operations to manipulate resource
names being passed into the API.

The package resource API is designed to work with normal filesystem packages,
.egg files, and unpacked .egg files.  It can also work in a limited way with
.zip files and with custom PEP 302 loaders that support the ``get_data()``
method.

Function Documentation

def pkg_resources.__getstate__ ( )
def pkg_resources.__setstate__ (   state)
def pkg_resources._bypass_ensure_directory (   name,
  mode = 0o777 
)
private
def pkg_resources._declare_state (   vartype,
  kw 
)
private
def pkg_resources._find_adapter (   registry,
  ob 
)
private
Return an adapter factory for `ob` from `registry`
def pkg_resources._get_mro (   cls)
private
Get an mro for a type or classic class
def pkg_resources._handle_ns (   packageName,
  path_item 
)
private
Ensure that named package includes a subpath of path_item (if needed)
def pkg_resources._initialize (   g)
private
def pkg_resources._macosx_arch (   machine)
private
def pkg_resources._macosx_vers (   _cache = [])
private
def pkg_resources._mkstemp (   args,
  kw 
)
private
def pkg_resources._normalize_cached (   filename,
  _cache = {} 
)
private
def pkg_resources._parse_version_parts (   s)
private
def pkg_resources._remove_md5_fragment (   location)
private
def pkg_resources._set_parent_ns (   packageName)
private
def pkg_resources._sget_dict (   val)
private
def pkg_resources._sget_object (   val)
private
def pkg_resources._sset_dict (   key,
  ob,
  state 
)
private
def pkg_resources._sset_object (   key,
  ob,
  state 
)
private
def pkg_resources.build_zipmanifest (   path)
This builds a similar dictionary to the zipimport directory
caches.  However instead of tuples, ZipInfo objects are stored.

The translation of the tuple is as follows:
  * [0] - zipinfo.filename on stock pythons this needs "/" --> os.sep
          on pypy it is the same (one reason why distribute did work
          in some cases on pypy and win32).
  * [1] - zipinfo.compress_type
  * [2] - zipinfo.compress_size
  * [3] - zipinfo.file_size
  * [4] - len(utf-8 encoding of filename) if zipinfo & 0x800
          len(ascii encoding of filename) otherwise
  * [5] - (zipinfo.date_time[0] - 1980) << 9 |
           zipinfo.date_time[1] << 5 | zipinfo.date_time[2]
  * [6] - (zipinfo.date_time[3] - 1980) << 11 |
           zipinfo.date_time[4] << 5 | (zipinfo.date_time[5] // 2)
  * [7] - zipinfo.CRC
def pkg_resources.compatible_platforms (   provided,
  required 
)
Can code for the `provided` platform run on the `required` platform?

Returns true if either platform is ``None``, or the platforms are equal.

XXX Needs compatibility checks for Linux and other unixy OSes.
def pkg_resources.declare_namespace (   packageName)
Declare that package 'packageName' is a namespace package
def pkg_resources.ensure_directory (   path)
Ensure that the parent directory of `path` exists
def pkg_resources.execfile (   fn,
  globs = None,
  locs = None 
)
def pkg_resources.file_ns_handler (   importer,
  path_item,
  packageName,
  module 
)
Compute an ns-package subpath for a filesystem or zipfile importer
def pkg_resources.find_distributions (   path_item,
  only = False 
)
Yield distributions accessible via `path_item`
def pkg_resources.find_eggs_in_zip (   importer,
  path_item,
  only = False 
)
Find eggs in zip files; possibly multiple nested eggs.
def pkg_resources.find_nothing (   importer,
  path_item,
  only = False 
)
def pkg_resources.find_on_path (   importer,
  path_item,
  only = False 
)
Yield distributions accessible on a sys.path directory
def pkg_resources.fixup_namespace_packages (   path_item,
  parent = None 
)
Ensure that previously-declared namespace packages include path_item
def pkg_resources.get_build_platform ( )
Return this platform's string for platform-specific distributions

XXX Currently this is the same as ``distutils.util.get_platform()``, but it
needs some hacks for Linux and Mac OS X.
def pkg_resources.get_default_cache ( )
Determine the default cache location

This returns the ``PYTHON_EGG_CACHE`` environment variable, if set.
Otherwise, on Windows, it returns a "Python-Eggs" subdirectory of the
"Application Data" directory.  On all other systems, it's "~/.python-eggs".
def pkg_resources.get_distribution (   dist)
Return a current distribution object for a Requirement or string
def pkg_resources.get_entry_info (   dist,
  group,
  name 
)
Return the EntryPoint object for `group`+`name`, or ``None``
def pkg_resources.get_entry_map (   dist,
  group = None 
)
Return the entry point map for `group`, or the full entry map
def pkg_resources.get_provider (   moduleOrReq)
Return an IResourceProvider for the named module or requirement
def pkg_resources.get_supported_platform ( )
Return this platform's maximum compatible version.

distutils.util.get_platform() normally reports the minimum version
of Mac OS X that would be required to *use* extensions produced by
distutils.  But what we want when checking compatibility is to know the
version of Mac OS X that we are *running*.  To allow usage of packages that
explicitly require a newer version of Mac OS X, we must also know the
current version of the OS.

If this condition occurs for any other platform with a version in its
platform strings, this function should be extended accordingly.
def pkg_resources.issue_warning (   args,
  kw 
)
def pkg_resources.load_entry_point (   dist,
  group,
  name 
)
Return `name` entry point of `group` for `dist` or raise ImportError
def pkg_resources.normalize_path (   filename)
Normalize a file/dir name for comparison purposes
def pkg_resources.null_ns_handler (   importer,
  path_item,
  packageName,
  module 
)
def pkg_resources.parse_requirements (   strs)
Yield ``Requirement`` objects for each specification in `strs`

`strs` must be an instance of ``basestring``, or a (possibly-nested)
iterable thereof.
def pkg_resources.parse_version (   s)
Convert a version string to a chronologically-sortable key

This is a rough cross between distutils' StrictVersion and LooseVersion;
if you give it versions that would work with StrictVersion, then it behaves
the same; otherwise it acts like a slightly-smarter LooseVersion. It is
*possible* to create pathological version coding schemes that will fool
this parser, but they should be very rare in practice.

The returned value will be a tuple of strings.  Numeric portions of the
version are padded to 8 digits so they will compare numerically, but
without relying on how numbers compare relative to strings.  Dots are
dropped, but dashes are retained.  Trailing zeros between alpha segments
or dashes are suppressed, so that e.g. "2.4.0" is considered the same as
"2.4". Alphanumeric parts are lower-cased.

The algorithm assumes that strings like "-" and any alpha string that
alphabetically follows "final"  represents a "patch level".  So, "2.4-1"
is assumed to be a branch or patch of "2.4", and therefore "2.4.1" is
considered newer than "2.4-1", which in turn is newer than "2.4".

Strings like "a", "b", "c", "alpha", "beta", "candidate" and so on (that
come before "final" alphabetically) are assumed to be pre-release versions,
so that the version "2.4" is considered newer than "2.4a1".

Finally, to handle miscellaneous cases, the strings "pre", "preview", and
"rc" are treated as if they were "c", i.e. as though they were release
candidates, and therefore are not as new as a version string that does not
contain them, and "dev" is replaced with an '@' so that it sorts lower than
than any other pre-release tag.
def pkg_resources.register_finder (   importer_type,
  distribution_finder 
)
Register `distribution_finder` to find distributions in sys.path items

`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `distribution_finder` is a callable that, passed a path
item and the importer instance, yields ``Distribution`` instances found on
that path item.  See ``pkg_resources.find_on_path`` for an example.
def pkg_resources.register_loader_type (   loader_type,
  provider_factory 
)
Register `provider_factory` to make providers for `loader_type`

`loader_type` is the type or class of a PEP 302 ``module.__loader__``,
and `provider_factory` is a function that, passed a *module* object,
returns an ``IResourceProvider`` for that module.
def pkg_resources.register_namespace_handler (   importer_type,
  namespace_handler 
)
Register `namespace_handler` to declare namespace packages

`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `namespace_handler` is a callable like this::

    def namespace_handler(importer, path_entry, moduleName, module):
        # return a path_entry to use for child packages

Namespace handlers are only called if the importer object has already
agreed that it can handle the relevant path item, and they should only
return a subpath if the module __path__ does not already contain an
equivalent subpath.  For an example namespace handler, see
``pkg_resources.file_ns_handler``.
def pkg_resources.run_script (   dist_spec,
  script_name 
)
Locate distribution `dist_spec` and run its `script_name` script
def pkg_resources.safe_extra (   extra)
Convert an arbitrary string to a standard 'extra' name

Any runs of non-alphanumeric characters are replaced with a single '_',
and the result is always lowercased.
def pkg_resources.safe_name (   name)
Convert an arbitrary string to a standard distribution name

Any runs of non-alphanumeric/. characters are replaced with a single '-'.
def pkg_resources.safe_version (   version)
Convert an arbitrary string to a standard version string

Spaces become dots, and all other non-alphanumeric characters become
dashes, with runs of multiple dashes condensed to a single dash.
def pkg_resources.split_sections (   s)
Split a string or iterable thereof into (section, content) pairs

Each ``section`` is a stripped version of the section header ("[section]")
and each ``content`` is a list of stripped lines excluding blank lines and
comment-only lines.  If there are any such lines before the first section
header, they're returned in a first ``section`` of ``None``.
def pkg_resources.to_filename (   name)
Convert a project or version name to its filename-escaped form

Any '-' characters are currently replaced with '_'.
def pkg_resources.yield_lines (   strs)
Yield non-empty/non-comment lines of a ``basestring`` or sequence

Variable Documentation

list pkg_resources.__all__
dictionary pkg_resources._distributionImpl
Initial value:
1 = {
2  '.egg': Distribution,
3  '.egg-info': Distribution,
4  '.dist-info': DistInfoDistribution,
5  }
tuple pkg_resources._manager = ResourceManager()
dictionary pkg_resources._provider_factories = {}
pkg_resources._sget_none = lambda*args:None
dictionary pkg_resources._state_vars = {}
pkg_resources.add_activation_listener = working_set.subscribe
pkg_resources.AvailableDistributions = Environment
pkg_resources.basestring = str
int pkg_resources.BINARY_DIST = 2
tuple pkg_resources.CBRACKET = re.compile(r"\s*\]")
int pkg_resources.CHECKOUT_DIST = 0
tuple pkg_resources.COMMA = re.compile(r"\s*,")
tuple pkg_resources.component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE)
tuple pkg_resources.CONTINUE = re.compile(r"\s*\\\s*(#.*)?$")
tuple pkg_resources.darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
int pkg_resources.DEVELOP_DIST = -1
tuple pkg_resources.DISTRO = re.compile(r"\s*((\w|[-.])+)")
int pkg_resources.EGG_DIST = 3
tuple pkg_resources.EGG_NAME
Initial value:
2  r"(?P<name>[^-]+)"
3  r"( -(?P<ver>[^-]+) (-py(?P<pyver>[^-]+) (-(?P<plat>.+))? )? )?",
4  re.VERBOSE | re.IGNORECASE
5 )
tuple pkg_resources.empty_provider = EmptyProvider()
pkg_resources.evaluate_marker = MarkerEvaluation.evaluate_marker
pkg_resources.get_platform = get_build_platform
pkg_resources.importlib_bootstrap = None
pkg_resources.invalid_marker = MarkerEvaluation.is_invalid_marker
pkg_resources.iter_entry_points = working_set.iter_entry_points
tuple pkg_resources.LINE_END = re.compile(r"\s*(#.*)?$")
tuple pkg_resources.macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)")
tuple pkg_resources.MODULE = re.compile(r"\w+(\.\w+)*$")
tuple pkg_resources.next = lambdao:o.next()
tuple pkg_resources.OBRACKET = re.compile(r"\s*\[")
list pkg_resources.PY_MAJOR = sys.version[:3]
dictionary pkg_resources.replace = {'pre':'c', 'preview':'c','-':'final-','rc':'c','dev':'@'}
pkg_resources.require = working_set.require
pkg_resources.run_main = run_script
pkg_resources.run_script = working_set.run_script
int pkg_resources.SOURCE_DIST = 1
dictionary pkg_resources.state_machine
Initial value:
1 = {
2  # =><
3  '<': '--T',
4  '<=': 'T-T',
5  '>': 'F+F',
6  '>=': 'T+F',
7  '==': 'T..',
8  '!=': 'F++',
9 }
tuple pkg_resources.VERSION = re.compile(r"\s*(<=?|>=?|==|!=)\s*((\w|[-.])+)")
tuple pkg_resources.working_set = WorkingSet._build_master()
pkg_resources.WRITE_SUPPORT = True

Copyright 2014 Google Inc. All rights reserved.