MCPcopy Create free account
hub / github.com/numpy/numpy / open

Function open

numpy/lib/_datasource.py:155–193  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

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

Callers 15

_compute_hashFunction · 0.85
write_release_taskFunction · 0.85
mainFunction · 0.85
build_projectFunction · 0.85
asv_substitute_configFunction · 0.85
check_submodulesFunction · 0.85
__enter__Method · 0.85
__exit__Method · 0.85
flags_is_requiredFunction · 0.85
download_wheelsFunction · 0.85
get_countFunction · 0.85
find_missingFunction · 0.85

Calls 2

openMethod · 0.95
DataSourceClass · 0.85

Tested by 15

mainFunction · 0.68
build_projectFunction · 0.68
asv_substitute_configFunction · 0.68
test_cythonFunction · 0.68
_read_csvMethod · 0.68
test_isfileobjFunction · 0.68
assert_features_equalFunction · 0.68
get_cpuinfo_itemMethod · 0.68
test_astype_copyMethod · 0.68
test_fromfile_bogusMethod · 0.68