💾 Archived View for tris.fyi › pydoc › importlib.metadata captured on 2022-03-01 at 16:08:56. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-01-08)

➡️ Next capture (2022-04-28)

🚧 View Differences

-=-=-=-=-=-=-

Back to module index

Go to module by name

importlib

importlib.metadata

This module has no docstring.

Classes

ConfigParser

ConfigParser implementing interpolation.
add_section(self, section)

  Create a new section in the configuration.  Extends
          RawConfigParser.add_section by validating if the section name is
          a string.
clear(self)

  D.clear() -> None.  Remove all items from D.
defaults(self)
get(self, section, option, *, raw=False, vars=None, fallback=<object object at 0x7f0226f9c040>)

  Get an option value for a given section.

          If `vars' is provided, it must be a dictionary. The option is looked up
          in `vars' (if provided), `section', and in `DEFAULTSECT' in that order.
          If the key is not found and `fallback' is provided, it is used as
          a fallback value. `None' can be provided as a `fallback' value.

          If interpolation is enabled and the optional argument `raw' is False,
          all interpolations are expanded in the return values.

          Arguments `raw', `vars', and `fallback' are keyword only.

          The section DEFAULT is special.
        
getboolean(self, section, option, *, raw=False, vars=None, fallback=<object object at 0x7f0226f9c040>, **kwargs)
getfloat(self, section, option, *, raw=False, vars=None, fallback=<object object at 0x7f0226f9c040>, **kwargs)
getint(self, section, option, *, raw=False, vars=None, fallback=<object object at 0x7f0226f9c040>, **kwargs)
has_option(self, section, option)

  Check for the existence of a given option in a given section.
          If the specified `section' is None or an empty string, DEFAULT is
          assumed. If the specified `section' does not exist, returns False.
has_section(self, section)

  Indicate whether the named section is present in the configuration.

          The DEFAULT section is not acknowledged.
        
items(self, section=<object object at 0x7f0226f9c040>, raw=False, vars=None)

  Return a list of (name, value) tuples for each option in a section.

          All % interpolations are expanded in the return values, based on the
          defaults passed into the constructor, unless the optional argument
          `raw' is true.  Additional substitutions may be provided using the
          `vars' argument, which must be a dictionary whose contents overrides
          any pre-existing defaults.

          The section DEFAULT is special.
        
keys(self)

  D.keys() -> a set-like object providing a view on D's keys
options(self, section)

  Return a list of option names for the given section name.
optionxform(self, optionstr)
pop(self, key, default=<object object at 0x7f0227c3c170>)

  D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
            If key is not found, d is returned if given, otherwise KeyError is raised.
        
popitem(self)

  Remove a section from the parser and return it as
          a (section_name, section_proxy) tuple. If no section is present, raise
          KeyError.

          The section DEFAULT is never returned because it cannot be removed.
        
read(self, filenames, encoding=None)

  Read and parse a filename or an iterable of filenames.

          Files that cannot be opened are silently ignored; this is
          designed so that you can specify an iterable of potential
          configuration file locations (e.g. current directory, user's
          home directory, systemwide directory), and all existing
          configuration files in the iterable will be read.  A single
          filename may also be given.

          Return list of successfully read files.
        
read_dict(self, dictionary, source='<dict>')

  Read configuration from a dictionary.

          Keys are section names, values are dictionaries with keys and values
          that should be present in the section. If the used dictionary type
          preserves order, sections and their keys will be added in order.

          All types held in the dictionary are converted to strings during
          reading, including section names, option names and keys.

          Optional second argument is the `source' specifying the name of the
          dictionary being read.
        
read_file(self, f, source=None)

  Like read() but the argument must be a file-like object.

          The `f' argument must be iterable, returning one line at a time.
          Optional second argument is the `source' specifying the name of the
          file being read. If not given, it is taken from f.name. If `f' has no
          `name' attribute, `<???>' is used.
        
read_string(self, string, source='<string>')

  Read configuration from a given string.
readfp(self, fp, filename=None)

  Deprecated, use read_file instead.
remove_option(self, section, option)

  Remove an option.
remove_section(self, section)

  Remove a file section.
sections(self)

  Return a list of section names, excluding [DEFAULT]
set(self, section, option, value=None)

  Set an option.  Extends RawConfigParser.set by validating type and
          interpolation syntax on the value.
setdefault(self, key, default=None)

  D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
update(self, other=(), /, **kwds)

   D.update([E, ]**F) -> None.  Update D from mapping/iterable E and F.
              If E present and has a .keys() method, does:     for k in E: D[k] = E[k]
              If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v
              In either case, this is followed by: for k, v in F.items(): D[k] = v
        
