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

Method open

numpy/lib/_datasource.py:654–684  ·  view source on GitHub ↗

Open and return file-like object prepending Repository base URL. If `path` is an URL, it will be downloaded, stored in the DataSource directory and opened from there. Parameters ---------- path : str Local file path or URL to open. This

(self, path, mode='r', encoding=None, newline=None)

Source from the content-addressed store, hash-verified

652 return DataSource.exists(self, self._fullpath(path))
653
654 def open(self, path, mode='r', encoding=None, newline=None):
655 """
656 Open and return file-like object prepending Repository base URL.
657
658 If `path` is an URL, it will be downloaded, stored in the
659 DataSource directory and opened from there.
660
661 Parameters
662 ----------
663 path : str
664 Local file path or URL to open. This may, but does not have to,
665 include the `baseurl` with which the `Repository` was
666 initialized.
667 mode : {'r', 'w', 'a'}, optional
668 Mode to open `path`. Mode 'r' for reading, 'w' for writing,
669 'a' to append. Available modes depend on the type of object
670 specified by `path`. Default is 'r'.
671 encoding : {None, str}, optional
672 Open text file with given encoding. The default encoding will be
673 what `io.open` uses.
674 newline : {None, str}, optional
675 Newline to use when reading text file.
676
677 Returns
678 -------
679 out : file object
680 File object.
681
682 """
683 return DataSource.open(self, self._fullpath(path), mode,
684 encoding=encoding, newline=newline)
685
686 def listdir(self):
687 """

Callers

nothing calls this directly

Calls 2

_fullpathMethod · 0.95
openMethod · 0.45

Tested by

no test coverage detected