open_remote_file#
- gwpy.io.remote.open_remote_file(
- url: str,
- *,
- cache: bool | None = None,
- show_progress: bool = False,
- encoding: Literal['binary'] = 'binary',
- **kwargs,
- gwpy.io.remote.open_remote_file(
- url: str,
- *,
- cache: bool | None = None,
- show_progress: bool = False,
- encoding: str | None,
- **kwargs,
Download a file and open it.
This function is a wrapper around
astropy.utils.data.get_readable_fileobjwith the following customisations:Default to
cache=Trueif theGWPY_CACHEenvironment variable is set to something ‘truthy’.If the URL looks like a Pelican URL, hand off to a dedicated Pelican download wrapper to attempt the remote access.
- Parameters:
- url
str, file-like The name of the resource to access. Can be a local path, or a
file://URL, or any remote URL supported by Astropy.- cache
bool Whether to cache the contents of remote URLs. Default is
Trueif theGWPY_CACHEenvironment variable is set to something ‘truthy’.- show_progress: `bool`, optional
Print verbose progress information to the screen.
- encoding
str, optional When
'binary'(default), returns a file-like object where itsreadmethod returnsbytesobjects.When
None, returns a file-like object with areadmethod that returnsstr(unicode) objects, usinglocale.getpreferredencodingas an encoding. This matches the default behavior of the built-inopenwhen nomodeargument is provided.When another string, it is the name of an encoding, and the file-like object’s
readmethod will returnstr(unicode) objects, decoded from binary using the given encoding.- kwargs
All other positional and keyword arguments are passed directly to
astropy.utils.data.get_readable_fileobj.
- url
- Returns:
- filefile-like
The file opened in binary format.
See also
astropy.utils.data.get_readable_fileobjFor details of the underlying downloader.
gwpy.io.pelican.open_remote_fileFor details of the Pelican-aware download wrapper.