Skip to content

Commit

Permalink
Add example in docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Apr 18, 2024
1 parent 0a742fa commit be3ad83
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pytroll_watchers/dataspace_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,20 @@ def _fromisoformat(metadata):


def generate_download_links_since(filter_string, dataspace_auth, last_publication_date, storage_options):
"""Generate download links for data that was published since a given `last publication_date`."""
"""Generate download links for data that was published since a given `last publication_date`.
Example:
To fetch download link since yesterday, using netrc-stored credentials, and an aws s3 profile:
>>> from pytroll_watchers.dataspace_watcher import generate_download_links_since
>>> filter_string = "contains(Name,'OL_1_EFR')"
>>> dataspace_auth = dict(netrc_host="dataspace.copernicus.eu")
>>> last_publication_date = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(hours=24)
>>> storage_options = dict(profile="my_copernicus_s3_profile")
>>> generator = generate_download_links_since(filter_string, dataspace_auth, last_publication_date,
... storage_options)
"""
pub_limit = f"PublicationDate gt {last_publication_date.strftime('%Y-%m-%dT%H:%M:%S.%fZ')}"
filter_string_with_pub_limit = f"{filter_string} and {pub_limit}"

Expand Down

0 comments on commit be3ad83

Please sign in to comment.