Changeset 353 for nappy/trunk


Ignore:
Timestamp:
25/11/04 00:25:32 (15 years ago)
Author:
badc
Message:

Two bug fixes. One to deal with regular expression error if units
contained a regex special character. The other to stop the NetCDF-style
attributes including the variable name between each.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nappy/trunk/cdms2na.py

    r351 r353  
    122122        name="%s (%s)" % (name, var.units)     
    123123        # Do a check to see units are not duplicated 
    124         match=re.match("(.*\(%s\)\s*)\(%s\)(.*)$" % (var.units, var.units), name) 
    125         if match: 
    126             name=match.groups()[0]+match.groups()[1] 
     124        # [The regex below failed because it interpreted 'm**2' as 
     125        # regex characters] 
     126        #match=re.match("(.*\(%s\)\s*)\(%s\)(.*)$" % (var.units, var.units), name) 
     127        #if match: 
     128        #    name=match.groups()[0]+match.groups()[1] 
     129        if name.count("(%s)" % var.units)>1: 
     130            name=name.replace("(%s)" % var.units, "") 
    127131         
    128132    if name[-2:]=="()": name=name[:-2] 
     
    534538                            SCOM.append("Additional Variable Attributes defined in the source file and not translated elsewhere:") 
    535539                            SCOM.append("###Variable attributes from source (NetCDF) file follow###") 
    536                         varflag=="using"  
     540                        varflag="using"  
    537541                        SCOM.append("\tVariable (%s): %s" % (var.id, name)) 
    538542                    SCOM.append("\t\t%s = %s" % (scom, var.attributes[scom])) 
Note: See TracChangeset for help on using the changeset viewer.