Changeset ff99eae in flex_extract.git for python/ControlFile.py
- Timestamp:
- Jun 1, 2018, 8:34:59 PM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- e1228f3
- Parents:
- ccab809
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/ControlFile.py
r812283d rff99eae 2 2 # -*- coding: utf-8 -*- 3 3 #************************************************************************ 4 # T ODOAP4 # ToDo AP 5 5 # - write a test class 6 6 #************************************************************************ … … 37 37 # - __init__ 38 38 # - __str__ 39 # - tolist 39 # - to_list 40 # 41 # @Class Attributes: 42 # - start_date 43 # - end_date 44 # - accuracy 45 # - omega 46 # - cwc 47 # - omegadiff 48 # - etadiff 49 # - level 50 # - levelist 51 # - step 52 # - maxstep 53 # - prefix 54 # - makefile 55 # - basetime 56 # - date_chunk 57 # - grib2flexpart 58 # - exedir 59 # - flexpart_root_scripts 60 # - ecmwfdatadir 40 61 # 41 62 #******************************************************************************* … … 46 67 import os 47 68 import inspect 69 48 70 # software specific module from flex_extract 49 import Tools 71 from tools import get_list_as_string, my_error 50 72 51 73 # ------------------------------------------------------------------------------ 52 74 # CLASS 53 75 # ------------------------------------------------------------------------------ 54 class ControlFile :76 class ControlFile(object): 55 77 ''' 56 78 Class containing the information of the flex_extract CONTROL file. … … 114 136 for d in dd: 115 137 data.append(d) 116 pass117 138 if len(data) == 2: 118 139 if '$' in data[1]: … … 126 147 data[1] = data[1][:i] + var + data[1][k+1:] 127 148 else: 128 Tools.myerror(None, 129 'Could not find variable ' + 130 data[1][j+1:k] + 131 ' while reading ' + 132 filename) 149 my_error(None, 'Could not find variable ' + 150 data[1][j+1:k] + ' while reading ' + 151 filename) 133 152 setattr(self, data[0].lower() + '_expanded', data[1]) 134 153 else: … … 160 179 if not hasattr(self, 'levelist'): 161 180 if not hasattr(self, 'level'): 162 print ('Warning: neither levelist nor level \163 specified in CONTROL file' )181 print 'Warning: neither levelist nor level \ 182 specified in CONTROL file' 164 183 else: 165 184 self.levelist = '1/to/' + self.level … … 224 243 return ', '.join("%s: %s" % item for item in attrs.items()) 225 244 226 def to list(self):245 def to_list(self): 227 246 ''' 228 247 @Description: … … 255 274 pass 256 275 else: 257 if type(item[1]) is list:276 if isinstance(item[1], list): 258 277 stot = '' 259 278 for s in item[1]: … … 265 284 266 285 return sorted(l) 286 287 # def to_dict(self): 288 # ''' 289 290 # ''' 291 # parameters_dict = vars(self) 292 293 # # remove unneeded parameter 294 # parameters_dict.pop('_expanded', None) 295 # parameters_dict.pop('exedir', None) 296 # parameters_dict.pop('flexpart_root_scripts', None) 297 # parameters_dict.pop('ecmwfdatadir', None) 298 299 # parameters_dict_str = {} 300 # for key, value in parameters_dict.iteritems(): 301 # if isinstance(value, list): 302 # parameters_dict_str[str(key)] = get_list_as_string(value, ' ') 303 # else: 304 # parameters_dict_str[str(key)] = str(value) 305 306 # return parameters_dict_str
Note: See TracChangeset
for help on using the changeset viewer.