[cmor] 146/190: WIP: iterate on python3 patch. Disable building python3 mods for the moment

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:48 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 999b07016b1b33f5a344497d7ad961a9bbbc865b
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Wed Jun 12 13:33:07 2013 +0100

    WIP: iterate on python3 patch. Disable building python3 mods for the moment
---
 debian/patches/python3.patch | 411 ++++++++++++++++++++++++++++++++++---------
 debian/rules                 |   2 +-
 2 files changed, 331 insertions(+), 82 deletions(-)

diff --git a/debian/patches/python3.patch b/debian/patches/python3.patch
index e0e3976..484122c 100644
--- a/debian/patches/python3.patch
+++ b/debian/patches/python3.patch
@@ -5,8 +5,8 @@ Forwarded: no
 
 Index: cmor-2.8.3/Lib/git2svn.py
 ===================================================================
---- cmor-2.8.3.orig/Lib/git2svn.py	2013-06-12 12:04:17.000000000 +0100
-+++ cmor-2.8.3/Lib/git2svn.py	2013-06-12 12:04:21.000000000 +0100
+--- cmor-2.8.3.orig/Lib/git2svn.py	2013-06-12 12:22:15.000000000 +0100
++++ cmor-2.8.3/Lib/git2svn.py	2013-06-12 12:22:21.000000000 +0100
 @@ -1,5 +1,7 @@
  import os,sys
  
@@ -36,9 +36,14 @@ Index: cmor-2.8.3/Lib/git2svn.py
      os.popen(cmd).readlines()
 Index: cmor-2.8.3/Lib/pywrapper.py
 ===================================================================
---- cmor-2.8.3.orig/Lib/pywrapper.py	2013-06-12 12:04:17.000000000 +0100
-+++ cmor-2.8.3/Lib/pywrapper.py	2013-06-12 12:04:21.000000000 +0100
-@@ -37,25 +37,25 @@
+--- cmor-2.8.3.orig/Lib/pywrapper.py	2013-06-12 12:22:15.000000000 +0100
++++ cmor-2.8.3/Lib/pywrapper.py	2013-06-12 13:17:10.000000000 +0100
+@@ -1,4 +1,3 @@
+-
+ import cmor_const,numpy,os,_cmor
+ 
+ try:
+@@ -37,25 +36,25 @@
      missing_value : scalar that is used to indicate missing data for this variable.  It must be the same type as the data that will be passed to cmor_write.  This missing_value will in general be replaced by a standard missing_value specified in the MIP table.  If there are no missing data, and the user chooses not to declare the missing value, then this argument may be either omitted or assigned the value 'none' (i.e., missing_value='none').
      """
      if not isinstance(table_entry,str):
@@ -70,7 +75,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
          missing_value = float(missing_value)
          
      return _cmor.time_varying_grid_coordinate(grid_id,table_entry,units,type,missing_value)
-@@ -68,7 +68,7 @@
+@@ -68,7 +67,7 @@
          try:
              vals = numpy.ascontiguousarray(vals.filled())
          except:
@@ -79,7 +84,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
          
      return vals
  
-@@ -92,32 +92,32 @@
+@@ -92,32 +91,32 @@
      elif isinstance(axis_ids,(list,tuple)):
          axis_ids = numpy.ascontiguousarray(axis_ids)
      elif not isinstance(axis_ids, numpy.ndarray):
@@ -119,7 +124,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
      else:
          type='f'
          if nvertices is None :
-@@ -129,19 +129,19 @@
+@@ -129,19 +128,19 @@
          latitude_vertices = _to_numpy(latitude_vertices, 'latitude_vertices')
  
          if numpy.rank(latitude_vertices)!=len(axis_ids)+1:
@@ -143,7 +148,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  ##         print 'longitude_vert type:',longitude_vertices.dtype.char
          if longitude_vertices.dtype.char!=type:
              longitude_vertices = longitude_vertices.astype(type)
-@@ -149,10 +149,10 @@
+@@ -149,10 +148,10 @@
          if latitude_vertices is None:
              nvert = nvert2
          elif nvert!=nvert2:
@@ -156,7 +161,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
          
  ##     if area is not None:
-@@ -160,9 +160,9 @@
+@@ -160,9 +159,9 @@
  ##             try:
  ##                 area = numpy.ascontiguousarray(area.filled())
  ##             except:
@@ -168,21 +173,35 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  ##         if area.dtype.char!=type:
  ##             area = area.astype(type)
      n = len(axis_ids)
-@@ -182,9 +182,9 @@
+@@ -181,27 +180,33 @@
+        parameter_values :: array/list of parameter values in the same order of parameter_names (ignored if parameter_names is ditcionary)
         parameter_units  :: array/list of parameter units  in the same order of parameter_names (ignored if parameter_names is ditcionary)
      """
-     if not isinstance(grid_id,(numpy.int32,int,long)):
+-    if not isinstance(grid_id,(numpy.int32,int,long)):
 -        raise Exception, "grid_id must be an integer: %s"%type(grid_id)
