Skip to content

Commit

Permalink
Allow specifying product type when printing eodag products metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
HamedElgizery committed Jul 3, 2024
1 parent f4f2bba commit b87069a
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/imagery/i.eodag/i.eodag.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,33 +796,40 @@ def to_dict(config):
def print_eodag_providers(**kwargs):
"""Print providers available in JSON format.
:param producType: Restricts providers to given product.
:type productType: dict
:param kwargs: Restricts providers to providers offering specified product type.
:type kwargs: dict
"""
productType = kwargs["producttype"]
if productType:
gs.message(_("Recongnized providers offering {}".format(productType)))
product_type = kwargs["producttype"]
if product_type:
gs.message(_("Recongnized providers offering {}".format(product_type)))
else:
gs.message(_("Recongnizaed providers"))
print(
json.dumps(
{"providers": dag.available_providers(productType or None)}, indent=4
{"providers": dag.available_providers(product_type or None)}, indent=4
)
)


def print_eodag_products(**kwargs):
"""Print products available in JSON format.
:param provider: Restricts products to given provider.
:type provider: dict
:param kwargs: Restricts products to products offered by specific provider
or specifies product type.
:type kwargs: dict
"""
provider = kwargs["provider"]
product_type = kwargs["producttype"]
if provider:
gs.message(_("Recognized products offered by {}".format(provider)))
else:
gs.message(_("Recongnizaed providers"))
print(json.dumps({"products": dag.list_product_types(provider or None)}, indent=4))
products = dag.list_product_types(provider or None)
if product_type:
for product in products:
if product["ID"] == product_type:
products = [product]
print(json.dumps({"products": products}, indent=4))


def print_eodag_queryables(**kwargs):
Expand All @@ -832,10 +839,10 @@ def print_eodag_queryables(**kwargs):
:type kwargs: dict
"""
provider = kwargs["provider"]
productType = kwargs["producttype"]
product_type = kwargs["producttype"]
gs.message(_("Available queryables"))
queryables = dag.list_queryables(
provider=provider or None, productType=productType or None
provider=provider or None, productType=product_type or None
)

# Literal is for queryables that have a certain list of options to choose from.
Expand Down

0 comments on commit b87069a

Please sign in to comment.