Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AMDA]Adds support for registered requests on time restricted products #118

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Removes unused function and documents new has_time_restriction
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
  • Loading branch information
jeandet committed Feb 22, 2024
commit 502875bbaffb302bbcdd139f5f033eea0e1369d3
23 changes: 16 additions & 7 deletions speasy/webservices/amda/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ def is_user_parameter(self, parameter_id: str or ParameterIndex):

def has_time_restriction(self, product_id: str or SpeasyIndex, start_time: str or datetime,
stop_time: str or datetime):
"""Check if product is restricted for a given time range.

Parameters
----------
product_id: str or SpeasyIndex
product id
start_time: str or datetime
desired data start time
stop_time: str or datetime
desired data stop time

Returns
-------
bool
True if product is restricted for the given time range, False otherwise.
"""
dataset = self._find_parent_dataset(product_id)
if dataset:
dataset = self.flat_inventory.datasets[dataset]
Expand Down Expand Up @@ -698,13 +714,6 @@ def _find_parent_dataset(self, product_id: str or DatasetIndex or ParameterIndex
if product_id in dataset:
return to_xmlid(dataset)

def _time_restriction_range(self, product_id: str or DatasetIndex or ParameterIndex or ComponentIndex) -> Optional[
DateTimeRange]:
dataset = self._find_parent_dataset(product_id)
if dataset and hasattr(dataset, 'timeRestriction'):
return DateTimeRange(dataset.timeRestriction, dataset.stop_date)
return None

def product_type(self, product_id: str or SpeasyIndex) -> ProductType:
"""Returns product type for any known ADMA product from its index or ID.

Expand Down
Loading