MCPcopy Create free account
hub / github.com/nodejs/node / open_if_exists

Function open_if_exists

deps/v8/third_party/jinja2/utils.py:155–162  ·  view source on GitHub ↗

Returns a file descriptor for the filename if that file exists, otherwise ``None``.

(filename: str, mode: str = "rb")

Source from the content-addressed store, hash-verified

153
154
155def open_if_exists(filename: str, mode: str = "rb") -> t.Optional[t.IO]:
156 """Returns a file descriptor for the filename if that file exists,
157 otherwise ``None``.
158 """
159 if not os.path.isfile(filename):
160 return None
161
162 return open(filename, mode)
163
164
165def object_type_repr(obj: t.Any) -> str:

Callers 1

get_sourceMethod · 0.70

Calls 1

openFunction · 0.50

Tested by

no test coverage detected