mirror of https://github.com/ecmwf/eccodes.git
ECC-283: Add functions to Python interface
This commit is contained in:
parent
aa9a5f868c
commit
366bd1ff3d
|
@ -3,5 +3,5 @@
|
||||||
. ./include.sh
|
. ./include.sh
|
||||||
|
|
||||||
REDIRECT=/dev/null
|
REDIRECT=/dev/null
|
||||||
$PYTHON $examples_src/samples.py 2> $REDIRECT > $REDIRECT
|
$PYTHON $examples_src/samples.py
|
||||||
rm -f out.samples.grib || true
|
rm -f out.samples.grib
|
||||||
|
|
|
@ -92,5 +92,7 @@ from gribapi import grib_gts_header as codes_gts_header
|
||||||
from gribapi import grib_get_api_version as codes_get_api_version
|
from gribapi import grib_get_api_version as codes_get_api_version
|
||||||
from gribapi import grib_get_message as codes_get_message
|
from gribapi import grib_get_message as codes_get_message
|
||||||
from gribapi import grib_new_from_message as codes_new_from_message
|
from gribapi import grib_new_from_message as codes_new_from_message
|
||||||
|
from gribapi import grib_set_definitions_path as codes_set_definitions_path
|
||||||
|
from gribapi import grib_set_samples_path as codes_set_samples_path
|
||||||
|
|
||||||
from gribapi import GribInternalError as CodesInternalError
|
from gribapi import GribInternalError as CodesInternalError
|
||||||
|
|
|
@ -2114,3 +2114,15 @@ int grib_c_get_message(int *gid, const void **msg, size_t *size)
|
||||||
grib_handle *h = get_handle(*gid);
|
grib_handle *h = get_handle(*gid);
|
||||||
return grib_get_message(h,msg,size);
|
return grib_get_message(h,msg,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void grib_c_set_definitions_path(const char* path)
|
||||||
|
{
|
||||||
|
grib_context *c = grib_context_get_default();
|
||||||
|
grib_context_set_definitions_path(c, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void grib_c_set_samples_path(const char* path)
|
||||||
|
{
|
||||||
|
grib_context *c = grib_context_get_default();
|
||||||
|
grib_context_set_samples_path(c, path);
|
||||||
|
}
|
||||||
|
|
|
@ -108,5 +108,7 @@ void grib_c_gts_header_on(void);
|
||||||
void grib_c_gts_header_off(void);
|
void grib_c_gts_header_off(void);
|
||||||
int grib_c_get_message(int *gid, const void **msg, size_t *size);
|
int grib_c_get_message(int *gid, const void **msg, size_t *size);
|
||||||
int grib_c_get_string_length(int* gid, char* key, size_t* val);
|
int grib_c_get_string_length(int* gid, char* key, size_t* val);
|
||||||
|
void grib_c_set_definitions_path(const char* path);
|
||||||
|
void grib_c_set_samples_path(const char* path);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1868,3 +1868,24 @@ def grib_new_from_message(message):
|
||||||
error, gribid = _internal.grib_c_new_from_message(0, message, len(message))
|
error, gribid = _internal.grib_c_new_from_message(0, message, len(message))
|
||||||
GRIB_CHECK(error)
|
GRIB_CHECK(error)
|
||||||
return gribid
|
return gribid
|
||||||
|
|
||||||
|
|
||||||
|
@require(defs_path=str)
|
||||||
|
def grib_set_definitions_path(defs_path):
|
||||||
|
"""
|
||||||
|
@brief Set the definitions path
|
||||||
|
|
||||||
|
@param defs_path definitions path
|
||||||
|
"""
|
||||||
|
_internal.grib_c_set_definitions_path(defs_path)
|
||||||
|
|
||||||
|
|
||||||
|
@require(samples_path=str)
|
||||||
|
def grib_set_samples_path(samples_path):
|
||||||
|
"""
|
||||||
|
@brief Set the samples path
|
||||||
|
|
||||||
|
@param samples_path samples path
|
||||||
|
"""
|
||||||
|
_internal.grib_c_set_samples_path(samples_path)
|
||||||
|
|
||||||
|
|
|
@ -212,3 +212,5 @@ void no_fail_on_wrong_length(int flag);
|
||||||
long grib_c_get_api_version();
|
long grib_c_get_api_version();
|
||||||
void grib_c_gts_header_on();
|
void grib_c_gts_header_on();
|
||||||
void grib_c_gts_header_off();
|
void grib_c_gts_header_off();
|
||||||
|
void grib_c_set_definitions_path(const char* path);
|
||||||
|
void grib_c_set_samples_path(const char* path);
|
||||||
|
|
|
@ -7807,6 +7807,54 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWIGINTERN PyObject *_wrap_grib_c_set_definitions_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||||
|
PyObject *resultobj = 0;
|
||||||
|
char *arg1 = (char *) 0 ;
|
||||||
|
int res1 ;
|
||||||
|
char *buf1 = 0 ;
|
||||||
|
int alloc1 = 0 ;
|
||||||
|
PyObject * obj0 = 0 ;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args,(char *)"O:grib_c_set_definitions_path",&obj0)) SWIG_fail;
|
||||||
|
res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
|
||||||
|
if (!SWIG_IsOK(res1)) {
|
||||||
|
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "grib_c_set_definitions_path" "', argument " "1"" of type '" "char const *""'");
|
||||||
|
}
|
||||||
|
arg1 = (char *)(buf1);
|
||||||
|
grib_c_set_definitions_path((char const *)arg1);
|
||||||
|
resultobj = SWIG_Py_Void();
|
||||||
|
if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
|
||||||
|
return resultobj;
|
||||||
|
fail:
|
||||||
|
if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWIGINTERN PyObject *_wrap_grib_c_set_samples_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||||
|
PyObject *resultobj = 0;
|
||||||
|
char *arg1 = (char *) 0 ;
|
||||||
|
int res1 ;
|
||||||
|
char *buf1 = 0 ;
|
||||||
|
int alloc1 = 0 ;
|
||||||
|
PyObject * obj0 = 0 ;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args,(char *)"O:grib_c_set_samples_path",&obj0)) SWIG_fail;
|
||||||
|
res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
|
||||||
|
if (!SWIG_IsOK(res1)) {
|
||||||
|
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "grib_c_set_samples_path" "', argument " "1"" of type '" "char const *""'");
|
||||||
|
}
|
||||||
|
arg1 = (char *)(buf1);
|
||||||
|
grib_c_set_samples_path((char const *)arg1);
|
||||||
|
resultobj = SWIG_Py_Void();
|
||||||
|
if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
|
||||||
|
return resultobj;
|
||||||
|
fail:
|
||||||
|
if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyMethodDef SwigMethods[] = {
|
static PyMethodDef SwigMethods[] = {
|
||||||
{ (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
|
{ (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
|
||||||
{ (char *)"cdata", _wrap_cdata, METH_VARARGS, NULL},
|
{ (char *)"cdata", _wrap_cdata, METH_VARARGS, NULL},
|
||||||
|
@ -7932,6 +7980,8 @@ static PyMethodDef SwigMethods[] = {
|
||||||
{ (char *)"grib_c_get_api_version", _wrap_grib_c_get_api_version, METH_VARARGS, NULL},
|
{ (char *)"grib_c_get_api_version", _wrap_grib_c_get_api_version, METH_VARARGS, NULL},
|
||||||
{ (char *)"grib_c_gts_header_on", _wrap_grib_c_gts_header_on, METH_VARARGS, NULL},
|
{ (char *)"grib_c_gts_header_on", _wrap_grib_c_gts_header_on, METH_VARARGS, NULL},
|
||||||
{ (char *)"grib_c_gts_header_off", _wrap_grib_c_gts_header_off, METH_VARARGS, NULL},
|
{ (char *)"grib_c_gts_header_off", _wrap_grib_c_gts_header_off, METH_VARARGS, NULL},
|
||||||
|
{ (char *)"grib_c_set_definitions_path", _wrap_grib_c_set_definitions_path, METH_VARARGS, NULL},
|
||||||
|
{ (char *)"grib_c_set_samples_path", _wrap_grib_c_set_samples_path, METH_VARARGS, NULL},
|
||||||
{ NULL, NULL, 0, NULL }
|
{ NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8662,6 +8712,7 @@ SWIG_init(void) {
|
||||||
SWIG_Python_SetConstant(d, "GRIB_TOO_MANY_ATTRIBUTES",SWIG_From_int((int)(-62)));
|
SWIG_Python_SetConstant(d, "GRIB_TOO_MANY_ATTRIBUTES",SWIG_From_int((int)(-62)));
|
||||||
SWIG_Python_SetConstant(d, "GRIB_ATTRIBUTE_NOT_FOUND",SWIG_From_int((int)(-63)));
|
SWIG_Python_SetConstant(d, "GRIB_ATTRIBUTE_NOT_FOUND",SWIG_From_int((int)(-63)));
|
||||||
SWIG_Python_SetConstant(d, "GRIB_UNSUPPORTED_EDITION",SWIG_From_int((int)(-64)));
|
SWIG_Python_SetConstant(d, "GRIB_UNSUPPORTED_EDITION",SWIG_From_int((int)(-64)));
|
||||||
|
SWIG_Python_SetConstant(d, "GRIB_OUT_OF_RANGE",SWIG_From_int((int)(-65)));
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
return m;
|
return m;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -139,6 +139,7 @@ GRIB_ATTRIBUTE_CLASH = _gribapi_swig.GRIB_ATTRIBUTE_CLASH
|
||||||
GRIB_TOO_MANY_ATTRIBUTES = _gribapi_swig.GRIB_TOO_MANY_ATTRIBUTES
|
GRIB_TOO_MANY_ATTRIBUTES = _gribapi_swig.GRIB_TOO_MANY_ATTRIBUTES
|
||||||
GRIB_ATTRIBUTE_NOT_FOUND = _gribapi_swig.GRIB_ATTRIBUTE_NOT_FOUND
|
GRIB_ATTRIBUTE_NOT_FOUND = _gribapi_swig.GRIB_ATTRIBUTE_NOT_FOUND
|
||||||
GRIB_UNSUPPORTED_EDITION = _gribapi_swig.GRIB_UNSUPPORTED_EDITION
|
GRIB_UNSUPPORTED_EDITION = _gribapi_swig.GRIB_UNSUPPORTED_EDITION
|
||||||
|
GRIB_OUT_OF_RANGE = _gribapi_swig.GRIB_OUT_OF_RANGE
|
||||||
class intp(_object):
|
class intp(_object):
|
||||||
__swig_setmethods__ = {}
|
__swig_setmethods__ = {}
|
||||||
__setattr__ = lambda self, name, value: _swig_setattr(self, intp, name, value)
|
__setattr__ = lambda self, name, value: _swig_setattr(self, intp, name, value)
|
||||||
|
@ -608,4 +609,12 @@ def grib_c_gts_header_off():
|
||||||
return _gribapi_swig.grib_c_gts_header_off()
|
return _gribapi_swig.grib_c_gts_header_off()
|
||||||
grib_c_gts_header_off = _gribapi_swig.grib_c_gts_header_off
|
grib_c_gts_header_off = _gribapi_swig.grib_c_gts_header_off
|
||||||
|
|
||||||
|
def grib_c_set_definitions_path(*args):
|
||||||
|
return _gribapi_swig.grib_c_set_definitions_path(*args)
|
||||||
|
grib_c_set_definitions_path = _gribapi_swig.grib_c_set_definitions_path
|
||||||
|
|
||||||
|
def grib_c_set_samples_path(*args):
|
||||||
|
return _gribapi_swig.grib_c_set_samples_path(*args)
|
||||||
|
grib_c_set_samples_path = _gribapi_swig.grib_c_set_samples_path
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8631,6 +8631,54 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWIGINTERN PyObject *_wrap_grib_c_set_definitions_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||||
|
PyObject *resultobj = 0;
|
||||||
|
char *arg1 = (char *) 0 ;
|
||||||
|
int res1 ;
|
||||||
|
char *buf1 = 0 ;
|
||||||
|
int alloc1 = 0 ;
|
||||||
|
PyObject * obj0 = 0 ;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args,(char *)"O:grib_c_set_definitions_path",&obj0)) SWIG_fail;
|
||||||
|
res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
|
||||||
|
if (!SWIG_IsOK(res1)) {
|
||||||
|
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "grib_c_set_definitions_path" "', argument " "1"" of type '" "char const *""'");
|
||||||
|
}
|
||||||
|
arg1 = (char *)(buf1);
|
||||||
|
grib_c_set_definitions_path((char const *)arg1);
|
||||||
|
resultobj = SWIG_Py_Void();
|
||||||
|
if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
|
||||||
|
return resultobj;
|
||||||
|
fail:
|
||||||
|
if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWIGINTERN PyObject *_wrap_grib_c_set_samples_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||||
|
PyObject *resultobj = 0;
|
||||||
|
char *arg1 = (char *) 0 ;
|
||||||
|
int res1 ;
|
||||||
|
char *buf1 = 0 ;
|
||||||
|
int alloc1 = 0 ;
|
||||||
|
PyObject * obj0 = 0 ;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args,(char *)"O:grib_c_set_samples_path",&obj0)) SWIG_fail;
|
||||||
|
res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
|
||||||
|
if (!SWIG_IsOK(res1)) {
|
||||||
|
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "grib_c_set_samples_path" "', argument " "1"" of type '" "char const *""'");
|
||||||
|
}
|
||||||
|
arg1 = (char *)(buf1);
|
||||||
|
grib_c_set_samples_path((char const *)arg1);
|
||||||
|
resultobj = SWIG_Py_Void();
|
||||||
|
if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
|
||||||
|
return resultobj;
|
||||||
|
fail:
|
||||||
|
if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyMethodDef SwigMethods[] = {
|
static PyMethodDef SwigMethods[] = {
|
||||||
{ (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
|
{ (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
|
||||||
{ (char *)"cdata", _wrap_cdata, METH_VARARGS, NULL},
|
{ (char *)"cdata", _wrap_cdata, METH_VARARGS, NULL},
|
||||||
|
@ -8762,6 +8810,8 @@ static PyMethodDef SwigMethods[] = {
|
||||||
{ (char *)"grib_c_get_api_version", _wrap_grib_c_get_api_version, METH_VARARGS, NULL},
|
{ (char *)"grib_c_get_api_version", _wrap_grib_c_get_api_version, METH_VARARGS, NULL},
|
||||||
{ (char *)"grib_c_gts_header_on", _wrap_grib_c_gts_header_on, METH_VARARGS, NULL},
|
{ (char *)"grib_c_gts_header_on", _wrap_grib_c_gts_header_on, METH_VARARGS, NULL},
|
||||||
{ (char *)"grib_c_gts_header_off", _wrap_grib_c_gts_header_off, METH_VARARGS, NULL},
|
{ (char *)"grib_c_gts_header_off", _wrap_grib_c_gts_header_off, METH_VARARGS, NULL},
|
||||||
|
{ (char *)"grib_c_set_definitions_path", _wrap_grib_c_set_definitions_path, METH_VARARGS, NULL},
|
||||||
|
{ (char *)"grib_c_set_samples_path", _wrap_grib_c_set_samples_path, METH_VARARGS, NULL},
|
||||||
{ NULL, NULL, 0, NULL }
|
{ NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9492,6 +9542,7 @@ SWIG_init(void) {
|
||||||
SWIG_Python_SetConstant(d, "GRIB_TOO_MANY_ATTRIBUTES",SWIG_From_int((int)(-62)));
|
SWIG_Python_SetConstant(d, "GRIB_TOO_MANY_ATTRIBUTES",SWIG_From_int((int)(-62)));
|
||||||
SWIG_Python_SetConstant(d, "GRIB_ATTRIBUTE_NOT_FOUND",SWIG_From_int((int)(-63)));
|
SWIG_Python_SetConstant(d, "GRIB_ATTRIBUTE_NOT_FOUND",SWIG_From_int((int)(-63)));
|
||||||
SWIG_Python_SetConstant(d, "GRIB_UNSUPPORTED_EDITION",SWIG_From_int((int)(-64)));
|
SWIG_Python_SetConstant(d, "GRIB_UNSUPPORTED_EDITION",SWIG_From_int((int)(-64)));
|
||||||
|
SWIG_Python_SetConstant(d, "GRIB_OUT_OF_RANGE",SWIG_From_int((int)(-65)));
|
||||||
|
|
||||||
import_array();
|
import_array();
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,7 @@ GRIB_ATTRIBUTE_CLASH = _gribapi_swig.GRIB_ATTRIBUTE_CLASH
|
||||||
GRIB_TOO_MANY_ATTRIBUTES = _gribapi_swig.GRIB_TOO_MANY_ATTRIBUTES
|
GRIB_TOO_MANY_ATTRIBUTES = _gribapi_swig.GRIB_TOO_MANY_ATTRIBUTES
|
||||||
GRIB_ATTRIBUTE_NOT_FOUND = _gribapi_swig.GRIB_ATTRIBUTE_NOT_FOUND
|
GRIB_ATTRIBUTE_NOT_FOUND = _gribapi_swig.GRIB_ATTRIBUTE_NOT_FOUND
|
||||||
GRIB_UNSUPPORTED_EDITION = _gribapi_swig.GRIB_UNSUPPORTED_EDITION
|
GRIB_UNSUPPORTED_EDITION = _gribapi_swig.GRIB_UNSUPPORTED_EDITION
|
||||||
|
GRIB_OUT_OF_RANGE = _gribapi_swig.GRIB_OUT_OF_RANGE
|
||||||
class intp(_object):
|
class intp(_object):
|
||||||
__swig_setmethods__ = {}
|
__swig_setmethods__ = {}
|
||||||
__setattr__ = lambda self, name, value: _swig_setattr(self, intp, name, value)
|
__setattr__ = lambda self, name, value: _swig_setattr(self, intp, name, value)
|
||||||
|
@ -632,4 +633,12 @@ def grib_c_gts_header_off():
|
||||||
return _gribapi_swig.grib_c_gts_header_off()
|
return _gribapi_swig.grib_c_gts_header_off()
|
||||||
grib_c_gts_header_off = _gribapi_swig.grib_c_gts_header_off
|
grib_c_gts_header_off = _gribapi_swig.grib_c_gts_header_off
|
||||||
|
|
||||||
|
def grib_c_set_definitions_path(*args):
|
||||||
|
return _gribapi_swig.grib_c_set_definitions_path(*args)
|
||||||
|
grib_c_set_definitions_path = _gribapi_swig.grib_c_set_definitions_path
|
||||||
|
|
||||||
|
def grib_c_set_samples_path(*args):
|
||||||
|
return _gribapi_swig.grib_c_set_samples_path(*args)
|
||||||
|
grib_c_set_samples_path = _gribapi_swig.grib_c_set_samples_path
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue