Commit 537b6caa authored by Eivind Teig's avatar Eivind Teig Committed by Miss Islington (bot)

bpo-22062: Updated docstring and documentation for pathlib (GH-8519)



Original patch by Mike Short


https://bugs.python.org/issue22062
parent 9db56fb8
...@@ -728,7 +728,7 @@ call fails (for example because the path doesn't exist). ...@@ -728,7 +728,7 @@ call fails (for example because the path doesn't exist).
.. method:: Path.glob(pattern) .. method:: Path.glob(pattern)
Glob the given *pattern* in the directory represented by this path, Glob the given relative *pattern* in the directory represented by this path,
yielding all matching files (of any kind):: yielding all matching files (of any kind)::
>>> sorted(Path('.').glob('*.py')) >>> sorted(Path('.').glob('*.py'))
...@@ -980,8 +980,8 @@ call fails (for example because the path doesn't exist). ...@@ -980,8 +980,8 @@ call fails (for example because the path doesn't exist).
.. method:: Path.rglob(pattern) .. method:: Path.rglob(pattern)
This is like calling :meth:`Path.glob` with "``**``" added in front of the This is like calling :func:`Path.glob` with "``**/``" added in front of the
given *pattern*:: given relative *pattern*::
>>> sorted(Path().rglob("*.py")) >>> sorted(Path().rglob("*.py"))
[PosixPath('build/lib/pathlib.py'), [PosixPath('build/lib/pathlib.py'),
......
...@@ -1090,7 +1090,7 @@ class Path(PurePath): ...@@ -1090,7 +1090,7 @@ class Path(PurePath):
def glob(self, pattern): def glob(self, pattern):
"""Iterate over this subtree and yield all existing files (of any """Iterate over this subtree and yield all existing files (of any
kind, including directories) matching the given pattern. kind, including directories) matching the given relative pattern.
""" """
if not pattern: if not pattern:
raise ValueError("Unacceptable pattern: {!r}".format(pattern)) raise ValueError("Unacceptable pattern: {!r}".format(pattern))
...@@ -1104,7 +1104,8 @@ class Path(PurePath): ...@@ -1104,7 +1104,8 @@ class Path(PurePath):
def rglob(self, pattern): def rglob(self, pattern):
"""Recursively yield all existing files (of any kind, including """Recursively yield all existing files (of any kind, including
directories) matching the given pattern, anywhere in this subtree. directories) matching the given relative pattern, anywhere in
this subtree.
""" """
pattern = self._flavour.casefold(pattern) pattern = self._flavour.casefold(pattern)
drv, root, pattern_parts = self._flavour.parse_parts((pattern,)) drv, root, pattern_parts = self._flavour.parse_parts((pattern,))
......
Update documentation and docstrings for pathlib. Original patch by Mike Short.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment