Skip to content

Commit

Permalink
Changed number of expected positional arguments to 0 or 1 , warnings …
Browse files Browse the repository at this point in the history
…and debug statements
  • Loading branch information
wilke committed Aug 5, 2016
1 parent 74d2100 commit a6a3d33
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/Tools/xmlchange
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter

CIME.utils.setup_standard_logging_options(parser)

parser.add_argument("listofsettings", nargs="*",
parser.add_argument("listofsettings", nargs="?", default='' ,
help="Comma seperated list of settings in the form: var1=value,var2=value,...")

parser.add_argument("--caseroot", default=os.getcwd(),
Expand Down Expand Up @@ -77,7 +77,8 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)


logger.warning(args.listofsettings)
listofsettings = []
if( len(args.listofsettings) == 1 ):
listofsettings = args.listofsettings[0].split(',')
Expand All @@ -88,11 +89,12 @@ def xmlchange(caseroot, listofsettings=None, xmlfile=None, xmlid=None, xmlval=No
append=None, noecho=False, warn=None, force=False):
with Case(caseroot, read_only=False) as case:
if listofsettings:

logger.warning("List of attributes to change: %s" , listofsettings)

# Error handling, exit with grace if xmlval or equal sign is missing. Check first before changing any attributes
for setting in listofsettings:
(xmlid, xmlval) = setting.split('=', 1)
if xmlval == None :
if xmlval is None :
logger.error("Missing value for %s. Please all settings have to be in the form of attribute=value." , xmlid)
sys.exit(1)

Expand Down

0 comments on commit a6a3d33

Please sign in to comment.