python-cmr
Advanced tools
+24
-2
@@ -1,3 +0,25 @@ | ||
| from .queries import GranuleQuery, CollectionQuery, ToolQuery, ServiceQuery, VariableQuery, CMR_OPS, CMR_UAT, CMR_SIT | ||
| from .queries import ( | ||
| CMR_OPS, | ||
| CMR_SIT, | ||
| CMR_UAT, | ||
| CollectionQuery, | ||
| DayNightFlag, | ||
| GranuleQuery, | ||
| Query, | ||
| ServiceQuery, | ||
| ToolQuery, | ||
| VariableQuery, | ||
| ) | ||
| __all__ = ["GranuleQuery", "CollectionQuery", "ToolQuery", "ServiceQuery", "VariableQuery", "CMR_OPS", "CMR_UAT", "CMR_SIT"] | ||
| __all__ = [ | ||
| "CMR_OPS", | ||
| "CMR_SIT", | ||
| "CMR_UAT", | ||
| "CollectionQuery", | ||
| "DayNightFlag", | ||
| "GranuleQuery", | ||
| "Query", | ||
| "ServiceQuery", | ||
| "ToolQuery", | ||
| "VariableQuery", | ||
| ] |
+92
-19
@@ -34,8 +34,7 @@ """ | ||
| DateLike: TypeAlias = Union[str, date, datetime] | ||
| DayNightFlag: TypeAlias = Union[ | ||
| Literal["day"], Literal["night"], Literal["unspecified"] | ||
| ] | ||
| DayNightFlag: TypeAlias = Literal["day", "night", "unspecified"] | ||
| FloatLike: TypeAlias = Union[str, SupportsFloat] | ||
| PointLike: TypeAlias = Tuple[FloatLike, FloatLike] | ||
| class Query: | ||
@@ -289,3 +288,3 @@ """ | ||
| """ | ||
| Add token into authorization headers. | ||
| Set the value of this query's `Authorization` header to the given token. | ||
@@ -299,3 +298,3 @@ :param token: Token from EDL Echo-Token or NASA Launchpad token. | ||
| self.headers = {'Authorization': token} | ||
| self.headers.update({"Authorization": token}) | ||
@@ -306,3 +305,3 @@ return self | ||
| """ | ||
| Add token into authorization headers. | ||
| Set the value of this query's `Authorization` header to the given bearer token. | ||
@@ -316,3 +315,3 @@ :param token: Token from EDL token. | ||
| self.headers = {'Authorization': f'Bearer {bearer_token}'} | ||
| self.headers.update({"Authorization": f"Bearer {bearer_token}"}) | ||
@@ -347,20 +346,15 @@ return self | ||
| def temporal( | ||
| def _format_date( | ||
| self, | ||
| date_from: Optional[DateLike], | ||
| date_to: Optional[DateLike], | ||
| exclude_boundary: bool = False, | ||
| ) -> Self: | ||
| date_to: Optional[DateLike] | ||
| ) -> Tuple[str, str]: | ||
| """ | ||
| Filter by an open or closed date range. | ||
| Dates can be provided as native date objects or ISO 8601 formatted strings. Multiple | ||
| ranges can be provided by successive calls to this method before calling execute(). | ||
| Format dates into expected format for date queries. | ||
| :param date_from: earliest date of temporal range | ||
| :param date_to: latest date of temporal range | ||
| :param exclude_boundary: whether or not to exclude the date_from/to in the matched range | ||
| :returns: GranueQuery instance | ||
| :returns: Tuple instance | ||
| """ | ||
| iso_8601 = "%Y-%m-%dT%H:%M:%SZ" | ||
@@ -405,4 +399,59 @@ | ||
| raise ValueError("date_from must be earlier than date_to.") | ||
| return date_from, date_to | ||
| def revision_date( | ||
| self, | ||
| date_from: Optional[DateLike], | ||
| date_to: Optional[DateLike], | ||
| exclude_boundary: bool = False, | ||
| ) -> Self: | ||
| """ | ||
| Filter by an open or closed date range for a query that captures updated items. | ||
| Dates can be provided as native date objects or ISO 8601 formatted strings. Multiple | ||
| ranges can be provided by successive calls to this method before calling execute(). | ||
| :param date_from: earliest date of temporal range | ||
| :param date_to: latest date of temporal range | ||
| :param exclude_boundary: whether or not to exclude the date_from/to in the matched range | ||
| :returns: GranueQuery instance | ||
| """ | ||
| date_from, date_to = self._format_date(date_from, date_to) | ||
| # good to go, make sure we have a param list | ||
| if "revision_date" not in self.params: | ||
| self.params["revision_date"] = [] | ||
| self.params["revision_date"].append(f"{date_from},{date_to}") | ||
| if exclude_boundary: | ||
| self.options["revision_date"] = { | ||
| "exclude_boundary": True | ||
| } | ||
| return self | ||
| def temporal( | ||
| self, | ||
| date_from: Optional[DateLike], | ||
| date_to: Optional[DateLike], | ||
| exclude_boundary: bool = False, | ||
| ) -> Self: | ||
| """ | ||
| Filter by an open or closed date range for a temporal query. | ||
| Dates can be provided as native date objects or ISO 8601 formatted strings. Multiple | ||
| ranges can be provided by successive calls to this method before calling execute(). | ||
| :param date_from: earliest date of temporal range | ||
| :param date_to: latest date of temporal range | ||
| :param exclude_boundary: whether or not to exclude the date_from/to in the matched range | ||
| :returns: GranueQuery instance | ||
| """ | ||
| date_from, date_to = self._format_date(date_from, date_to) | ||
| # good to go, make sure we have a param list | ||
| if "temporal" not in self.params: | ||
@@ -931,2 +980,26 @@ self.params["temporal"] = [] | ||
| def cloud_hosted(self, cloud_hosted: bool) -> Self: | ||
| """ | ||
| Filter collections to only those that are (or are not) hosted in cloud storage. | ||
| A cloud-hosted collection either has a `DirectDistributionInformation` element | ||
| or is tagged with `gov.nasa.earthdatacloud.s3`. | ||
| When this method is _not_ invoked, the query results may contain a mix of | ||
| cloud-hosted and non-cloud-hosted (on-premise) collections. | ||
| :param cloud_hosted: `True` to select _only_ cloud-hosted collections; `False` to | ||
| select only _non_-cloud-hosted (on-premise) collections | ||
| :returns: self | ||
| ..seealso:: | ||
| `Find collections with data that is hosted in the cloud. <https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html#c-cloud-hosted>`_ | ||
| Documentation for finding cloud-hosted collections with the CMR Search API. | ||
| """ # noqa: E501 | ||
| if not isinstance(cloud_hosted, bool): | ||
| raise TypeError("Cloud hosted must be of type bool") | ||
| self.params["cloud_hosted"] = cloud_hosted | ||
| return self | ||
| @override | ||
@@ -933,0 +1006,0 @@ def _valid_state(self) -> bool: |
+11
-1
| Metadata-Version: 2.1 | ||
| Name: python-cmr | ||
| Version: 0.11.0 | ||
| Version: 0.12.0 | ||
| Summary: Python wrapper to the NASA Common Metadata Repository (CMR) API. | ||
@@ -134,2 +134,5 @@ Home-page: https://github.com/nasa/python_cmr | ||
| # search for granules by revision_date | ||
| api.revision_date("2022-05-16", "2024-06-30") | ||
| # only include granules available for download | ||
@@ -382,1 +385,8 @@ api.downloadable() | ||
| Run Type Checks | ||
| --------------- | ||
| ```shell | ||
| poetry run mypy cmr tests | ||
| ``` | ||
+1
-1
@@ -7,3 +7,3 @@ [build-system] | ||
| name = "python-cmr" | ||
| version = "0.11.0" | ||
| version = "0.12.0" | ||
| description = "Python wrapper to the NASA Common Metadata Repository (CMR) API." | ||
@@ -10,0 +10,0 @@ authors = ["python_cmr <nasa/python_cmr@github.com>"] |
+10
-0
@@ -105,2 +105,5 @@ This repository is a copy | ||
| # search for granules by revision_date | ||
| api.revision_date("2022-05-16", "2024-06-30") | ||
| # only include granules available for download | ||
@@ -352,1 +355,8 @@ api.downloadable() | ||
| ``` | ||
| Run Type Checks | ||
| --------------- | ||
| ```shell | ||
| poetry run mypy cmr tests | ||
| ``` |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
57162
6.13%863
9.66%