MCPcopy Index your code
hub / github.com/RustPython/RustPython / _is_present_dir

Function _is_present_dir

Lib/importlib/resources/_common.py:152–162  ·  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

150
151
152def _is_present_dir(path: Traversable) -> bool:
153 """
154 Some Traversables implement ``is_dir()`` to raise an
155 exception (i.e. ``FileNotFoundError``) when the
156 directory doesn't exist. This function wraps that call
157 to always return a boolean and only return True
158 if there's a dir and it exists.
159 """
160 with contextlib.suppress(FileNotFoundError):
161 return path.is_dir()
162 return False
163
164
165@functools.singledispatch

Callers 1

as_fileFunction · 0.85

Calls 1

is_dirMethod · 0.45

Tested by

no test coverage detected