Skip to content

Commit

Permalink
pygribjump: context should be a dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisspyB committed Sep 18, 2024
1 parent d4ba56e commit 1407e45
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pygribjump/pygribjump.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self):
# Set free function
self.__gribjump = ffi.gc(gribjump[0], lib.gribjump_delete_handle)

def extract(self, polyrequest, logctx="none", dump=True):
def extract(self, polyrequest, ctx=None, dump=True):
# TODO Add md5 hash to request
"""
Parameters
Expand All @@ -121,6 +121,11 @@ def extract(self, polyrequest, logctx="none", dump=True):
nfields = ffi.new('unsigned long**')
nrequests = len(requests)
c_requests = ffi.new('gribjump_extraction_request_t*[]', [r.ctype for r in requests])
if (ctx):
logctx=str(ctx)
else:
logctx=""

logctx_c = ffi.new('const char[]', logctx.encode('ascii'))
lib.extract(self.__gribjump, c_requests, nrequests, results_array, nfields, logctx_c)

Expand Down Expand Up @@ -346,4 +351,5 @@ def list_to_rangestr(ranges):

def dic_to_request(dic):
# e.g. {"class":"od", "expver":"0001", "levtype":"pl"} -> "class=od,expver=0001,levtype=pl"
return ','.join(['='.join([k, v]) for k, v in dic.items()])
return ','.join(['='.join([k, v]) for k, v in dic.items()])

0 comments on commit 1407e45

Please sign in to comment.