Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed Sep 28, 2023
1 parent 348564c commit 1c91eb2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions climetlab/sources/ecmwf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,28 @@ def retrieve(target, request):
@normalize("date", "date-list(%Y-%m-%d)")
@normalize("area", "bounding-box(list)")
def requests(self, **kwargs):
def value_to_list(v):
if isinstance(v, (list, tuple)):
return v
return (v,)

def to_lists(dic):
# Ensure that we only give lists.
# this is workaround because time=0 is treated as null or None and removed
# and replaced by the default value with may be != 0 (such as 12)
return {k: value_to_list(v) for k, v in dic.items()}

split_on = kwargs.pop("split_on", None)
if split_on is None or not isinstance(kwargs.get(split_on), (list, tuple)):
kwargs = to_lists(kwargs)
return [kwargs]

result = []

for v in kwargs[split_on]:
r = dict(**kwargs)
r[split_on] = v
r = to_lists(r)
result.append(r)

return result
Expand Down

0 comments on commit 1c91eb2

Please sign in to comment.