summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-07-18 02:53:00 (GMT)
committerGitHub <noreply@github.com>2021-07-18 02:53:00 (GMT)
commit049e98b2b74cdcd462f31720c24ab6ebff599d9f (patch)
tree5e71882f6c1c7d7a9a801c5b1e076ca776cfd230
parent8187033de10ee94c4997ab619f9ee4f255aa0b4c (diff)
downloadcpython-049e98b2b74cdcd462f31720c24ab6ebff599d9f.zip
cpython-049e98b2b74cdcd462f31720c24ab6ebff599d9f.tar.gz
cpython-049e98b2b74cdcd462f31720c24ab6ebff599d9f.tar.bz2
[3.9] bpo-43958: Document importlib.metadata.PackagePath.locate method (GH-25669) (GH-27221)
(cherry picked from commit b38b2fa0218911ccc20d576ff504f39c9c9d47ec) Co-authored-by: Paul Moore <p.f.moore@gmail.com> Automerge-Triggered-By: GH:jaraco
-rw-r--r--Doc/library/importlib.metadata.rst8
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/library/importlib.metadata.rst b/Doc/library/importlib.metadata.rst
index 9bf3404..1f73017 100644
--- a/Doc/library/importlib.metadata.rst
+++ b/Doc/library/importlib.metadata.rst
@@ -149,7 +149,7 @@ Distribution files
You can also get the full set of files contained within a distribution. The
``files()`` function takes a distribution package name and returns all of the
files installed by this distribution. Each file object returned is a
-``PackagePath``, a :class:`pathlib.Path` derived object with additional ``dist``,
+``PackagePath``, a :class:`pathlib.PurePath` derived object with additional ``dist``,
``size``, and ``hash`` properties as indicated by the metadata. For example::
>>> util = [p for p in files('wheel') if 'util.py' in str(p)][0] # doctest: +SKIP
@@ -173,6 +173,12 @@ Once you have the file, you can also read its contents::
return s.encode('utf-8')
return s
+You can also use the ``locate`` method to get a the absolute path to the
+file::
+
+ >>> util.locate() # doctest: +SKIP
+ PosixPath('/home/gustav/example/lib/site-packages/wheel/util.py')
+
In the case where the metadata file listing files
(RECORD or SOURCES.txt) is missing, ``files()`` will
return ``None``. The caller may wish to wrap calls to