From 4ac089ae34b682f2d1a6ba13b50c51334a8231db Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 10 May 2017 10:55:24 -0600 Subject: [PATCH 1/3] add --skip-xml-validation option to avoid validation of all xml files --- scripts/lib/CIME/XML/generic_xml.py | 6 ++++-- scripts/lib/CIME/utils.py | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/lib/CIME/XML/generic_xml.py b/scripts/lib/CIME/XML/generic_xml.py index 889624ccd48..63a5d652f65 100644 --- a/scripts/lib/CIME/XML/generic_xml.py +++ b/scripts/lib/CIME/XML/generic_xml.py @@ -5,7 +5,7 @@ from CIME.XML.standard_module_setup import * from distutils.spawn import find_executable from xml.dom import minidom - +import CIME.utils import getpass logger = logging.getLogger(__name__) @@ -18,7 +18,6 @@ def __init__(self, infile=None, schema=None): """ logger.debug("Initializing %s" , infile) self.tree = None - if infile == None: # if file is not defined just return self.filename = None @@ -262,6 +261,9 @@ def validate_xml_file(self, filename, schema): """ validate an XML file against a provided schema file using pylint """ + if CIME.utils.SKIP_XML_VALIDATION: + logger.warn("Skipping xml validation for file %s"%filename) + return expect(os.path.isfile(filename),"xml file not found %s"%filename) expect(os.path.isfile(schema),"schema file not found %s"%schema) xmllint = find_executable("xmllint") diff --git a/scripts/lib/CIME/utils.py b/scripts/lib/CIME/utils.py index 7bf661089a9..68c48e4eb18 100644 --- a/scripts/lib/CIME/utils.py +++ b/scripts/lib/CIME/utils.py @@ -6,6 +6,7 @@ import stat as statlib import warnings # Return this error code if the scripts worked but tests failed +SKIP_XML_VALIDATION = None TESTS_FAILED_ERR_CODE = 100 logger = logging.getLogger(__name__) @@ -621,6 +622,8 @@ def get_project(machobj=None): def setup_standard_logging_options(parser): helpfile = "%s.log"%sys.argv[0] helpfile = os.path.join(os.getcwd(),os.path.basename(helpfile)) + parser.add_argument("--skip-xml-validation", action="store_true", + help="Do not validate xml files") parser.add_argument("-d", "--debug", action="store_true", help="Print debug information (very verbose) to file %s" % helpfile) parser.add_argument("-v", "--verbose", action="store_true", @@ -646,6 +649,7 @@ def parse_args_and_handle_standard_logging_options(args, parser=None): logger.warning -> Goes to stderr (and log if --debug). Use for minor problems logger.error -> Goes to stderr (and log if --debug) """ + global SKIP_XML_VALIDATION root_logger = logging.getLogger() verbose_formatter = logging.Formatter(fmt='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', @@ -687,6 +691,11 @@ def parse_args_and_handle_standard_logging_options(args, parser=None): root_logger.setLevel(logging.WARN) else: root_logger.setLevel(logging.INFO) + + SKIP_XML_VALIDATION = False + if args.skip_xml_validation: + SKIP_XML_VALIDATION = True + return args From bab54271dbdc5219511456e4a5c08efe90726cef Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 10 May 2017 10:56:57 -0600 Subject: [PATCH 2/3] fix xml schema for env_mach_specific --- config/xml_schemas/env_mach_specific.xsd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/xml_schemas/env_mach_specific.xsd b/config/xml_schemas/env_mach_specific.xsd index ca30310b3a3..2ea8a90ee7b 100644 --- a/config/xml_schemas/env_mach_specific.xsd +++ b/config/xml_schemas/env_mach_specific.xsd @@ -23,9 +23,9 @@ - - - + + + @@ -35,9 +35,9 @@ - - - + + + From 99b0c6ab0293f7aa1ed865f9ee4974004be8515a Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 10 May 2017 13:07:29 -0600 Subject: [PATCH 3/3] undo the --skip-xml-validation option --- scripts/lib/CIME/XML/generic_xml.py | 6 ++---- scripts/lib/CIME/utils.py | 9 --------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/scripts/lib/CIME/XML/generic_xml.py b/scripts/lib/CIME/XML/generic_xml.py index 63a5d652f65..889624ccd48 100644 --- a/scripts/lib/CIME/XML/generic_xml.py +++ b/scripts/lib/CIME/XML/generic_xml.py @@ -5,7 +5,7 @@ from CIME.XML.standard_module_setup import * from distutils.spawn import find_executable from xml.dom import minidom -import CIME.utils + import getpass logger = logging.getLogger(__name__) @@ -18,6 +18,7 @@ def __init__(self, infile=None, schema=None): """ logger.debug("Initializing %s" , infile) self.tree = None + if infile == None: # if file is not defined just return self.filename = None @@ -261,9 +262,6 @@ def validate_xml_file(self, filename, schema): """ validate an XML file against a provided schema file using pylint """ - if CIME.utils.SKIP_XML_VALIDATION: - logger.warn("Skipping xml validation for file %s"%filename) - return expect(os.path.isfile(filename),"xml file not found %s"%filename) expect(os.path.isfile(schema),"schema file not found %s"%schema) xmllint = find_executable("xmllint") diff --git a/scripts/lib/CIME/utils.py b/scripts/lib/CIME/utils.py index 68c48e4eb18..7bf661089a9 100644 --- a/scripts/lib/CIME/utils.py +++ b/scripts/lib/CIME/utils.py @@ -6,7 +6,6 @@ import stat as statlib import warnings # Return this error code if the scripts worked but tests failed -SKIP_XML_VALIDATION = None TESTS_FAILED_ERR_CODE = 100 logger = logging.getLogger(__name__) @@ -622,8 +621,6 @@ def get_project(machobj=None): def setup_standard_logging_options(parser): helpfile = "%s.log"%sys.argv[0] helpfile = os.path.join(os.getcwd(),os.path.basename(helpfile)) - parser.add_argument("--skip-xml-validation", action="store_true", - help="Do not validate xml files") parser.add_argument("-d", "--debug", action="store_true", help="Print debug information (very verbose) to file %s" % helpfile) parser.add_argument("-v", "--verbose", action="store_true", @@ -649,7 +646,6 @@ def parse_args_and_handle_standard_logging_options(args, parser=None): logger.warning -> Goes to stderr (and log if --debug). Use for minor problems logger.error -> Goes to stderr (and log if --debug) """ - global SKIP_XML_VALIDATION root_logger = logging.getLogger() verbose_formatter = logging.Formatter(fmt='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', @@ -691,11 +687,6 @@ def parse_args_and_handle_standard_logging_options(args, parser=None): root_logger.setLevel(logging.WARN) else: root_logger.setLevel(logging.INFO) - - SKIP_XML_VALIDATION = False - if args.skip_xml_validation: - SKIP_XML_VALIDATION = True - return args