-+        raise Exception("grid_id must be an integer: %s"%type(grid_id))
++    try:
++        # Python2
++        if not isinstance(grid_id,(numpy.int32,int,long)):
++            raise Exception("grid_id must be an integer: %s"%type(grid_id))
++    except NameError:
++        # Python3
++        if not isinstance(grid_id,(numpy.int32,int)):
++            raise Exception("grid_id must be an integer: %s"%type(grid_id))
      if not isinstance(mapping_name,str):
 -        raise Exception, "mapping name must be a string"
 +        raise Exception("mapping name must be a string")
  
      if isinstance(parameter_names,dict):
          pnams = []
-@@ -196,12 +196,12 @@
+         pvals = []
+         punit = []
+-        for k in parameter_names.keys():
++        for k in list(parameter_names.keys()):
+             pnams.append(k)
+             val = parameter_names[k]
              if isinstance(val,dict):
-                 ks = val.keys()
+-                ks = val.keys()
++                ks = list(val.keys())
                  if not 'value' in ks or not 'units' in ks:
 -                    raise Exception, "error parameter_names key '%s' dictionary does not contain both 'units' and 'value' keys" % k
 +                    raise Exception("error parameter_names key '%s' dictionary does not contain both 'units' and 'value' keys" % k)
@@ -195,7 +214,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
                  for v in val:
                      if isinstance(v,str):
                          punit.append(v)
-@@ -210,20 +210,20 @@
+@@ -210,20 +215,20 @@
                      except:
                          pass
                  if len(pvals)!=len(punits) or len(pvals)!=len(pnams):
@@ -222,7 +241,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
          punit = list(parameter_units)
          if isinstance(parameter_values,(list,tuple)):
              pvals = list(parameter_values)
-@@ -231,11 +231,11 @@
+@@ -231,11 +236,11 @@
              try:
                  pvals = numpy.ascontiguousarray(parameter_values.filled())
              except:
@@ -237,7 +256,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
      pvals = numpy.ascontiguousarray(pvals).astype('d')
      return _cmor.set_grid_mapping(grid_id,mapping_name,pnms,pvals,punit)
-@@ -255,11 +255,11 @@
+@@ -255,11 +260,11 @@
      interval: a string used for time axes only (???)
      """
      if not isinstance(table_entry,str):
@@ -251,7 +270,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
      else:
          if has_cdms2 and isinstance(coord_vals,cdms2.axis.TransientAxis):
              if units is None:
-@@ -286,10 +286,10 @@
+@@ -286,10 +291,10 @@
              coord_vals = numpy.ascontiguousarray(coord_vals.filled())
  
          if not isinstance(coord_vals,numpy.ndarray):
@@ -264,7 +283,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
      if numpy.ma.isMA(cell_bounds):
          cell_bounds = numpy.ascontiguousarray(cell_bounds.filled())
-@@ -304,18 +304,18 @@
+@@ -304,18 +309,18 @@
          
      if cell_bounds is not None:
          if numpy.rank(cell_bounds)>2:
@@ -287,7 +306,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
      else:
          cbnds = 0
  
-@@ -324,7 +324,7 @@
+@@ -324,7 +329,7 @@
          type = coord_vals.dtype.char[0]
  
          if not type in ['i','l','f','d','S']:
@@ -296,7 +315,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
          if type == 'S':
              type = 'c'
-@@ -344,7 +344,7 @@
+@@ -344,7 +349,7 @@
              
      if units is None:
          if coord_vals is not None:
@@ -305,7 +324,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
          else:
              units = "1"
      
-@@ -359,26 +359,26 @@
+@@ -359,26 +364,26 @@
  def variable(table_entry,units,axis_ids,type='f',missing_value=None,tolerance = 1.e-4,positive=None,original_name=None,history=None,comment=None):
      
      if not isinstance(table_entry,str):
@@ -337,7 +356,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
      else:
          comment = ""
          
-@@ -391,18 +391,18 @@
+@@ -391,18 +396,18 @@
      elif isinstance(axis_ids,(list,tuple)):
          axis_ids = numpy.ascontiguousarray(axis_ids)
      elif not isinstance(axis_ids, numpy.ndarray):
@@ -360,7 +379,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
      ndims = len(axis_ids)
  
-@@ -422,13 +422,13 @@
+@@ -422,13 +427,13 @@
          comment = str(comment)
  
      if not isinstance(tolerance,(float,int,numpy.float,numpy.float32,numpy.int,numpy.int32)):
@@ -376,7 +395,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
          missing_value = float(missing_value)
  
-@@ -438,14 +438,14 @@
+@@ -438,14 +443,14 @@
  def zfactor(zaxis_id,zfactor_name,units="",axis_ids=None,type=None,zfactor_values=None,zfactor_bounds=None):
  
      if not isinstance(zaxis_id,(int,numpy.int,numpy.int32)):
@@ -394,7 +413,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
      if numpy.ma.isMA(axis_ids):
          axis_ids = numpy.ascontiguousarray(axis_ids.filled())
-@@ -462,10 +462,10 @@
+@@ -462,10 +467,10 @@
      elif isinstance(axis_ids,(int,numpy.int,numpy.int32)):
          axis_ids = numpy.array([axis_ids,])
      elif not isinstance(axis_ids, numpy.ndarray):
@@ -407,7 +426,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
      if axis_ids is None:
          ndims = 0
-@@ -474,9 +474,9 @@
+@@ -474,9 +479,9 @@
          ndims = len(axis_ids)
  
  ##     if ndims>1 and zfactor_values is not None:
@@ -419,7 +438,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
      if zfactor_values is not None:
          if isinstance(zfactor_values,(float,int,numpy.float,numpy.float32,numpy.int,numpy.int32)):
-@@ -490,7 +490,7 @@
+@@ -490,7 +495,7 @@
          elif isinstance(zfactor_values,(list,tuple)):
              zfactor_values = numpy.ascontiguousarray(zfactor_values)
          elif not isinstance(zfactor_values, numpy.ndarray):
@@ -428,7 +447,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
          if type is None:
              try:
-@@ -501,18 +501,18 @@
+@@ -501,18 +506,18 @@
                  elif isinstance(zfactor_values,(int,numpy.int,numpy.int32)):
                      type = 'd'
                  else:
@@ -450,7 +469,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
      
      if zfactor_bounds is not None:
          if numpy.ma.isMA(zfactor_bounds):
-@@ -524,19 +524,19 @@
+@@ -524,19 +529,19 @@
          elif isinstance(zfactor_bounds,(list,tuple)):
              zfactor_bounds = numpy.ascontiguousarray(zfactor_bounds)
          elif not isinstance(zfactor_bounds, numpy.ndarray):
@@ -474,7 +493,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
              bnds.append(zfactor_bounds[-1][1])
              zfactor_bounds=numpy.array(bnds)
      axis_ids = axis_ids.astype('i')
-@@ -551,15 +551,15 @@
+@@ -551,15 +556,15 @@
      ierr = write(var_id,data,ntimes_passed=None,file_suffix="",time_vals=None,time_bnds=None,store_with=None
      """
      if not isinstance(var_id,(int,numpy.int,numpy.int32)):