values(self)

  D.values() -> an object providing a view on D's values
write(self, fp, space_around_delimiters=True)

  Write an .ini-format representation of the configuration state.

          If `space_around_delimiters' is True (the default), delimiters
          between keys and values are surrounded by spaces.

          Please note that comments in the original configuration file are not
          preserved when writing the configuration back.
        
BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True, '0': False, 'no': False, 'false': False, 'off': False}
NONSPACECRE = re.compile('\\S')
OPTCRE = re.compile('\n        (?P<option>.*?)                    # very permissive!\n        \\s*(?P<vi>=|:)\\s*              # any number of space/tab,\n                                           # followed by any of t, re.VERBOSE)
OPTCRE_NV = re.compile('\n        (?P<option>.*?)                    # very permissive!\n        \\s*(?:                             # any number of space/tab,\n        (?P<vi>=|:)\\s*                 # optionally followed , re.VERBOSE)
SECTCRE = re.compile('\n        \\[                                 # [\n        (?P<header>[^]]+)                  # very permissive!\n        \\]                                 # ]\n        ', re.VERBOSE)
converters = <property object at 0x7f0226ee2b80>

Distribution

A Python distribution package.
at(path)

  Return a Distribution for the indicated metadata path

          :param path: a string or path-like object
          :return: a concrete Distribution instance for the path
        
discover(**kwargs)

  Return an iterable of Distribution objects for all packages.

          Pass a ``context`` or pass keyword arguments for constructing
          a context.

          :context: A ``DistributionFinder.Context`` object.
          :return: Iterable of Distribution objects for all packages.
        
from_name(name)

  Return the Distribution for the given package name.

          :param name: The name of the distribution package to search for.
          :return: The Distribution instance (or subclass thereof) for the named
              package, if found.
          :raises PackageNotFoundError: When the named package's distribution
              metadata cannot be found.
        
locate_file(self, path)


          Given a path to a file in this distribution, return a path
          to it.
        
read_text(self, filename)

  Attempt to load metadata file given by the name.

          :param filename: The name of the file in the distribution info.
          :return: The text if found, otherwise None.
        
entry_points = <property object at 0x7f0226ef1270>
files = <property object at 0x7f0226ef12c0>
  Files in this distribution.

          :return: List of PackagePath for this distribution or None

          Result is `None` if the metadata file that enumerates files
          (i.e. RECORD for dist-info or SOURCES.txt for egg-info) is
          missing.
          Result may be empty if the metadata exists but is empty.
        
metadata = <property object at 0x7f0226ef11d0>
  Return the parsed metadata for this Distribution.

          The returned object will have keys that name the various bits of
          metadata.  See PEP 566 for details.
        
requires = <property object at 0x7f0226ef1310>
  Generated requirements specified for this Distribution
version = <property object at 0x7f0226ef1220>
  Return the 'Version' metadata for the distribution package.

DistributionFinder


    A MetaPathFinder capable of discovering installed distributions.
    

invalidate_caches.Context


        Keyword arguments presented by the caller to
        ``distributions()`` or ``Distribution.discover()``
        to narrow the scope of a search for distributions
        in all DistributionFinders.

        Each DistributionFinder may expect any parameters
        and should attempt to honor the canonical
        parameters defined below when appropriate.
        
name = None
path = <property object at 0x7f0226ef13b0>

              The path that a distribution finder should search.

              Typically refers to Python package paths and defaults
              to ``sys.path``.
            
find_distributions(self, context=<importlib.metadata.DistributionFinder.Context object at 0x7f0226ee66d0>)


          Find distributions.

          Return an iterable of all Distribution instances capable of
          loading the metadata for packages matching the ``context``,
          a DistributionFinder.Context instance.
        
find_module(self, fullname, path)

  Return a loader for the module.

          If no module is found, return None.  The fullname is a str and
          the path is a list of strings or None.

          This method is deprecated since Python 3.4 in favor of
          finder.find_spec(). If find_spec() exists then backwards-compatible
          functionality is provided for this method.

        
invalidate_caches(self)

  An optional method for clearing the finder's cache, if any.
          This method is used by importlib.invalidate_caches().
        

EntryPoint

An entry point as defined by Python packaging conventions.

    See `the packaging docs on entry points
    <https://packaging.python.org/specifications/entry-points/>`_
    for more information.
    
count(self, value, /)

  Return number of occurrences of value.
