Skip to content

Commit

Permalink
Merge pull request #1818 from ESMCI/jgfouca/xmlchange_improve_error
Browse files Browse the repository at this point in the history
Improve error messages from xmlchange
ACME users were complaining of unhelpful error messages coming
from xmlchange. This PR will make the handling of type_str consistent
with the listofsettings block above. This should ensure a better error
message.

Test suite: code_checker, by-hand
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes [CIME Github issue #]

User interface changes?:

Update gh-pages html (Y/N)?:

Code review: jedwards
  • Loading branch information
jedwards4b authored Aug 16, 2017
2 parents 8e9a554 + c8a1ace commit 37909bd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scripts/Tools/xmlchange
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,26 @@ def xmlchange(caseroot, listofsettings, xmlfile, xmlid, xmlval, subgroup,
value = case.get_value(xmlid, resolved=False,
subgroup=subgroup)
xmlval = "%s %s" % (value, xmlval)

if type_str is not None and not force:
xmlval = convert_to_type(xmlval, type_str, xmlid)

if not dryrun :
if not dryrun:
newval = case.set_value(xmlid, xmlval, subgroup, ignore_type=force)
expect(newval is not None,"No variable \"%s\" found"%xmlid)
else :
else:
logger.warning("'%s' = '%s'" , xmlid , xmlval )
else:
if append:
value = case.get_value(xmlid, resolved=False, subgroup=subgroup)
xmlval = "%s %s" % (value, xmlval)

type_str = case.get_type_info(xmlid)
if not force:
if type_str is not None and not force:
xmlval = convert_to_type(xmlval, type_str, xmlid)
newval = case.set_value(xmlid, xmlval, subgroup, ignore_type=force)

expect(newval is not None,"No variable \"%s\" found"%xmlid)
newval = case.set_value(xmlid, xmlval, subgroup, ignore_type=force)
expect(newval is not None,"No variable '%s' found" % xmlid)

if not noecho:
argstr = ""
Expand Down

0 comments on commit 37909bd

Please sign in to comment.