@@ -493,7 +512,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
          store_with = int(store_with)
  
      if numpy.ma.isMA(data):
-@@ -573,7 +573,7 @@
+@@ -573,7 +578,7 @@
      elif isinstance(data,(list,tuple)):
          data = numpy.ascontiguousarray(data)
      elif not isinstance(data, numpy.ndarray):
@@ -502,7 +521,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
  
      if time_vals is None:
-@@ -594,12 +594,12 @@
+@@ -594,12 +599,12 @@
          try:
              time_vals = numpy.ascontiguousarray(time_vals)
          except:
@@ -517,7 +536,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
          time_vals=time_vals.astype("d")
         
  
-@@ -609,7 +609,7 @@
+@@ -609,7 +614,7 @@
          else:
              ntimes_passed = len(time_vals)
      if not isinstance(ntimes_passed,(int,numpy.int,numpy.int32)):
@@ -526,7 +545,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
      ntimes_passed = int(ntimes_passed)
  
  
-@@ -627,7 +627,7 @@
+@@ -627,7 +632,7 @@
          if goodshape[i]!=0:
              if sh[j]!=goodshape[i]:
                  if goodshape[i]!=1:
@@ -535,7 +554,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
              j+=1
          elif ntimes_passed!=1:
              j+=1
-@@ -649,13 +649,13 @@
+@@ -649,13 +654,13 @@
          elif isinstance(time_bnds,(list,tuple)):
              time_bnds = numpy.ascontiguousarray(time_bnds)
          elif not isinstance(time_bnds, numpy.ndarray):
@@ -552,7 +571,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
              bnds =[]
              if time_bnds.shape[0] > 1:
                  _check_time_bounds_contiguous(time_bnds)
-@@ -669,7 +669,7 @@
+@@ -669,7 +674,7 @@
              else:
                  ltv=len(time_vals)
              if len(time_bnds)!=ltv+1:
@@ -561,7 +580,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
              bnds=[]
              for i in range(ltv):
                  bnds.append([time_bnds[i],time_bnds[i+1]])
-@@ -680,12 +680,12 @@
+@@ -680,12 +685,12 @@
      if time_bnds is not None:
          type = time_bnds.dtype.char
          if not type in ['f','d','i','l']:
@@ -576,7 +595,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
      return _cmor.write(var_id,data,type,file_suffix,ntimes_passed,time_vals,time_bnds,store_with)
  
-@@ -696,7 +696,7 @@
+@@ -696,7 +701,7 @@
      for i in range(time_bnds.shape[0] - 1 ):
          b = time_bnds[i]
          if b[1]!=time_bnds[i+1][0]:
