mirror of https://github.com/ecmwf/eccodes.git
ECC-866: Python3: codes_gts_new_from_file does not return all GTS bulletins
This commit is contained in:
parent
6fece32386
commit
48313c1ebd
|
@ -1327,19 +1327,26 @@ int grib_c_count_in_file(FILE* f,int* n)
|
|||
return err;
|
||||
}
|
||||
|
||||
int grib_c_new_gts_from_file(FILE* f,int headers_only, int* gid)
|
||||
int grib_c_new_gts_from_file(FILE* f, int fd, char* fname, int headers_only, int* gid)
|
||||
{
|
||||
grib_handle *h = NULL;
|
||||
int err = 0;
|
||||
|
||||
if(f){
|
||||
h = gts_new_from_file(0,f,&err);
|
||||
FILE* p = retrieve_file_info(fd);
|
||||
if (p) {
|
||||
h = gts_new_from_file(0,p,&err); //use cached value
|
||||
} else {
|
||||
h = gts_new_from_file(0,f,&err); //use FILE pointer passed in
|
||||
store_file_info(fd, f); //store it for next time
|
||||
}
|
||||
|
||||
if(h){
|
||||
push_handle(h,gid);
|
||||
return GRIB_SUCCESS;
|
||||
} else {
|
||||
*gid=-1;
|
||||
clear_file_info(fd);
|
||||
return GRIB_END_OF_FILE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ int codes_c_close_file(int fd, char* fname);
|
|||
int grib_c_new_from_file(FILE *f, int fd, char* fname, int *gid, int headers_only);
|
||||
int grib_c_new_any_from_file(FILE *f, int fd, char* fname, int headers_only,int *gid);
|
||||
int grib_c_new_bufr_from_file(FILE *f, int fd, char* fname, int headers_only,int *gid);
|
||||
int grib_c_new_gts_from_file(FILE *f, int fd, char* fname, int headers_only, int *gid);
|
||||
|
||||
int grib_c_new_gts_from_file(FILE *f,int headers_only, int *gid);
|
||||
int grib_c_new_metar_from_file(FILE* f,int headers_only, int* gid);
|
||||
int grib_c_new_from_index(int *iid, int *gid);
|
||||
int grib_c_index_new_from_file(char *file, char *keys, int *gid);
|
||||
|
|
|
@ -157,7 +157,9 @@ def gts_new_from_file(fileobj, headers_only=False):
|
|||
@return id of the GTS loaded in memory
|
||||
@exception GribInternalError
|
||||
"""
|
||||
err, gtsid = _internal.grib_c_new_gts_from_file(fileobj, headers_only, 0)
|
||||
fd = fileobj.fileno()
|
||||
fn = fileobj.name
|
||||
err, gtsid = _internal.grib_c_new_gts_from_file(fileobj, fd, fn, headers_only, 0)
|
||||
if err:
|
||||
if err == _internal.GRIB_END_OF_FILE:
|
||||
return None
|
||||
|
|
|
@ -44,7 +44,7 @@ import_array();
|
|||
int grib_c_new_from_file(FILE* f, int fd, char* fname, int* INOUT, int headers_only);
|
||||
int grib_c_new_any_from_file(FILE* f, int fd, char* fname, int headers_only, int* INOUT);
|
||||
int grib_c_new_bufr_from_file(FILE* f, int fd, char* fname, int headers_only, int* INOUT);
|
||||
int grib_c_new_gts_from_file(FILE* f, int headers_only, int* INOUT);
|
||||
int grib_c_new_gts_from_file(FILE* f, int fd, char* fname, int headers_only, int* INOUT);
|
||||
int grib_c_new_metar_from_file(FILE* f, int headers_only, int* INOUT);
|
||||
int grib_c_iterator_new(int* INPUT, int* OUTPUT, int* INPUT);
|
||||
int grib_c_keys_iterator_new(int* INPUT, int* OUTPUT, char* name_space);
|
||||
|
|
|
@ -5492,17 +5492,26 @@ SWIGINTERN PyObject *_wrap_grib_c_new_gts_from_file(PyObject *SWIGUNUSEDPARM(sel
|
|||
PyObject *resultobj = 0;
|
||||
FILE *arg1 = (FILE *) 0 ;
|
||||
int arg2 ;
|
||||
int *arg3 = (int *) 0 ;
|
||||
char *arg3 = (char *) 0 ;
|
||||
int arg4 ;
|
||||
int *arg5 = (int *) 0 ;
|
||||
int val2 ;
|
||||
int ecode2 = 0 ;
|
||||
int temp3 ;
|
||||
int res3 = 0 ;
|
||||
int res3 ;
|
||||
char *buf3 = 0 ;
|
||||
int alloc3 = 0 ;
|
||||
int val4 ;
|
||||
int ecode4 = 0 ;
|
||||
int temp5 ;
|
||||
int res5 = 0 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
PyObject * obj1 = 0 ;
|
||||
PyObject * obj2 = 0 ;
|
||||
PyObject * obj3 = 0 ;
|
||||
PyObject * obj4 = 0 ;
|
||||
int result;
|
||||
|
||||
if (!PyArg_ParseTuple(args,(char *)"OOO:grib_c_new_gts_from_file",&obj0,&obj1,&obj2)) SWIG_fail;
|
||||
if (!PyArg_ParseTuple(args,(char *)"OOOOO:grib_c_new_gts_from_file",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
|
||||
{
|
||||
int fileDescriptor = PyObject_AsFileDescriptor(obj0);
|
||||
/*printf("swig.i fileDescriptor=%d\n", fileDescriptor);*/
|
||||
|
@ -5520,26 +5529,38 @@ SWIGINTERN PyObject *_wrap_grib_c_new_gts_from_file(PyObject *SWIGUNUSEDPARM(sel
|
|||
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "grib_c_new_gts_from_file" "', argument " "2"" of type '" "int""'");
|
||||
}
|
||||
arg2 = (int)(val2);
|
||||
if (!(SWIG_IsOK((res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3),SWIGTYPE_p_int,0))))) {
|
||||
res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
|
||||
if (!SWIG_IsOK(res3)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "grib_c_new_gts_from_file" "', argument " "3"" of type '" "char *""'");
|
||||
}
|
||||
arg3 = (char *)(buf3);
|
||||
ecode4 = SWIG_AsVal_int(obj3, &val4);
|
||||
if (!SWIG_IsOK(ecode4)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "grib_c_new_gts_from_file" "', argument " "4"" of type '" "int""'");
|
||||
}
|
||||
arg4 = (int)(val4);
|
||||
if (!(SWIG_IsOK((res5 = SWIG_ConvertPtr(obj4,SWIG_as_voidptrptr(&arg5),SWIGTYPE_p_int,0))))) {
|
||||
int val;
|
||||
int ecode = SWIG_AsVal_int(obj2, &val);
|
||||
int ecode = SWIG_AsVal_int(obj4, &val);
|
||||
if (!SWIG_IsOK(ecode)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "grib_c_new_gts_from_file" "', argument " "3"" of type '" "int""'");
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "grib_c_new_gts_from_file" "', argument " "5"" of type '" "int""'");
|
||||
}
|
||||
temp3 = (int)(val);
|
||||
arg3 = &temp3;
|
||||
res3 = SWIG_AddTmpMask(ecode);
|
||||
temp5 = (int)(val);
|
||||
arg5 = &temp5;
|
||||
res5 = SWIG_AddTmpMask(ecode);
|
||||
}
|
||||
result = (int)grib_c_new_gts_from_file(arg1,arg2,arg3);
|
||||
result = (int)grib_c_new_gts_from_file(arg1,arg2,arg3,arg4,arg5);
|
||||
resultobj = SWIG_From_int((int)(result));
|
||||
if (SWIG_IsTmpObj(res3)) {
|
||||
resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3)));
|
||||
if (SWIG_IsTmpObj(res5)) {
|
||||
resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg5)));
|
||||
} else {
|
||||
int new_flags = SWIG_IsNewObj(res3) ? (SWIG_POINTER_OWN | 0 ) : 0 ;
|
||||
resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_int, new_flags));
|
||||
int new_flags = SWIG_IsNewObj(res5) ? (SWIG_POINTER_OWN | 0 ) : 0 ;
|
||||
resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg5), SWIGTYPE_p_int, new_flags));
|
||||
}
|
||||
if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
|
||||
return resultobj;
|
||||
fail:
|
||||
if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -387,8 +387,8 @@ def grib_c_new_bufr_from_file(f: 'FILE *', fd: 'int', fname: 'char *', headers_o
|
|||
return _gribapi_swig.grib_c_new_bufr_from_file(f, fd, fname, headers_only, INOUT)
|
||||
grib_c_new_bufr_from_file = _gribapi_swig.grib_c_new_bufr_from_file
|
||||
|
||||
def grib_c_new_gts_from_file(f: 'FILE *', headers_only: 'int', INOUT: 'int *') -> "int *":
|
||||
return _gribapi_swig.grib_c_new_gts_from_file(f, headers_only, INOUT)
|
||||
def grib_c_new_gts_from_file(f: 'FILE *', fd: 'int', fname: 'char *', headers_only: 'int', INOUT: 'int *') -> "int *":
|
||||
return _gribapi_swig.grib_c_new_gts_from_file(f, fd, fname, headers_only, INOUT)
|
||||
grib_c_new_gts_from_file = _gribapi_swig.grib_c_new_gts_from_file
|
||||
|
||||
def grib_c_new_metar_from_file(f: 'FILE *', headers_only: 'int', INOUT: 'int *') -> "int *":
|
||||
|
|
Loading…
Reference in New Issue