Changeset 4137
- Timestamp:
- 2013-10-25T16:06:26+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/OOO/ooo/ooo.py
r4136 r4137 25 25 parser.add_argument("--dry-run", action="store_true", 26 26 help="Flag to test namelist building without submitting.") 27 parser.add_argument("-v", "--verbose", action="store_true", 28 help="Prints difference between before and after namelists.") 27 29 parser.add_argument("namelist", metavar="NAMELIST", 28 30 help="NEMO namelist to edit.") … … 32 34 args.lead_times = map(int, args.lead_times.split(',')) 33 35 return args 36 37 def printdiff(text1, text2): 38 # Provides nice text difference summary of namelists 39 import difflib 40 lines1 = text1.splitlines() 41 lines2 = text2.splitlines() 42 d = difflib.Differ() 43 result = list(d.compare(lines1, lines2)) 44 text = '\n'.join(result) 45 print text 34 46 35 47 def main(): … … 53 65 text = nml.reader(args.namelist) 54 66 sublists = nml.namelists(text) 67 68 # Verbose save original text 69 if args.verbose: 70 original_text = text 55 71 56 72 # namooo … … 87 103 text = nml.update("namobs", text, data=namobs) 88 104 105 # Verbose print namelist differences 106 if args.verbose: 107 printdiff(original_text, text) 108 89 109 # pipe text to file 90 110 tmp = args.namelist+".tmp"
Note: See TracChangeset
for help on using the changeset viewer.