Assets#
SyncAsset#
- class nasa.SyncAsset[source]#
Bases:
_BaseAssetRepresents an asset returned by the NASA Api as a python object.
Supported Operations
- x == y
Checks if two Assets holds the same file.
- x != y
Checks if two Assets don’t holds the same file.
New in version 0.0.1.
- read() bytes[source]#
Fetch the file and return its bytes.
Note
This function doesn’t use the token. As a result requests made with this method won’t reduce your request counter.
- Returns:
The
bytesof the file.- Return type:
- property bytes_asset: bytes#
The bytes of the asset if already cached otherwise
None.Hint
This property can be
Noneif the Asset wasn’t previously fetched. You should check ifbytes_assetisNoneand then fetch it. Check the example atAstronomyPicture.image.- Type:
Union[
bytes,None]
- save(file: str | bytes | os.PathLike[str], *, seek_at_end: bool = True) str[source]#
- save(file: BufferedIOBase, *, seek_at_end: bool = True) int
Saves the Asset locally. If
fileisio.BufferedIOBasereturns the numbers of bytes writed otherwise the name of the file or the path where it was saved.- Parameters:
file (Union[
str,bytes,os.PathLike,io.BufferedIOBase]) –seek_at_end (
bool) –
- Returns:
If
fileisio.BufferedIOBasethe number of bytes written; otherwise the name of the file or the path where it was saved.- Return type:
AsyncAsset#
- class nasa.AsyncAsset[source]#
Bases:
_BaseAssetRepresents an asset returned by the NASA Api as a python object.
Supported Operations
- x == y
Checks if two Assets holds the same file.
- x != y
Checks if two Assets don’t holds the same file.
New in version 0.0.1.
- async read() bytes[source]#
Fetch the file and return its bytes.
Note
This function doesn’t use the token. As a result requests made with this method won’t reduce your request counter.
- Returns:
The
bytesof the file.- Return type:
- property bytes_asset: bytes | None#
the bytes of the asset if already cached otherwise
None.Hint
This property can be
Noneif the Asset wasn’t previously fetched. You should check ifbytes_assetisNoneand then fetch it. Check the example atAstronomyPicture.image.- Type:
Union[
bytes,None]
- async save(file: BufferedIOBase, *, seek_at_end: bool = True) int[source]#
- async save(file: str | bytes | os.PathLike[str], *, seek_at_end: bool = True) Union[str, bytes, PathLike[str], PathLike[bytes]]
Saves the Asset locally. If
fileisio.BufferedIOBasereturns the numbers of bytes writed otherwise the name of the file or the path where it was saved.- Parameters:
file (Union[
str,bytes,os.PathLike,io.BufferedIOBase]) –seek_at_end (
bool) –
- Returns:
If
fileisio.BufferedIOBasethe number of bytes written; otherwise the name of the file or the path where it was saved.- Return type:
Union[
int,str,bytes,os.PathLike]