From be3ad83ece4449b8b9f7080fed7df22949e41c92 Mon Sep 17 00:00:00 2001 From: Martin Raspaud Date: Thu, 18 Apr 2024 08:36:28 +0200 Subject: [PATCH] Add example in docstring --- src/pytroll_watchers/dataspace_watcher.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pytroll_watchers/dataspace_watcher.py b/src/pytroll_watchers/dataspace_watcher.py index 6b74244..2920a1e 100644 --- a/src/pytroll_watchers/dataspace_watcher.py +++ b/src/pytroll_watchers/dataspace_watcher.py @@ -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}"