[cmor] 70/190: 2010-11-05 : file_name=True ignored in python if no var_id is passed to it as well.

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository cmor.

commit 9d539375a8ff740e7f0349b374789e60d3c68aaf
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date:   Fri Nov 5 16:48:05 2010 -0700

    2010-11-05 : file_name=True ignored in python if no var_id is passed to it as well.
---
 Lib/pywrapper.py                       |  4 ++--
 RELEASE-NOTES                          |  1 +
 Src/_cmormodule.c                      | 12 +++++++-----
 Test/test_python_jamie_site_surface.py |  2 +-
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/Lib/pywrapper.py b/Lib/pywrapper.py
index e469e8e..00be0b1 100644
--- a/Lib/pywrapper.py
+++ b/Lib/pywrapper.py
@@ -839,11 +839,11 @@ def close(var_id=None,file_name=False, preserve=False):
       cmor.close(varid=None)
     Where:
       var_id: id of variable to close, if passing None, means close every open ones.
-      [file_name] True/False (default False) if True: return name of the file just closed
+      [file_name] True/False (default False) if True: return name of the file just closed, works only if var_id is not None
       [preserve] True/False (default False) if True: close the file but preserve the var definition in CMOR to write more data with this variable (into a new file)
       """
     if var_id is not None and not isinstance(var_id,int):
-        raise Exception, "Error var_id must be none or a integer"
+        raise Exception, "Error var_id must be None or a integer"
 
     if (preserve is False):
         if (file_name is False):
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 4c15f2b..000953f 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -1,3 +1,4 @@
+2010-11-05 : file_name=True ignored in python if no var_id is passed to it as well.
 2010-11-05 : added realm to gridspec file names
 2010-11-05 : reverted ext_cell_measures to cell_measures
 2010-10-27 : edited the test for permission on output directory, used to fail if you had group write privileges but that wasnt your main group
diff --git a/Src/_cmormodule.c b/Src/_cmormodule.c
index 9a09f85..3ff4bc1 100644
--- a/Src/_cmormodule.c
+++ b/Src/_cmormodule.c
@@ -632,24 +632,26 @@ static PyObject *
   PyCMOR_close(PyObject *self,PyObject *args)
 {
   PyObject *var;
-  PyObject *file;
-  PyObject *preserve;
   int varid,ierr;
   int dofile=0;
   int dopreserve=0;
   int preserved_id;
   char file_name[CMOR_MAX_STRING];
-  if (!PyArg_ParseTuple(args,"OOO",&var,&file,&preserve)) {
+  if (!PyArg_ParseTuple(args,"Oii",&var,&dofile,&dopreserve)) {
     return NULL;
   }
   
   if (var == Py_None ) {
     ierr = cmor_close();
+    if (ierr!=0) {
+      return NULL;
+    }
+    else {
+      return Py_BuildValue("i",ierr);
+    }
   }
   else {
     varid = (int)PyInt_AsLong(var);
-    dofile =(int)PyInt_AsLong(file);
-    dopreserve =(int)PyInt_AsLong(preserve);
 
     if (dopreserve==1) {
       if (dofile==1) { 
diff --git a/Test/test_python_jamie_site_surface.py b/Test/test_python_jamie_site_surface.py
index f1cd556..b68037e 100644
--- a/Test/test_python_jamie_site_surface.py
+++ b/Test/test_python_jamie_site_surface.py
@@ -58,7 +58,7 @@ def main():
     cmor_initialisation()
     values, axes = setup_data()
     cmor_define_and_write(values, axes)
-    cmor.close()
+    print cmor.close(file_name=True)
     
 if __name__ == '__main__':
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cmor.git



More information about the debian-science-commits mailing list