Changeset 4128
- Timestamp:
- 2013-10-24T22:45:19+02:00 (11 years ago)
- Location:
- branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/OOO/ooo/nml.py
r4126 r4128 154 154 __version__ = "0.1.0" 155 155 import re 156 from numbers import Number 156 157 157 158 def reader(path): … … 341 342 """ 342 343 if isinstance(data, list): 343 if same_type(data):344 if all_numeric(data): 344 345 delim = " " 345 346 else: … … 350 351 return text 351 352 353 def all_numeric(inputs): 354 # Checks all list entries are numbers 355 flag = True 356 for input in inputs: 357 if not isinstance(input, Number): 358 flag = False 359 break 360 return flag 361 352 362 def numeric(word): 353 363 # Tests input string is numeric data … … 375 385 flag = False 376 386 return flag 387 388 def quote(word): 389 if not quoted(word): 390 word = "'%s'" % (word,) 391 return word 377 392 378 393 def convert(word): … … 383 398 result = "%s" % (word,) 384 399 else: 385 result = "'%s'" % (word,)400 result = quote(word) 386 401 elif isinstance(word, bool): 387 402 if word: -
branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/OOO/ooo/test_nml.py
r4126 r4128 173 173 self.num = 10 174 174 self.mixed_list = ["foo.nc", -1, True] 175 self.mixed_str_list = map(nml.quote, ["foo.nc", "-1", ".TRUE."]) 175 176 176 177 def test_should_format_mixed_list(self): … … 186 187 def test_should_format_character_list(self): 187 188 data = nml.tostring(self.char_list) 188 result = "'a.nc' 'b.nc''c.nc'"189 result = "'a.nc', 'b.nc', 'c.nc'" 189 190 self.assertEqual(data, result) 190 191 … … 213 214 self.assertEqual(case, input) 214 215 216 def test_should_treat_mixed_numeric_character_data_as_character(self): 217 case = nml.tostring(self.mixed_str_list) 218 result = "'foo.nc', '-1', '.TRUE.'" 219 self.assertEqual(case, result) 220 215 221 class TestUpdateNamelist(unittest.TestCase): 216 222 def setUp(self): -
branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/src/c4comb.F90
r4124 r4128 465 465 CALL chkerr( nf90_put_att(ncid, nf90_global,'institution', trim(ins_str)),cpname, __LINE__) 466 466 CALL chkerr( nf90_put_att(ncid, nf90_global,'validity_time', trim(val_str)),cpname, __LINE__) 467 CALL chkerr( nf90_put_att(ncid, nf90_global,'best_estimate_description', 'analysis produced 2 days behind real time'),cpname, __LINE__) 467 CALL chkerr( nf90_put_att(ncid, nf90_global,'best_estimate_description', & 468 & 'analysis produced 2 days behind real time'),cpname, __LINE__) 468 469 CALL chkerr( nf90_put_att(ncid, nf90_global,'time_interp', 'daily average fields'),cpname, __LINE__) 469 470 WRITE(*,*) 'Succesfully put global attributes '
Note: See TracChangeset
for help on using the changeset viewer.