Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_codes_keys_iterator():
grib = bindings.codes_grib_new_from_file(open(TEST_DATA))
iterator = bindings.codes_keys_iterator_new(grib)
assert bindings.codes_keys_iterator_next(iterator) == 1
assert bindings.codes_keys_iterator_get_name(iterator) == 'globalDomain'
assert bindings.codes_keys_iterator_next(iterator) == 1
assert bindings.codes_keys_iterator_get_name(iterator) == 'GRIBEditionNumber'
bindings.codes_keys_iterator_delete(iterator)
iterator = bindings.codes_keys_iterator_new(grib, namespace='time')
assert bindings.codes_keys_iterator_next(iterator) == 1
assert bindings.codes_keys_iterator_get_name(iterator) == 'dataDate'
assert bindings.codes_keys_iterator_next(iterator) == 1
assert bindings.codes_keys_iterator_get_name(iterator) == 'dataTime'
bindings.codes_keys_iterator_delete(iterator)
def test_codes_keys_iterator():
grib = bindings.codes_grib_new_from_file(open(TEST_DATA))
iterator = bindings.codes_keys_iterator_new(grib)
assert bindings.codes_keys_iterator_next(iterator) == 1
assert bindings.codes_keys_iterator_get_name(iterator) == 'globalDomain'
assert bindings.codes_keys_iterator_next(iterator) == 1
assert bindings.codes_keys_iterator_get_name(iterator) == 'GRIBEditionNumber'
bindings.codes_keys_iterator_delete(iterator)
iterator = bindings.codes_keys_iterator_new(grib, namespace='time')
assert bindings.codes_keys_iterator_next(iterator) == 1
assert bindings.codes_keys_iterator_get_name(iterator) == 'dataDate'
assert bindings.codes_keys_iterator_next(iterator) == 1
assert bindings.codes_keys_iterator_get_name(iterator) == 'dataTime'
bindings.codes_keys_iterator_delete(iterator)
def message_grib_keys(self, namespace=None):
# type: (str) -> T.Generator[str, None, None]
iterator = eccodes.codes_keys_iterator_new(self.codes_id, namespace=namespace)
while eccodes.codes_keys_iterator_next(iterator):
yield eccodes.codes_keys_iterator_get_name(iterator)
eccodes.codes_keys_iterator_delete(iterator)