@@ -585,7 +604,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
  def _flatten_time_bounds(time_bnds):
      '''
-@@ -721,21 +721,21 @@
+@@ -721,21 +726,21 @@
      create_subdirectories: 1 to create subdirectories structure, 0 to dump files directly where cmor_dataset tells to
  """
      if not isinstance(exit_control,int) or not exit_control in [ cmor_const.CMOR_EXIT_ON_WARNING, cmor_const.CMOR_EXIT_ON_MAJOR, cmor_const.CMOR_NORMAL]:
@@ -612,7 +631,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
      return _cmor.setup(inpath,netcdf_file_action,set_verbosity,exit_control,logfile,create_subdirectories)
  
  def load_table(table):
-@@ -744,7 +744,7 @@
+@@ -744,7 +749,7 @@
      load_table(table)
      """
      if not isinstance(table,str):
@@ -621,7 +640,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  ##     if not os.path.exists(table):
  ##         raise Exception, "Error, the table you specified (%s) does not exists" % table
      return _cmor.load_table(table)
-@@ -782,7 +782,7 @@
+@@ -782,7 +787,7 @@
          if not isinstance(st,str):
              for o in dir():
                  if locals()[o] is st:
@@ -630,7 +649,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
  
      calendar = calendar.lower()
      
-@@ -790,7 +790,7 @@
+@@ -790,7 +795,7 @@
          if not isinstance(i,int):
              for o in dir():
                  if locals()[o] is i:
@@ -639,7 +658,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
      if isinstance(month_lengths,(list,tuple)):
          month_lengths = numpy.array(month_lengths)
      elif has_cdms2 and cdms2.isVariable(month_lengths):
-@@ -802,26 +802,26 @@
+@@ -802,26 +807,26 @@
          
      if isinstance(month_lengths,numpy.ndarray):
          if not numpy.rank(month_lengths)==1:
@@ -672,7 +691,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
          else:
              branch_time=float(branch_time)
  
-@@ -829,7 +829,7 @@
+@@ -829,7 +834,7 @@
  
  def set_table(table):
      if not isinstance(table,int):
@@ -681,7 +700,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
      return _cmor.set_table(table)
  
  def close(var_id=None,file_name=False, preserve=False):
-@@ -842,7 +842,7 @@
+@@ -842,7 +847,7 @@
        [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):
@@ -692,31 +711,34 @@ Index: cmor-2.8.3/Lib/pywrapper.py
          if (file_name is False):
 Index: cmor-2.8.3/Lib/__init__.py
 ===================================================================
---- cmor-2.8.3.orig/Lib/__init__.py	2013-06-12 12:04:17.000000000 +0100
-+++ cmor-2.8.3/Lib/__init__.py	2013-06-12 12:21:48.000000000 +0100
-@@ -1,9 +1,11 @@
-+from __future__ import print_function
- from cmor_const import *
- 
-+
- from pywrapper import axis,variable,write,setup,load_table,dataset,set_table,zfactor,close,grid,set_grid_mapping,time_varying_grid_coordinate,set_cur_dataset_attribute,get_cur_dataset_attribute,has_cur_dataset_attribute,create_output_path,set_variable_attribute,get_variable_attribute,has_variable_attribute
+--- cmor-2.8.3.orig/Lib/__init__.py	2013-06-12 12:22:15.000000000 +0100
++++ cmor-2.8.3/Lib/__init__.py	2013-06-12 13:08:32.000000000 +0100
+@@ -1,9 +1,9 @@
+-from cmor_const import *
+-
+-from pywrapper import axis,variable,write,setup,load_table,dataset,set_table,zfactor,close,grid,set_grid_mapping,time_varying_grid_coordinate,set_cur_dataset_attribute,get_cur_dataset_attribute,has_cur_dataset_attribute,create_output_path,set_variable_attribute,get_variable_attribute,has_variable_attribute
++from __future__ import print_function # Be python2/python3 agnostic
++from .cmor_const import *
++from .pywrapper import axis,variable,write,setup,load_table,dataset,set_table,zfactor,close,grid,set_grid_mapping,time_varying_grid_coordinate,set_cur_dataset_attribute,get_cur_dataset_attribute,has_cur_dataset_attribute,create_output_path,set_variable_attribute,get_variable_attribute,has_variable_attribute
  
  try:
-   from check_CMOR_compliant import checkCMOR
- except Exception,err:
+-  from check_CMOR_compliant import checkCMOR
+-except Exception,err:
 -  print err
++  from .check_CMOR_compliant import checkCMOR
++except Exception as err:
 +  print(err)
    pass
 Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
 ===================================================================
---- cmor-2.8.3.orig/Lib/check_CMOR_compliant.py	2013-06-12 12:04:17.000000000 +0100
-+++ cmor-2.8.3/Lib/check_CMOR_compliant.py	2013-06-12 12:21:36.000000000 +0100
+--- cmor-2.8.3.orig/Lib/check_CMOR_compliant.py	2013-06-12 12:22:15.000000000 +0100
++++ cmor-2.8.3/Lib/check_CMOR_compliant.py	2013-06-12 13:32:05.000000000 +0100
 @@ -1,3 +1,4 @@
 +from __future__ import print_function
  import cdms2
  import os
  import unidata
-@@ -8,6 +9,7 @@
+@@ -8,14 +9,19 @@
  import time
  VERBOSE=-999
  
@@ -724,7 +746,21 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
  #ok now we are going online to pull the file that has the control md5s
  try:
      f=open("Tables/md5s")
-@@ -53,11 +55,11 @@
+     ctrl_md5s=eval(f.read())
+ except:
+     try:
+-        import urllib2
+-        url=urllib2.urlopen("http://esgf.org/gitweb/?p=cmip5-cmor-tables.git;a=blob_plain;f=Tables/md5s;hb=HEAD")
++        try: 
++            import urllib2
++            url=urllib2.urlopen("http://esgf.org/gitweb/?p=cmip5-cmor-tables.git;a=blob_plain;f=Tables/md5s;hb=HEAD")
++        except ImportError:
++            import urllib.request, urllib.error, urllib.parse
++            url=urllib.request.urlopen("http://esgf.org/gitweb/?p=cmip5-cmor-tables.git;a=blob_plain;f=Tables/md5s;hb=HEAD")
+         ctrl_md5s=eval(url.read())
+         url.close()
+         del(url)
+@@ -53,11 +59,11 @@
          color=34
      else:
          return
@@ -738,14 +774,15 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
      return
      
  def manageLog(fout,error,*msg_bits):
-@@ -67,35 +69,35 @@
+@@ -67,35 +73,35 @@
          msg+=" "+str(m)
      msg=msg.lstrip()
          
 -##     print >>fout, 'No error is:',noerror
 +##     print( 'No error is:',noerror,file=fout)
      if error == cmor.CMOR_CRITICAL:
-         raise CMORError,[msg,]
+-        raise CMORError,[msg,]
++        raise CMORError([msg,])
      elif error == VERBOSE:
          fout.write( msg)
          if msg_bits[-1]!="":
@@ -788,7 +825,21 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
      return 1
  
  def split_expt_ids(val):
-@@ -160,7 +162,7 @@
+@@ -143,7 +149,7 @@
+         st=st.split('!')[0].strip()
+         if st[0]=="'":
+             st=st[1:-1]
+-        if gen_attributes.has_key(kw):
++        if kw in gen_attributes:
+             if isinstance(gen_attributes[kw],str):
+                 gen_attributes[kw]=[gen_attributes[kw],st]
+             else:
+@@ -156,11 +162,11 @@
+         sp=l.split('_entry:')
+         entry_type=sp[0]
+         entry=sp[1].strip()
+-        if not e.has_key(entry_type):
++        if entry_type not in e:
              e[entry_type]={}
          e[entry_type][entry]=e[entry_type].get(entry,{})
              
@@ -797,13 +848,14 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
          cont=1
          while cont:
              l = ln.pop(0)[:-1]
-@@ -176,26 +178,26 @@
+@@ -176,26 +182,26 @@
              sp=l.split(':')
              kw=sp[0].strip()
              val=":".join(sp[1:]).split('!')[0].strip()
 -            ## print  'dic is:',e[entry_type][entry]
+-            if e[entry_type][entry].has_key(kw):
 +            ## print('dic is:',e[entry_type][entry])
-             if e[entry_type][entry].has_key(kw):
++            if kw in e[entry_type][entry]:
                  if kw in lists_kw:
                      e[entry_type][entry][kw]="".join(e[entry_type][entry][kw])
                  e[entry_type][entry][kw]+=' '+val
@@ -830,7 +882,19 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
      return e
  
  
-@@ -264,7 +266,7 @@
+@@ -227,9 +233,9 @@
+         for ex in extra_req:
+             if not ex in req_glbl_att:
+                 req_glbl_att.append(ex)
+-        for v in Vars.keys():
++        for v in list(Vars.keys()):
+             IPCC_std_vars.append(Vars[v].get('out_name',v))
+-        for a in Axes.keys():
++        for a in list(Axes.keys()):
+             onm = Axes[a].get('out_name',a)
+             if not onm in IPCC_std_axes:
+                 IPCC_std_axes.append(onm)
+@@ -264,7 +270,7 @@
          manageLog(fout,VERBOSE, 'Checking file argument',IPCC_std_axes)
          manageLog(fout,VERBOSE, 'Checking path structure for path:',pthroot)
          manageLog(fout,VERBOSE, 'Checking file structure for file:',fnm)
@@ -839,7 +903,45 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
          ok = False
          for v in IPCC_std_vars:
              n = len(v)
-@@ -538,7 +540,7 @@
+@@ -275,8 +281,8 @@
+             nerr+=manageLog(fout, noerror, ''+shrt_fnm+' does not start with standard %s variable name followed by _' % file.project_id)
+         vf=v
+         #Check the variable is actually in the file
+-        if not v in file.variables.keys():
+-            nerr+=manageLog(fout,noerror,"Your file name says it contains variable",v,"but it is not in your file, your file contains:",file.variables.keys())
++        if not v in list(file.variables.keys()):
++            nerr+=manageLog(fout,noerror,"Your file name says it contains variable",v,"but it is not in your file, your file contains:",list(file.variables.keys()))
+         if hasattr(file,'cmor_version'):
+             up = False
+             rew = False
+@@ -447,7 +453,7 @@
+                 nwarn+=1
+                 manageLog(fout,cmor.CMOR_WARNING, '\t\tIt is often helpful to define the global attribute: ',att)
+ 
+-        for att in file.attributes.keys():
++        for att in list(file.attributes.keys()):
+             ncheck+=1
+             if not att in req_glbl_att and not att in opt_glbl_att:
+                 nwarn+=1
+@@ -483,7 +489,7 @@
+                                 ctrlmd5=tmd5s.get(tbl_date,None)
+                                 if ctrlmd5 is None:
+                                     nwarn+=1
+-                                    manageLog(fout,cmor.CMOR_WARNING, '\t\tCould not obtain control md5s for table %s for project %s dated on %s, valid tables dates are: ' % (tbl_id,file.project_id,tbl_date),sorted(tmd5s.keys()))
++                                    manageLog(fout,cmor.CMOR_WARNING, '\t\tCould not obtain control md5s for table %s for project %s dated on %s, valid tables dates are: ' % (tbl_id,file.project_id,tbl_date),sorted(list(tmd5s.keys())))
+                                 else:
+                                     ncheck+=1
+                                     if ctrlmd5!=tbl_md5:
+@@ -492,7 +498,7 @@
+                                         
+ 
+                         
+-                except Exception,err:
++                except Exception as err:
+                     #no md5 stored in file
+                     pass
+                 ttbl_id = e['general'].get("table_id").split()[1]
+@@ -538,7 +544,7 @@
              else:
                  spoffset=0
                  
@@ -848,16 +950,36 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
              if len(sp)<n:
                  nerr+=manageLog(fout, noerror, 'your file name does not seem to match the profile: varid_tableid_modelid_exptid_rid[iid][pid][_startdate-enddate][_suffix][_clim].nc')
                  
-@@ -970,7 +972,7 @@
+@@ -874,7 +880,7 @@
+         manageLog(fout,VERBOSE, 'Ok user asked to check the following variable:',variable,'with from bounds =',fb)
+     manageLog(fout,VERBOSE, 'Checking variable name is %s compliant' % file.project_id)
+     if not var in IPCC_std_vars:
+-        if var in Vars.keys():
++        if var in list(Vars.keys()):
+             nerr+=manageLog(fout, noerror, var+' is not valid, did you mean :'+Vars[var]['out_name']+' ?')
+         else:
+             nerr+=manageLog(fout, noerror, 'Variable name :'+var+' is not %s compliant' % file.project_id)
+@@ -895,7 +901,7 @@
+     for ax in axes:
+         manageLog(fout,VERBOSE, 'Checking axis name is valid for:',ax.id,'on var:',V.id)
+         if not ax.id in IPCC_std_axes:
+-            if ax.id in Axes.keys():
++            if ax.id in list(Axes.keys()):
+                 if major <2:
+                     ncheck+=1
+                     nwarn+=1
+@@ -970,8 +976,8 @@
                  gnm=nm
                  manageLog(fout,VERBOSE, '\tChecking special case %s, i.e' % (nm),'')
                  tmpax=V.getLevel()
 -                print>>fout,  tmpax.id,tmpax.standard_name
+-                for x in Axes.keys():
 +                print(tmpax.id,tmpax.standard_name,file=fout)
-                 for x in Axes.keys():
++                for x in list(Axes.keys()):
                      tmp=Axes[x].get('standard_name',None)
                      if tmp is not None: tmp=tmp.strip()
-@@ -1089,7 +1091,7 @@
+                     if tmp is not None and tmp==tmpax.standard_name:
+@@ -1089,7 +1095,7 @@
                  manageLog(fout,VERBOSE, r,'')
                  val=getattr(ax,r,None)
                  if val is None:
@@ -866,7 +988,7 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
                      nerr+=manageLog(fout, noerror, 'attribute '+r+' is required for axis '+ax.id)
                  if r!='units':
                      good_val=Axes[nm].get(r,None)
-@@ -1097,8 +1099,8 @@
+@@ -1097,8 +1103,8 @@
                          if val!=good_val:
                              nerr+=manageLog(fout, noerror, 'axis attribute '+r+' should be: '+str(good_val)+' but is:'+str(val))
                  if r=='formula_terms':
@@ -877,7 +999,7 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
              if not 'units' in Axes[nm].get('ignored',[]):
                  if not 'units' in Axes[nm].get('optional',[]) or ('units' in Axes[nm].get('optional',[]) and hasattr(ax,'units')):
                      if not ax.isTime():
-@@ -1200,7 +1202,7 @@
+@@ -1200,7 +1206,7 @@
                  manageLog(fout,VERBOSE, '\t\tChecking that the latitude are in degrees (not rads)')
                  min,max=genutil.minmax(ax[:])
                  if 0.<max-min<3.2:
@@ -886,7 +1008,7 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
                      nerr+=manageLog(fout, noerror, 'latitude must be stored in degree span is:'+str(max-min)+' looks like rad')
              elif ax.isTime() and len(ax[:])>1:
                  manageLog(fout,VERBOSE, '\t\tChecking for axis attribute')
-@@ -1212,7 +1214,7 @@
+@@ -1212,7 +1218,7 @@
                  manageLog(fout,VERBOSE, '\t\tView calendar attribute: ','')
                  c=getattr(ax,'calendar',None)
                  if c is None:
@@ -895,7 +1017,25 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
                      nerr+=manageLog(fout, noerror, 'calendar attribute must be defined on time axis')
                  else:
                      manageLog(fout,VERBOSE, c)
-@@ -1345,7 +1347,7 @@
+@@ -1255,7 +1261,7 @@
+                         t=t.split()[-1]
+     ##                     manageLog(fout,VERBOSE, 'Now it is:',t)
+                         sp2=ft.split(t+':')[1].split()[0]
+-                        if not sp2 in file.variables.keys():
++                        if not sp2 in list(file.variables.keys()):
+                             nerr+=manageLog(fout, noerror, 'formula_terms attribute indicates variable '+sp2+' should be stored in file')
+ 
+             if not docoord:
+@@ -1329,7 +1335,7 @@
+                         nerr+=manageLog(fout, noerror, 'dimension:'+Nm+' has no associated bounds')
+                 else:
+                     manageLog(fout,VERBOSE, '\t\tChecking that defined bounds variable is in file')
+-                    if not b in file.variables.keys():
++                    if not b in list(file.variables.keys()):
+                         nerr+=manageLog(fout, noerror, 'dimension '+Nm+' associated bounds are defined to be '+b+' but the variable is not present in file')
+                     if ax.isTime():
+                         interv = Axes[nm].get('interval',None)
+@@ -1345,7 +1351,7 @@
                                  else:
                                      c=ax.getCalendar()
  
@@ -904,10 +1044,119 @@ Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
                                  beg=cdtime.reltime(b[0],ax.units).tocomp(c)
                                  end=cdtime.reltime(b[1],ax.units).tocomp(c)
                                  mid=cdtime.reltime(ax[ib],ax.units).tocomp(c)
+@@ -1363,7 +1369,7 @@
+     opt_var_Att=['original_name','history','long_name','comment','coordinates','cell_methods','original_units',"cell_measures"]
+     for etmp in etables:
+         ev = etmp['variable']
+-        for v in ev.keys():
++        for v in list(ev.keys()):
+             if v == var:
+                 for p in ev[v].get("optional",[]):
+                     if p in req_var_Att:
+@@ -1408,7 +1414,7 @@
+                         if val.find(sp[i+1]+"_")==-1:
+                             nerr+=manageLog(fout,noerror,"associated files should point to file containing:",sp[i+1],'you have:',val)
+                             
+-    print >>fout
++    print(file=fout)
+     tp=Vars[V.id].get('type','real')
+     manageLog(fout,VERBOSE, '\tChecking Variable typecode is',tp)
+     if tp == 'double' : tp='d'
+@@ -1430,7 +1436,7 @@
+                       '1 '+V.units+' is actually :'+str(U2))
+         except:
+             nerr+=manageLog(fout, noerror, 'variable units:'+V.units+' do not match IPCC units:'+Vars[var]['units'])
+-    if 'standard_name' in Vars[var].keys():
++    if 'standard_name' in list(Vars[var].keys()):
+         manageLog(fout,VERBOSE, '\tChecking standard name (case independent)')
+         if getattr(V,'standard_name','').lower().strip()!=Vars[var]['standard_name']:
+             nerr+=manageLog(fout, noerror, 'standard_name for '+var+' should be:'+Vars[var]['standard_name'])
+@@ -1479,10 +1485,10 @@
+         if cm!=[]:
+             manageLog(fout,VERBOSE, '\tChecking for cell_methods: ','')
+             if not hasattr(V,'cell_methods'):
+-                print >> fout
++                print(file=fout)
+                 nerr+=manageLog(fout, noerror, 'Variable '+var+' should have "cell_methods" attribute')
+             else:
+-                 print >> fout,V.cell_methods
++                 print(V.cell_methods,file=fout)
+                
+             cmv=getattr(V,'cell_methods','')
+             sp=cm.split('(')
+@@ -1505,8 +1511,8 @@
+             for s in sp[1:]:
+                 dicv[kw]=s.split()[0].strip()
+                 kw=s.split()[-1].strip()
+-            for kw in dic.keys():
+-                if not kw in dicv.keys():
++            for kw in list(dic.keys()):
++                if not kw in list(dicv.keys()):
+                     nerr+=manageLog(fout, noerror, 'cell_methods must include '+kw+' defined (to: '+dic[kw]+' )')
+                 elif not dicv[kw]==dic[kw]:
+                     nerr+=manageLog(fout, noerror, 'cell_method: '+kw+' definition does not match table, it is :'+dicv[kw]+' but should be: '+dic[kw])
+@@ -1515,7 +1521,7 @@
+             if not hasattr(V,att):
+                 nwarn+=1
+                 manageLog(fout,cmor.CMOR_WARNING, '\t\tWhen appropriate, it is often helpful to define the variable attribute: ',att)
+-        for att in V.attributes.keys():
++        for att in list(V.attributes.keys()):
+             ncheck+=1
+             if not att in req_var_Att and not att in opt_var_Att:
+                 nwarn+=1
+@@ -1535,8 +1541,8 @@
+             nerr+=nerr
+         manageLog(fout,cmor.CMOR_WARNING, '%d warnings issued out of %d checked for (%5.2f%%)' % (nwarn,ncheck,float(nwarn)/ncheck*100))
+         if nerr!=0:
+-            print 'Nerr:',nerr
+-            raise CMORError,'%i CMOR errors were raise, please check output and correct your file !!!!' % (nerr)
++            print('Nerr:',nerr)
++            raise CMORError('%i CMOR errors were raise, please check output and correct your file !!!!' % (nerr))
+ 
+         file.close()
+     return nwarn,ncheck,nerr
+@@ -1585,7 +1591,7 @@
+         if o in ['--grid_table','-g']:
+             grid_table=p
+         if o in ['--help','-h','-?']:
+-            print help
++            print(help)
+             sys.exit()
+         if o in ['--noerror','-e']:
+             if p.lower() in ['off','0']:
+@@ -1595,16 +1601,16 @@
+         if o in ['--out','-o']:
+             out=p
+ 
+-    print 'File is:',file,file.find('*')
++    print('File is:',file,file.find('*'))
+     if os.path.isdir(file):
+         files=os.popen('ls '+file+'/*.nc').readlines()
+     elif file.find('*')>=0:
+         files=os.popen('ls '+file).readlines()
+     else:
+         files=[file]
+-    print 'Files:',files
++    print('Files:',files)
+     for file in files:
+-        print 'Dealing with ',file.strip()
++        print('Dealing with ',file.strip())
+         if out.lower()=='screen':
+             fout=sys.stdout
+         elif out.lower()=='file':
+@@ -1617,6 +1623,6 @@
+         else:
+             try:
+                 checkCMOR(fout,file.strip(),table,other_tables=[grid_table,],noerror=noerror,variable=var)
+-            except Exception,err:
+-                print err
++            except Exception as err:
++                print(err)
+            
 Index: cmor-2.8.3/Test/check_results.py
 ===================================================================
---- cmor-2.8.3.orig/Test/check_results.py	2013-06-12 12:04:17.000000000 +0100
-+++ cmor-2.8.3/Test/check_results.py	2013-06-12 12:04:21.000000000 +0100
+--- cmor-2.8.3.orig/Test/check_results.py	2013-06-12 12:22:15.000000000 +0100
++++ cmor-2.8.3/Test/check_results.py	2013-06-12 12:22:21.000000000 +0100
 @@ -2,6 +2,8 @@
  from in_files import input_tables
  import sys,os
@@ -961,8 +1210,8 @@ Index: cmor-2.8.3/Test/check_results.py
 +    raise CMORResultCheckError(["Error checking output files for test: Test/%s.f90 we could only find %i files when %i were expected.\n\n Expected files: \n\t%s\n\nPresent files: \n\t%s\n\nMissing files: \n\t%s\n" % (test,nfiles,len(outfiles),repr(outfiles),repr(gotfiles),repr(missing)),])
 Index: cmor-2.8.3/Test/cmor_speed_and_compression_01.py
 ===================================================================
---- cmor-2.8.3.orig/Test/cmor_speed_and_compression_01.py	2013-06-12 12:04:17.000000000 +0100
-+++ cmor-2.8.3/Test/cmor_speed_and_compression_01.py	2013-06-12 12:04:21.000000000 +0100
+--- cmor-2.8.3.orig/Test/cmor_speed_and_compression_01.py	2013-06-12 12:22:15.000000000 +0100
++++ cmor-2.8.3/Test/cmor_speed_and_compression_01.py	2013-06-12 12:22:21.000000000 +0100
 @@ -1,11 +1,13 @@
  import cmor,numpy,sys,os
 +
@@ -1040,8 +1289,8 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression_01.py
  f.close()
 Index: cmor-2.8.3/setup.py.in
 ===================================================================
---- cmor-2.8.3.orig/setup.py.in	2013-06-12 12:04:17.000000000 +0100
-+++ cmor-2.8.3/setup.py.in	2013-06-12 12:20:22.000000000 +0100
+--- cmor-2.8.3.orig/setup.py.in	2013-06-12 12:22:15.000000000 +0100
++++ cmor-2.8.3/setup.py.in	2013-06-12 12:22:21.000000000 +0100
 @@ -1,8 +1,10 @@
 +from __future__ import print_function # to be python2/python3 agnostic
  import numpy
diff --git a/debian/rules b/debian/rules
index 471dbfd..9d5e593 100755
--- a/debian/rules
+++ b/debian/rules
@@ -40,7 +40,7 @@ endif
 override_dh_auto_install:
 	$(MAKE) install DESTDIR=`pwd`/debian/tmp
 	$(MAKE) install_shlib DESTDIR=`pwd`/debian/tmp
-	for p in $(PYVERS) $(PY3VERS); do \
+	for p in $(PYVERS) ; do \
 		$$p ./setup.py install  --root=$(CURDIR)/debian/tmp --install-layout=deb ; \
 		done
 	dh_numpy

-- 
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