summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorPaul Moore <p.f.moore@gmail.com>2021-04-28 23:27:37 (GMT)
committerGitHub <noreply@github.com>2021-04-28 23:27:37 (GMT)
commitb38b2fa0218911ccc20d576ff504f39c9c9d47ec (patch)
tree4aaec5d25d928a2069d50657916074c332f22f9d /Doc/library
parent4a85718212fd032c922ca7d630b2602dd4b29a35 (diff)
downloadcpython-b38b2fa0218911ccc20d576ff504f39c9c9d47ec.zip
cpython-b38b2fa0218911ccc20d576ff504f39c9c9d47ec.tar.gz
cpython-b38b2fa0218911ccc20d576ff504f39c9c9d47ec.tar.bz2
Document importlib.metadata.PackagePath.locate method (GH-25669)
Diffstat (limited to 'Doc/library')
-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 0f0a8dd..40e48d1 100644
--- a/Doc/library/importlib.metadata.rst
+++ b/Doc/library/importlib.metadata.rst
@@ -191,7 +191,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
@@ -215,6 +215,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