index(self, value, start=0, stop=9223372036854775807, /)

  Return first index of value.

  Raises ValueError if the value is not present.
load(self)

  Load the entry point from its definition. If only a module
          is indicated by the value, return that module. Otherwise,
          return the named object.
        
attr = <property object at 0x7f0226ef1090>
extras = <property object at 0x7f0226ef1040>
group = _tuplegetter(2, 'Alias for field number 2')
  Alias for field number 2
module = <property object at 0x7f0227528220>
name = _tuplegetter(0, 'Alias for field number 0')
  Alias for field number 0
pattern = re.compile('(?P<module>[\\w.]+)\\s*(:\\s*(?P<attr>[\\w.]+))?\\s*(?P<extras>\\[.*\\])?\\s*


)
value = _tuplegetter(1, 'Alias for field number 1')
  Alias for field number 1

FastPath


    Micro-optimized class for searching a path for
    children.
    
children(self)
is_egg(self, search)
joinpath(self, child)
search(self, name)
zip_children(self)

FileHash

MetaPathFinder

Abstract base class for import finders on sys.meta_path.
find_module(self, fullname, path)

  Return a loader for the module.

          If no module is found, return None.  The fullname is a str and
          the path is a list of strings or None.

          This method is deprecated since Python 3.4 in favor of
          finder.find_spec(). If find_spec() exists then backwards-compatible
          functionality is provided for this method.

        
invalidate_caches(self)

  An optional method for clearing the finder's cache, if any.
          This method is used by importlib.invalidate_caches().
        

MetadataPathFinder

invalidate_caches.Context


        Keyword arguments presented by the caller to
        ``distributions()`` or ``Distribution.discover()``
        to narrow the scope of a search for distributions
        in all DistributionFinders.

        Each DistributionFinder may expect any parameters
        and should attempt to honor the canonical
        parameters defined below when appropriate.
        
name = None
path = <property object at 0x7f0226ef13b0>

              The path that a distribution finder should search.

              Typically refers to Python package paths and defaults
              to ``sys.path``.
            
find_distributions(context=<importlib.metadata.DistributionFinder.Context object at 0x7f0226ee6790>)


          Find distributions.

          Return an iterable of all Distribution instances capable of
          loading the metadata for packages matching ``context.name``
          (or all names if ``None`` indicated) along the paths in the list
          of directories ``context.path``.
        
find_module(self, fullname, path)

  Return a loader for the module.

          If no module is found, return None.  The fullname is a str and
          the path is a list of strings or None.

          This method is deprecated since Python 3.4 in favor of
          finder.find_spec(). If find_spec() exists then backwards-compatible
          functionality is provided for this method.

        
invalidate_caches(self)

  An optional method for clearing the finder's cache, if any.
          This method is used by importlib.invalidate_caches().
        

PackageNotFoundError

The package was not found.
with_traceback(...)

  Exception.with_traceback(tb) --
      set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
msg = <member 'msg' of 'ImportError' objects>
  exception message
name = <member 'name' of 'ImportError' objects>
  module name
path = <member 'path' of 'ImportError' objects>
  module path

PackagePath

A reference to a path in a package
as_posix(self)

  Return the string representation of the path with forward (/)
          slashes.
as_uri(self)

  Return the path as a 'file' URI.
is_absolute(self)

  True if the path is absolute (has both a root and, if applicable,
          a drive).
is_relative_to(self, *other)

  Return True if the path is relative to another path or False.
        
is_reserved(self)

  Return True if the path contains one of the special names reserved
          by the system, if any.
joinpath(self, *args)

  Combine this path with one or several arguments, and return a
          new path representing either a subpath (if all arguments are relative
          paths) or a totally different path (if one of the arguments is
          anchored).
        
locate(self)

  Return a path-like object for this path
match(self, path_pattern)


          Return True if this path matches the given pattern.
        
read_binary(self)
read_text(self, encoding='utf-8')
relative_to(self, *other)

  Return the relative path to another path identified by the passed
          arguments.  If the operation is not possible (because this is not
          a subpath of the other path), raise ValueError.
        
with_name(self, name)

  Return a new path with the file name changed.
with_stem(self, stem)

  Return a new path with the stem changed.
with_suffix(self, suffix)

  Return a new path with the file suffix changed.  If the path
          has no suffix, add given suffix.  If the given suffix is an empty
          string, remove the suffix from the path.
        
anchor = <property object at 0x7f0226fb3cc0>
  The concatenation of the drive and root, or ''.
