MCPcopy Index your code
hub / github.com/nodejs/node / open_if_exists

Function open_if_exists

tools/inspector_protocol/jinja2/utils.py:149–157  ·  view source on GitHub ↗

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

(filename, mode='rb')

Source from the content-addressed store, hash-verified

147
148
149def open_if_exists(filename, mode='rb'):
150 """Returns a file descriptor for the filename if that file exists,
151 otherwise `None`.
152 """
153 try:
154 return open(filename, mode)
155 except IOError as e:
156 if e.errno not in (errno.ENOENT, errno.EISDIR, errno.EINVAL):
157 raise
158
159
160def object_type_repr(obj):

Callers 2

get_sourceMethod · 0.90
load_bytecodeMethod · 0.90

Calls 1

openFunction · 0.50

Tested by

no test coverage detected