Call `ReadablePath.info.exists()` rather than `ReadablePath.exists()` when
globbing so that we use (or populate) the `info` cache.
"""Provides shell-style pattern matching and globbing for pathlib paths.
"""
- lexists = operator.methodcaller('exists', follow_symlinks=False)
+ @staticmethod
+ def lexists(path):
+ return path.info.exists(follow_symlinks=False)
@staticmethod
def scandir(path):
paths.append((path, dirnames, filenames))
try:
for child in path.iterdir():
- try:
- if child.info.is_dir(follow_symlinks=follow_symlinks):
- if not top_down:
- paths.append(child)
- dirnames.append(child.name)
- else:
- filenames.append(child.name)
- except OSError:
+ if child.info.is_dir(follow_symlinks=follow_symlinks):
+ if not top_down:
+ paths.append(child)
+ dirnames.append(child.name)
+ else:
filenames.append(child.name)
except OSError as error:
if on_error is not None:
p = P(self.base)
q = p / "FILEa"
given = set(p.glob("FILEa"))
- expect = {q} if q.exists() else set()
+ expect = {q} if q.info.exists() else set()
self.assertEqual(given, expect)
self.assertEqual(set(p.glob("FILEa*")), set())