Skip to content

Commit

Permalink
Revert "Merge pull request #343 from ESMCI/wilke/scripts/xmlchange"
Browse files Browse the repository at this point in the history
This reverts commit 252aea7, reversing
changes made to e7b334e.
  • Loading branch information
jgfouca committed Aug 9, 2016
1 parent 8dc2354 commit 5d38420
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions scripts/Tools/xmlchange
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ from CIME.case import Case

import argparse, doctest, shutil, glob, time

logger = logging.getLogger("xmlchange")

###############################################################################
def parse_command_line(args, description):
###############################################################################
Expand All @@ -41,7 +39,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter

CIME.utils.setup_standard_logging_options(parser)

parser.add_argument("listofsettings", nargs="?", default='' ,
parser.add_argument("listofsettings", nargs="*",
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,33 +75,19 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)

listofsettings = []
if( len(args.listofsettings) ):
listofsettings = args.listofsettings.split(',')
if( len(args.listofsettings) == 1 ):
listofsettings = args.listofsettings[0].split(',')

return args.caseroot, listofsettings, args.file, args.id, args.val, args.subgroup, args.append, args.noecho, args.warn, args.force

def xmlchange(caseroot, listofsettings=None, xmlfile=None, xmlid=None, xmlval=None, subgroup=None,
append=None, noecho=False, warn=None, force=False):
with Case(caseroot, read_only=False) as case:
if len(listofsettings):
logger.warning("List of attributes to change: %s" , listofsettings)

# Error handling, exit with grace if xmlval or equal sign is missing. Check first all attributes before changing
for setting in listofsettings:
# Test for equal sign
pair = setting.split("=")
expect(len(pair) == 2 , "Wrong format for %s. Expecting a key value pair in form of key=value." % (setting) )
(xmlid, xmlval) = pair

# Change values
if listofsettings:
for setting in listofsettings:

pair = setting.split("=")
expect(len(pair) == 2 , "Expecting a key value pair in the form of key=value.")
(xmlid, xmlval) = pair

(xmlid, xmlval) = setting.split('=', 1)
type_str = case.get_type_info(xmlid)
if(append is True):
value = case.get_value(xmlid, resolved=False,
Expand Down

0 comments on commit 5d38420

Please sign in to comment.