MCPcopy Index your code
hub / github.com/python/cpython / _is_present_dir

Function _is_present_dir

Lib/importlib/resources/_common.py:118–128  ·  view source on GitHub ↗

Some Traversables implement ``is_dir()`` to raise an exception (i.e. ``FileNotFoundError``) when the directory doesn't exist. This function wraps that call to always return a boolean and only return True if there's a dir and it exists.

(path: Traversable)

Source from the content-addressed store, hash-verified

116
117
118def _is_present_dir(path: Traversable) -> bool:
119 """
120 Some Traversables implement ``is_dir()`` to raise an
121 exception (i.e. ``FileNotFoundError``) when the
122 directory doesn't exist. This function wraps that call
123 to always return a boolean and only return True
124 if there's a dir and it exists.
125 """
126 with contextlib.suppress(FileNotFoundError):
127 return path.is_dir()
128 return False
129
130
131@functools.singledispatch

Callers 1

as_fileFunction · 0.85

Calls 1

is_dirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…