Ignore:
Timestamp:
08/05/20 00:25:08 (5 years ago)
Author:
jdquinn
Message:

CHG: Default argument cannot follow *args; shlex not behaving as expected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/io/loadvars.py

    r25125 r25346  
    1515
    1616
    17 def loadvars(*args, OL):
    18     '''
     17def loadvars(*args, **kwargs):
     18    """
    1919    LOADVARS - function to load variables from a file.
    2020
     
    3030        nvdict = loadvars('shelve.dat', {'a':None, 'b':None})
    3131        nvdict = loadvars('shelve.dat')
    32     '''
     32    """
    3333
    3434    filename = ''
     
    5555    else:
    5656        raise TypeError("Unrecognized input arguments.")
     57
     58    onlylast = False
     59
     60    for key, value in kwargs.items():
     61        if key == 'onlylast':
     62            onlylast = value
    5763
    5864    if whichdb(filename):   #We used python pickle for the save
     
    110116                            nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [OrderedDict() for i in range(max(1, len(curclass.groups)))]
    111117                        else:
    112                             if OL:   #we load only the last result to save on time and memory
     118                            if onlylast:   #we load only the last result to save on time and memory
    113119                                nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)()]
    114120                                Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]]
     
    126132                        if AllHaveTime:
    127133                            #Time dimension is in all the variables so we take that as stepnumber for the results
    128                             if OL:   #we load only the last result to save on time and memory
     134                            if onlylast:   #we load only the last result to save on time and memory
    129135                                nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)()]
    130136                                Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]]
     
    166172                        NewFormat = 'Time' in NCFile.dimensions
    167173                        if type(Tree) == list and NewFormat:
    168                             if OL:
     174                            if onlylast:
    169175                                if vardim == 1:
    170176                                    Tree[0].__dict__[str(var)] = varval[-1].data
Note: See TracChangeset for help on using the changeset viewer.