drive = <property object at 0x7f0226fb3c20>
  The drive prefix (letter or UNC path), if any.
name = <property object at 0x7f0226fb3d10>
  The final path component, if any.
parent = <property object at 0x7f0226fb3ea0>
  The logical parent of the path.
parents = <property object at 0x7f0226fb3ef0>
  A sequence of this path's logical parents.
parts = <property object at 0x7f0226fb3e50>
  An object providing sequence-like access to the
          components in the filesystem path.
root = <property object at 0x7f0226fb3c70>
  The root of the path, if any.
stem = <property object at 0x7f0226fb3e00>
  The final path component, minus its last suffix.
suffix = <property object at 0x7f0226fb3d60>

          The final component's last suffix, if any.

          This includes the leading period. For example: '.txt'
        
suffixes = <property object at 0x7f0226fb3db0>

          A list of the final component's suffixes, if any.

          These include the leading periods. For example: ['.tar', '.gz']
        

PathDistribution

at(path)

  Return a Distribution for the indicated metadata path

          :param path: a string or path-like object
          :return: a concrete Distribution instance for the path
        
discover(**kwargs)

  Return an iterable of Distribution objects for all packages.

          Pass a ``context`` or pass keyword arguments for constructing
          a context.

          :context: A ``DistributionFinder.Context`` object.
          :return: Iterable of Distribution objects for all packages.
        
from_name(name)

  Return the Distribution for the given package name.

          :param name: The name of the distribution package to search for.
          :return: The Distribution instance (or subclass thereof) for the named
              package, if found.
          :raises PackageNotFoundError: When the named package's distribution
              metadata cannot be found.
        
locate_file(self, path)
read_text(self, filename)

  Attempt to load metadata file given by the name.

          :param filename: The name of the file in the distribution info.
          :return: The text if found, otherwise None.
        
entry_points = <property object at 0x7f0226ef1270>
files = <property object at 0x7f0226ef12c0>
  Files in this distribution.

          :return: List of PackagePath for this distribution or None

          Result is `None` if the metadata file that enumerates files
          (i.e. RECORD for dist-info or SOURCES.txt for egg-info) is
          missing.
          Result may be empty if the metadata exists but is empty.
        
metadata = <property object at 0x7f0226ef11d0>
  Return the parsed metadata for this Distribution.

          The returned object will have keys that name the various bits of
          metadata.  See PEP 566 for details.
        
requires = <property object at 0x7f0226ef1310>
  Generated requirements specified for this Distribution
version = <property object at 0x7f0226ef1220>
  Return the 'Version' metadata for the distribution package.

Prepared


    A prepared search for metadata on a possibly-named package.
    
exact_matches = []
normalized = ''
prefix = ''
suffixes = ('.dist-info', '.egg-info')
versionless_egg_name = ''

starmap

Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence.

suppress

Context manager to suppress specified exceptions

    After the exception is suppressed, execution proceeds with the next
    statement following the with statement.

         with suppress(FileNotFoundError):
             os.remove(somefile)
         # Execution still resumes here if the file was already removed
    

Functions

distribution

distribution(distribution_name)

  Get the ``Distribution`` instance for the named package.

      :param distribution_name: The name of the distribution package as a string.
      :return: A ``Distribution`` instance (or subclass thereof).
    

distributions

distributions(**kwargs)

  Get all ``Distribution`` instances in the current environment.

      :return: An iterable of ``Distribution`` instances.
    

entry_points

entry_points()

  Return EntryPoint objects for all installed packages.

      :return: EntryPoint objects for all installed packages.
    

files

files(distribution_name)

  Return a list of files for the named package.

      :param distribution_name: The name of the distribution package to query.
      :return: List of files composing the distribution.
    

import_module

import_module(name, package=None)

  Import a module.

      The 'package' argument is required when performing a relative import. It
      specifies the package to use as the anchor point from which to resolve the
      relative import to an absolute import.

    

metadata

metadata(distribution_name)

  Get the metadata for the named package.

      :param distribution_name: The name of the distribution package to query.
      :return: An email.Message containing the parsed metadata.
    

requires

requires(distribution_name)


      Return a list of requirements for the named package.

      :return: An iterator of requirements, suitable for
      packaging.requirement.Requirement.
    

version

version(distribution_name)

  Get the version string for the named package.

      :param distribution_name: The name of the distribution package to query.
      :return: The version string for the package as defined in the package's
          "Version" metadata key.
    

Modules

abc

collections

csv

email

functools

io

itertools

operator

os

pathlib

posixpath

re

sys

zipfile