MCPcopy Index your code
hub / github.com/numpy/numpy / open

Function open

numpy/lib/_datasource.py:154–192  ·  view source on GitHub ↗

Open `path` with `mode` and return the file object. If ``path`` is a URL, it will be downloaded, stored in the `DataSource` `destpath` directory and opened from there. Parameters ---------- path : str or pathlib.Path Local file path or URL to open. mode : str,

(path, mode='r', destpath=os.curdir, encoding=None, newline=None)

Source from the content-addressed store, hash-verified

152_file_openers = _FileOpeners()
153
154def open(path, mode='r', destpath=os.curdir, encoding=None, newline=None):
155 """
156 Open `path` with `mode` and return the file object.
157
158 If ``path`` is a URL, it will be downloaded, stored in the
159 `DataSource` `destpath` directory and opened from there.
160
161 Parameters
162 ----------
163 path : str or pathlib.Path
164 Local file path or URL to open.
165 mode : str, optional
166 Mode to open `path`. Mode 'r' for reading, 'w' for writing, 'a' to
167 append. Available modes depend on the type of object specified by
168 path. Default is 'r'.
169 destpath : str, optional
170 Path to the directory where the source file gets downloaded to for
171 use. If `destpath` is None, a temporary directory will be created.
172 The default path is the current directory.
173 encoding : {None, str}, optional
174 Open text file with given encoding. The default encoding will be
175 what `open` uses.
176 newline : {None, str}, optional
177 Newline to use when reading text file.
178
179 Returns
180 -------
181 out : file object
182 The opened file.
183
184 Notes
185 -----
186 This is a convenience function that instantiates a `DataSource` and
187 returns the file object from ``DataSource.open(path)``.
188
189 """
190
191 ds = DataSource(destpath)
192 return ds.open(path, mode, encoding=encoding, newline=newline)
193
194
195@set_module('numpy.lib.npyio')

Callers 15

get_submodule_pathsFunction · 0.85
find_missingFunction · 0.85
parse_reqsFunction · 0.85
write_textMethod · 0.85
write_htmlMethod · 0.85
write_textMethod · 0.85
write_htmlMethod · 0.85
doxy_genFunction · 0.85
doxy_configFunction · 0.85

Calls 2

openMethod · 0.95
DataSourceClass · 0.85

Tested by 15

test_cythonFunction · 0.68
_read_csvMethod · 0.68
test_pickleFunction · 0.68
assert_features_equalFunction · 0.68
get_cpuinfo_itemMethod · 0.68
test_astype_copyMethod · 0.68
install_tempFunction · 0.68
install_tempFunction · 0.68
test_fromfile_bogusMethod · 0.68
test_fromfile_complexMethod · 0.68
test_fromfileMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…