diff --git a/CIME/BuildTools/macrowriterbase.py b/CIME/BuildTools/macrowriterbase.py index 7f91ba6b085..6acf14d487e 100644 --- a/CIME/BuildTools/macrowriterbase.py +++ b/CIME/BuildTools/macrowriterbase.py @@ -13,7 +13,7 @@ from abc import ABCMeta, abstractmethod from CIME.XML.standard_module_setup import * from CIME.utils import get_cime_root -from six import add_metaclass +from CIME.six import add_metaclass logger = logging.getLogger(__name__) diff --git a/CIME/SystemTests/system_tests_common.py b/CIME/SystemTests/system_tests_common.py index 5eb8558df10..7c1e26c62e1 100644 --- a/CIME/SystemTests/system_tests_common.py +++ b/CIME/SystemTests/system_tests_common.py @@ -12,7 +12,7 @@ from CIME.locked_files import LOCKED_DIR, lock_file, is_locked import CIME.build as build -import glob, gzip, time, traceback, six, os +import glob, gzip, time, traceback, CIME.six, os logger = logging.getLogger(__name__) @@ -309,7 +309,7 @@ def _coupler_log_indicates_run_complete(self): allgood = len(newestcpllogfiles) for cpllog in newestcpllogfiles: try: - if six.b("SUCCESSFUL TERMINATION") in gzip.open(cpllog, 'rb').read(): + if CIME.six.b("SUCCESSFUL TERMINATION") in gzip.open(cpllog, 'rb').read(): allgood = allgood - 1 except Exception as e: # Probably want to be more specific here msg = e.__str__() diff --git a/CIME/XML/compilers.py b/CIME/XML/compilers.py index 4eba47907c1..8ba2c53bd67 100644 --- a/CIME/XML/compilers.py +++ b/CIME/XML/compilers.py @@ -9,7 +9,7 @@ from CIME.BuildTools.makemacroswriter import MakeMacroWriter from CIME.BuildTools.cmakemacroswriter import CMakeMacroWriter from CIME.BuildTools.macroconditiontree import merge_optional_trees -import six +import CIME.six logger = logging.getLogger(__name__) @@ -161,7 +161,7 @@ def write_macros_file(self, macros_file="Macros.make", output_format="make", xml else: format_ = output_format - if isinstance(macros_file, six.string_types): + if isinstance(macros_file, CIME.six.string_types): with open(macros_file, "w") as macros: self._write_macros_file(format_, macros) else: diff --git a/CIME/XML/entry_id.py b/CIME/XML/entry_id.py index 2e16e339f38..0cdce134f26 100644 --- a/CIME/XML/entry_id.py +++ b/CIME/XML/entry_id.py @@ -7,7 +7,7 @@ from CIME.utils import expect, convert_to_string, convert_to_type from CIME.XML.generic_xml import GenericXML -import six +import CIME.six logger = logging.getLogger(__name__) @@ -249,7 +249,7 @@ def _set_value(self, node, value, vid=None, subgroup=None, ignore_type=False): def get_valid_value_string(self, node, value,vid=None, ignore_type=False): valid_values = self._get_valid_values(node) if ignore_type: - expect(isinstance(value, six.string_types), "Value must be type string if ignore_type is true") + expect(isinstance(value, CIME.six.string_types), "Value must be type string if ignore_type is true") str_value = value return str_value type_str = self._get_type_info(node) diff --git a/CIME/XML/generic_xml.py b/CIME/XML/generic_xml.py index 1223851f6b2..6355ce74685 100644 --- a/CIME/XML/generic_xml.py +++ b/CIME/XML/generic_xml.py @@ -9,7 +9,7 @@ #pylint: disable=import-error from distutils.spawn import find_executable import getpass -import six +import CIME.six from copy import deepcopy from collections import namedtuple @@ -97,7 +97,7 @@ def read(self, infile, schema=None): if not cached_read: logger.debug("read: {}".format(infile)) - file_open = (lambda x: open(x, 'r', encoding='utf-8')) if six.PY3 else (lambda x: open(x, 'r')) + file_open = (lambda x: open(x, 'r', encoding='utf-8')) if CIME.six.PY3 else (lambda x: open(x, 'r')) with file_open(infile) as fd: self.read_fd(fd) @@ -357,7 +357,7 @@ def write(self, outfile=None, force_write=False): if outfile is None: outfile = self.filename - logger.debug("write: " + (outfile if isinstance(outfile, six.string_types) else str(outfile))) + logger.debug("write: " + (outfile if isinstance(outfile, CIME.six.string_types) else str(outfile))) xmlstr = self.get_raw_record() @@ -365,7 +365,7 @@ def write(self, outfile=None, force_write=False): xmllint = find_executable("xmllint") if xmllint is not None: - if isinstance(outfile, six.string_types): + if isinstance(outfile, CIME.six.string_types): run_cmd_no_fail("{} --format --output {} -".format(xmllint, outfile), input_str=xmlstr) else: outfile.write(run_cmd_no_fail("{} --format -".format(xmllint), input_str=xmlstr)) @@ -498,7 +498,7 @@ def get_resolved_value(self, raw_value, allow_unresolved_envvars=False): if item_data is None: return None - if not isinstance(item_data, six.string_types): + if not isinstance(item_data, CIME.six.string_types): return item_data for m in env_ref_re.finditer(item_data): diff --git a/CIME/bless_test_results.py b/CIME/bless_test_results.py index 4ca6faedf6b..cf5e3124382 100644 --- a/CIME/bless_test_results.py +++ b/CIME/bless_test_results.py @@ -5,7 +5,7 @@ from CIME.hist_utils import generate_baseline, compare_baseline from CIME.case import Case from CIME.test_utils import get_test_status_files -import os, time, six +import os, time, CIME.six logger = logging.getLogger(__name__) ############################################################################### @@ -18,7 +18,7 @@ def bless_namelists(test_name, report_only, force, baseline_name, baseline_root, # Update namelist files logger.info("Test '{}' had namelist diff".format(test_name)) if (not report_only and - (force or six.moves.input("Update namelists (y/n)? ").upper() in ["Y", "YES"])): + (force or CIME.six.moves.input("Update namelists (y/n)? ").upper() in ["Y", "YES"])): create_test_gen_args = " -g {} ".format(baseline_name if get_model() == "cesm" else " -g -b {} ".format(baseline_name)) if new_test_root is not None: @@ -49,7 +49,7 @@ def bless_history(test_name, case, baseline_name, baseline_root, report_only, fo else: logger.info(cmp_comments) if (not report_only and - (force or six.moves.input("Update this diff (y/n)? ").upper() in ["Y", "YES"])): + (force or CIME.six.moves.input("Update this diff (y/n)? ").upper() in ["Y", "YES"])): gen_result, gen_comments = generate_baseline(case, baseline_dir=baseline_full_dir) if not gen_result: logger.warning("Hist file bless FAILED for test {}".format(test_name)) diff --git a/CIME/case/case.py b/CIME/case/case.py index 6ed6c211186..99960aea4cd 100644 --- a/CIME/case/case.py +++ b/CIME/case/case.py @@ -6,10 +6,10 @@ through the Case module. """ from copy import deepcopy -import glob, os, shutil, math, six, time, hashlib, socket, getpass +import glob, os, shutil, math, CIME.six, time, hashlib, socket, getpass from CIME.XML.standard_module_setup import * #pylint: disable=import-error,redefined-builtin -from six.moves import input +from CIME.six.moves import input from CIME.utils import expect, get_cime_root, append_status from CIME.utils import convert_to_type, get_model, set_model from CIME.utils import get_project, get_charge_account, check_name @@ -303,7 +303,7 @@ def get_values(self, item, attribute=None, resolved=True, subgroup=None): new_results = [] if resolved: for result in results: - if isinstance(result, six.string_types): + if isinstance(result, CIME.six.string_types): result = self.get_resolved_value(result) vtype = env_file.get_type_info(item) if vtype is not None or vtype != "char": @@ -329,7 +329,7 @@ def get_value(self, item, attribute=None, resolved=True, subgroup=None): result = env_file.get_value(item, attribute, resolved=False, subgroup=subgroup) if result is not None: - if resolved and isinstance(result, six.string_types): + if resolved and isinstance(result, CIME.six.string_types): result = self.get_resolved_value(result) vtype = env_file.get_type_info(item) if vtype is not None and vtype != "char": @@ -755,7 +755,7 @@ def get_compset_components(self): def __iter__(self): for entryid_file in self._env_entryid_files: for key, val in entryid_file: - if isinstance(val, six.string_types) and '$' in val: + if isinstance(val, CIME.six.string_types) and '$' in val: yield key, self.get_resolved_value(val) else: yield key, val diff --git a/CIME/case/case_submit.py b/CIME/case/case_submit.py index 1b02b5cc96b..b0a24ef5419 100644 --- a/CIME/case/case_submit.py +++ b/CIME/case/case_submit.py @@ -6,7 +6,7 @@ jobs. submit, check_case and check_da_settings are members of class Case in file case.py """ -from six.moves import configparser +from CIME.six.moves import configparser from CIME.XML.standard_module_setup import * from CIME.utils import expect, run_and_log_case_status, CIMEError from CIME.locked_files import unlock_file, lock_file diff --git a/CIME/case/check_lockedfiles.py b/CIME/case/check_lockedfiles.py index 3a4972fc28a..e007b0e8caa 100644 --- a/CIME/case/check_lockedfiles.py +++ b/CIME/case/check_lockedfiles.py @@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) -import glob, six +import glob, CIME.six def check_pelayouts_require_rebuild(self, models): """ @@ -108,7 +108,7 @@ def check_lockedfiles(self, skip=None): caseroot = self.get_value("CASEROOT") lockedfiles = glob.glob(os.path.join(caseroot, "LockedFiles", "*.xml")) skip = [] if skip is None else skip - skip = [skip] if isinstance(skip, six.string_types) else skip + skip = [skip] if isinstance(skip, CIME.six.string_types) else skip for lfile in lockedfiles: fpart = os.path.basename(lfile) # ignore files used for tests such as env_mach_pes.ERP1.xml by looking for extra dots in the name diff --git a/CIME/code_checker.py b/CIME/code_checker.py index aa9d9709132..d1c85e92bf3 100644 --- a/CIME/code_checker.py +++ b/CIME/code_checker.py @@ -120,7 +120,7 @@ def check_code(files, num_procs=10, interactive=False): if "scripts/lib/six.py" in files_to_check: files_to_check.remove("scripts/lib/six.py") - logger.info("Not checking contributed file six.py") + logger.info("Not checking contributed file CIME.six.py") expect(len(files_to_check) > 0, "No matching files found") diff --git a/CIME/compare_namelists.py b/CIME/compare_namelists.py index 9c890945eb1..00bde0ecf64 100644 --- a/CIME/compare_namelists.py +++ b/CIME/compare_namelists.py @@ -1,4 +1,4 @@ -import os, re, logging, six +import os, re, logging, CIME.six from collections import OrderedDict from CIME.utils import expect, CIMEError @@ -129,7 +129,7 @@ def _parse_namelists(namelist_lines, filename): ... dval = 'one->two', 'three -> four' ... mdval = 'one -> two', ... 'three -> four', - ... 'five -> six' + ... 'five -> CIME.six' ... nval = 1850 ... / ... @@ -394,7 +394,7 @@ def _compare_values(name, gold_value, comp_value, case): comments += " dict variable '{}' has extra key {} with value {}\n".format(name, key, comp_value[key]) else: - expect(isinstance(gold_value, six.string_types), "Unexpected type found: '{}'".format(type(gold_value))) + expect(isinstance(gold_value, CIME.six.string_types), "Unexpected type found: '{}'".format(type(gold_value))) norm_gold_value = _normalize_string_value(name, gold_value, case) norm_comp_value = _normalize_string_value(name, comp_value, case) @@ -420,7 +420,7 @@ def _compare_namelists(gold_namelists, comp_namelists, case): ... aval = 'one','two', 'three' ... maval = 'one', 'two', 'three', 'four' ... dval = 'one -> two', 'three -> four' - ... mdval = 'one -> two', 'three -> four', 'five -> six' + ... mdval = 'one -> two', 'three -> four', 'five -> CIME.six' ... nval = 1850 ... / ... &nml2 diff --git a/CIME/get_tests.py b/CIME/get_tests.py index a12a0fdf322..ca9e9413c12 100644 --- a/CIME/get_tests.py +++ b/CIME/get_tests.py @@ -1,7 +1,7 @@ import CIME.utils from CIME.utils import expect, convert_to_seconds, parse_test_name, get_cime_root from CIME.XML.machines import Machines -import six, sys, os +import CIME.six, sys, os # Expect that, if a model wants to use python-based test lists, they will have a file # $model/cime_config/tests.py , containing a test dictionary called _TESTS. Currently, @@ -156,7 +156,7 @@ def _get_key_data(raw_dict, key, the_type): expect(False, "Unsupported type {}".format(the_type)) else: val = raw_dict[key] - if the_type is tuple and isinstance(val, six.string_types): + if the_type is tuple and isinstance(val, CIME.six.string_types): val = (val, ) expect(isinstance(val, the_type), @@ -198,7 +198,7 @@ def get_test_suite(suite, machine=None, compiler=None, skip_inherit=False, skip_ inherits_from, _, _, tests_raw = get_test_data(suite) tests = [] for item in tests_raw: - expect(isinstance(item, six.string_types), "Bad type of test {}, expected string".format(item)) + expect(isinstance(item, CIME.six.string_types), "Bad type of test {}, expected string".format(item)) test_mods = None test_components = item.split(".") diff --git a/CIME/namelist.py b/CIME/namelist.py index d6c7647ed66..80df47976e6 100644 --- a/CIME/namelist.py +++ b/CIME/namelist.py @@ -108,7 +108,7 @@ from CIME.XML.standard_module_setup import * from CIME.utils import expect, string_in_list -import six +import CIME.six logger = logging.getLogger(__name__) @@ -730,21 +730,21 @@ def compress_literal_list(literals): # Otherwise, write out the previous literal and start tracking the # new one. rep_str = str(num_reps) + '*' if num_reps > 1 else '' - if isinstance(old_literal, six.string_types): + if isinstance(old_literal, CIME.six.string_types): compressed.append(rep_str + old_literal) else: compressed.append(rep_str + str(old_literal)) old_literal = literal num_reps = 1 rep_str = str(num_reps) + '*' if num_reps > 1 else '' - if isinstance(old_literal, six.string_types): + if isinstance(old_literal, CIME.six.string_types): compressed.append(rep_str + old_literal) else: compressed.append(rep_str + str(old_literal)) return compressed else: for literal in literals: - if isinstance(literal, six.string_types): + if isinstance(literal, CIME.six.string_types): compressed.append(literal) else: compressed.append(str(literal)) @@ -831,7 +831,7 @@ def parse(in_file=None, text=None, groupless=False, convert_tab_to_space=True): "Must specify an input file or text to the namelist parser.") expect(in_file is None or text is None, "Cannot specify both input file and text to the namelist parser.") - if isinstance(in_file, six.string_types): + if isinstance(in_file, CIME.six.string_types): logger.debug("Reading namelist at: {}".format(in_file)) with open(in_file) as in_file_obj: text = in_file_obj.read() @@ -1151,7 +1151,7 @@ def write(self, out_file, groups=None, append=False, format_='nml', sorted_group """ expect(format_ in ('nml', 'rc', 'nmlcontents'), "Namelist.write: unexpected output format {!r}".format(str(format_))) - if isinstance(out_file, six.string_types): + if isinstance(out_file, CIME.six.string_types): logger.debug("Writing namelist to: {}".format(out_file)) flag = 'a' if append else 'w' with open(out_file, flag) as file_obj: @@ -1215,7 +1215,7 @@ def write_nuopc(self, out_file, groups=None, sorted_groups=True): file object with a `write` method that accepts unicode. If specified, the `groups` argument specifies a subset of all groups to write out. """ - if isinstance(out_file, six.string_types): + if isinstance(out_file, CIME.six.string_types): logger.debug("Writing nuopc config file to: {}".format(out_file)) flag = 'w' with open(out_file, flag) as file_obj: diff --git a/CIME/six.py b/CIME/six.py index a0297d7113d..81633a67164 100644 --- a/CIME/six.py +++ b/CIME/six.py @@ -164,7 +164,7 @@ def _resolve(self): class _SixMetaPathImporter(object): """ - A meta path importer to import six.moves and its submodules. + A meta path importer to import CIME.six.moves and its submodules. This class implements a PEP302 finder and loader. It should be compatible with Python 2.5 and all existing versions of Python3 @@ -321,7 +321,7 @@ class _MovedItems(_LazyModule): class Module_six_moves_urllib_parse(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_parse""" + """Lazy loading of moved objects in CIME.six.moves.urllib_parse""" _urllib_parse_moved_attributes = [ @@ -363,7 +363,7 @@ class Module_six_moves_urllib_parse(_LazyModule): class Module_six_moves_urllib_error(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_error""" + """Lazy loading of moved objects in CIME.six.moves.urllib_error""" _urllib_error_moved_attributes = [ @@ -383,7 +383,7 @@ class Module_six_moves_urllib_error(_LazyModule): class Module_six_moves_urllib_request(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_request""" + """Lazy loading of moved objects in CIME.six.moves.urllib_request""" _urllib_request_moved_attributes = [ @@ -435,7 +435,7 @@ class Module_six_moves_urllib_request(_LazyModule): class Module_six_moves_urllib_response(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_response""" + """Lazy loading of moved objects in CIME.six.moves.urllib_response""" _urllib_response_moved_attributes = [ @@ -456,7 +456,7 @@ class Module_six_moves_urllib_response(_LazyModule): class Module_six_moves_urllib_robotparser(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_robotparser""" + """Lazy loading of moved objects in CIME.six.moves.urllib_robotparser""" _urllib_robotparser_moved_attributes = [ @@ -474,7 +474,7 @@ class Module_six_moves_urllib_robotparser(_LazyModule): class Module_six_moves_urllib(types.ModuleType): - """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" + """Create a CIME.six.moves.urllib namespace that resembles the Python 3 namespace""" __path__ = [] # mark as package parse = _importer._get_module("moves.urllib_parse") error = _importer._get_module("moves.urllib_error") @@ -490,12 +490,12 @@ def __dir__(self): def add_move(move): - """Add an item to six.moves.""" + """Add an item to CIME.six.moves.""" setattr(_MovedItems, move.name, move) def remove_move(name): - """Remove item from six.moves.""" + """Remove item from CIME.six.moves.""" try: delattr(_MovedItems, name) except AttributeError: @@ -872,14 +872,14 @@ def python_2_unicode_compatible(klass): __package__ = __name__ # see PEP 366 @ReservedAssignment if globals().get("__spec__") is not None: __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable -# Remove other six meta path importers, since they cause problems. This can -# happen if six is removed from sys.modules and then reloaded. (Setuptools does +# Remove other CIME.six meta path importers, since they cause problems. This can +# happen if CIME.six is removed from sys.modules and then reloaded. (Setuptools does # this for some reason.) if sys.meta_path: for i, importer in enumerate(sys.meta_path): - # Here's some real nastiness: Another "instance" of the six module might + # Here's some real nastiness: Another "instance" of the CIME.six module might # be floating around. Therefore, we can't use isinstance() to check for - # the six meta path importer, since the other six instance will have + # the CIME.six meta path importer, since the other CIME.six instance will have # inserted an importer with different class. if (type(importer).__name__ == "_SixMetaPathImporter" and importer.name == __name__): diff --git a/CIME/six_additions.py b/CIME/six_additions.py index 00743992563..6f7634b6ff0 100644 --- a/CIME/six_additions.py +++ b/CIME/six_additions.py @@ -1,8 +1,8 @@ -"""Additions to the six library needed for python 2/3 compatibility""" +"""Additions to the CIME.six library needed for python 2/3 compatibility""" -import six +import CIME.six -if six.PY3: +if CIME.six.PY3: # This is only available in python3.2 and later, so this code won't # run with python3 versions prior to 3.2 _assertNotRegex = "assertNotRegex" diff --git a/CIME/test_scheduler.py b/CIME/test_scheduler.py index fcb8c6eab6c..ddcaf4ec36f 100644 --- a/CIME/test_scheduler.py +++ b/CIME/test_scheduler.py @@ -12,7 +12,7 @@ from collections import OrderedDict from CIME.XML.standard_module_setup import * -import six +import CIME.six from CIME.get_tests import get_recommended_test_time, get_build_groups from CIME.utils import append_status, append_testlog, TESTS_FAILED_ERR_CODE, parse_test_name, get_full_test_name, get_model, \ convert_to_seconds, get_cime_root, get_project, get_timestamp, get_python_libs_root, get_cime_default_driver @@ -979,7 +979,7 @@ def _producer(self): logger.debug(" Current workload:") total_procs = 0 - for the_test, the_data in six.iteritems(threads_in_flight): + for the_test, the_data in CIME.six.iteritems(threads_in_flight): logger.debug(" {}: {} -> {}".format(the_test, the_data[2], the_data[1])) total_procs += the_data[1] diff --git a/CIME/tests/SystemTests/test_utils/test_user_nl_utils.py b/CIME/tests/SystemTests/test_utils/test_user_nl_utils.py index ceebde32ec6..4112001f693 100755 --- a/CIME/tests/SystemTests/test_utils/test_user_nl_utils.py +++ b/CIME/tests/SystemTests/test_utils/test_user_nl_utils.py @@ -5,7 +5,7 @@ import shutil import tempfile from CIME.SystemTests.test_utils import user_nl_utils -import six +import CIME.six class TestUserNLCopier(unittest.TestCase): @@ -109,7 +109,7 @@ def test_append_without_files_raises_exception(self): self.write_user_nl_file(component_exists, 'irrelevant contents') # Exercise & verify - six.assertRaisesRegex(self, RuntimeError, "No user_nl files found", + CIME.six.assertRaisesRegex(self, RuntimeError, "No user_nl files found", user_nl_utils.append_to_user_nl_files, caseroot = self._caseroot, component = component_for_append, diff --git a/CIME/tests/XML/test_expected_fails_file.py b/CIME/tests/XML/test_expected_fails_file.py index a9beea87d09..ecdb0c00f15 100755 --- a/CIME/tests/XML/test_expected_fails_file.py +++ b/CIME/tests/XML/test_expected_fails_file.py @@ -4,7 +4,7 @@ import os import shutil import tempfile -import six +import CIME.six from CIME.XML.expected_fails_file import ExpectedFailsFile from CIME.utils import CIMEError from CIME.expected_fails import ExpectedFails @@ -114,7 +114,7 @@ def test_invalid_file(self): with open(self._xml_filepath, 'w') as xml_file: xml_file.write(contents) - with six.assertRaisesRegex(self, CIMEError, "Schemas validity error"): + with CIME.six.assertRaisesRegex(self, CIMEError, "Schemas validity error"): _ = ExpectedFailsFile(self._xml_filepath) if __name__ == '__main__': diff --git a/CIME/tests/custom_assertions_test_status.py b/CIME/tests/custom_assertions_test_status.py index 17c4d5bf737..2eaed48118e 100644 --- a/CIME/tests/custom_assertions_test_status.py +++ b/CIME/tests/custom_assertions_test_status.py @@ -7,8 +7,8 @@ import unittest import re -import six -import six_additions +import CIME.six +import CIME.six_additions from CIME import test_status class CustomAssertionsTestStatus(unittest.TestCase): @@ -38,7 +38,7 @@ def assert_status_of_phase(self, output, status, phase, test_name, xfail=None): expect(xfail is None, "Unhandled value of xfail argument") expected_re = re.compile(expected, flags=re.MULTILINE) - six.assertRegex(self, output, expected_re) + CIME.six.assertRegex(self, output, expected_re) def assert_phase_absent(self, output, phase, test_name): """Asserts that 'output' does not contain a status line for the @@ -47,7 +47,7 @@ def assert_phase_absent(self, output, phase, test_name): self._test_name_and_phase_regex(test_name, phase), flags=re.MULTILINE) - six_additions.assertNotRegex(self, output, expected) + CIME.six_additions.assertNotRegex(self, output, expected) def assert_core_phases(self, output, test_name, fails): """Asserts that 'output' contains a line for each of the core test diff --git a/CIME/tests/test_cs_status.py b/CIME/tests/test_cs_status.py index 3fb8039b715..467c9b72f12 100755 --- a/CIME/tests/test_cs_status.py +++ b/CIME/tests/test_cs_status.py @@ -5,8 +5,8 @@ import os import tempfile import re -import six -import six_additions +import CIME.six +import CIME.six_additions from CIME.cs_status import cs_status from CIME import test_status from CIME.tests.custom_assertions_test_status import CustomAssertionsTestStatus @@ -25,7 +25,7 @@ class TestCsStatus(CustomAssertionsTestStatus): def setUp(self): self._testroot = tempfile.mkdtemp() - self._output = six.StringIO() + self._output = CIME.six.StringIO() def tearDown(self): self._output.close() @@ -125,7 +125,7 @@ def test_fails_only(self): self.assert_phase_absent(output=self._output.getvalue(), phase=phase, test_name=test_name) - six_additions.assertNotRegex(self, self._output.getvalue(), r'Overall:') + CIME.six_additions.assertNotRegex(self, self._output.getvalue(), r'Overall:') def test_count_fails(self): """Test the count of fails with three tests @@ -179,9 +179,9 @@ def test_count_fails(self): phase=phase_of_interest2, test_name=test_names[testnum]) count_regex1 = r'{} +non-passes: +2'.format(re.escape(phase_of_interest1)) - six.assertRegex(self, self._output.getvalue(), count_regex1) + CIME.six.assertRegex(self, self._output.getvalue(), count_regex1) count_regex2 = r'{} +non-passes: +1'.format(re.escape(phase_of_interest2)) - six.assertRegex(self, self._output.getvalue(), count_regex2) + CIME.six.assertRegex(self, self._output.getvalue(), count_regex2) def test_expected_fails(self): """With the expected_fails_file flag, expected failures should be flagged as such""" diff --git a/CIME/tests/test_user_mod_support.py b/CIME/tests/test_user_mod_support.py index bf4e2ab17c7..b57a449d9aa 100755 --- a/CIME/tests/test_user_mod_support.py +++ b/CIME/tests/test_user_mod_support.py @@ -6,7 +6,7 @@ import os from CIME.user_mod_support import apply_user_mods from CIME.utils import CIMEError -import six +import CIME.six # ======================================================================== # Define some parameters @@ -116,7 +116,7 @@ def test_basic(self): def test_keepexe(self): self.createUserMod("foo") - with six.assertRaisesRegex(self, CIMEError, "cannot have any source mods"): + with CIME.six.assertRaisesRegex(self, CIMEError, "cannot have any source mods"): apply_user_mods(self._caseroot, os.path.join(self._user_mods_parent_dir, "foo"), keepexe=True) diff --git a/CIME/utils.py b/CIME/utils.py index 783e3502415..7e2d95b33c6 100644 --- a/CIME/utils.py +++ b/CIME/utils.py @@ -7,10 +7,10 @@ import importlib.util import errno, signal, warnings, filecmp import stat as statlib -import six +import CIME.six from contextlib import contextmanager #pylint: disable=import-error -from six.moves import configparser +from CIME.six.moves import configparser from distutils import file_util # Return this error code if the scripts worked but tests failed @@ -505,12 +505,12 @@ def run_cmd(cmd, input_str=None, from_dir=None, verbose=None, # Real defaults for these value should be subprocess.PIPE if arg_stdout is _hack: arg_stdout = subprocess.PIPE - elif isinstance(arg_stdout, six.string_types): + elif isinstance(arg_stdout, CIME.six.string_types): arg_stdout = _convert_to_fd(arg_stdout, from_dir) if arg_stderr is _hack: arg_stderr = subprocess.STDOUT if combine_output else subprocess.PIPE - elif isinstance(arg_stderr, six.string_types): + elif isinstance(arg_stderr, CIME.six.string_types): arg_stderr = _convert_to_fd(arg_stdout, from_dir) if (verbose != False and (verbose or logger.isEnabledFor(logging.DEBUG))): @@ -549,7 +549,7 @@ def run_cmd(cmd, input_str=None, from_dir=None, verbose=None, # as much as possible, so we convert bytes to string (which is unicode in py3) via # decode. For python2, we do NOT want to do this since decode will yield unicode # strings which are not necessarily compatible with the system's default base str type. - if not six.PY2: + if not CIME.six.PY2: if output is not None: try: output = output.decode('utf-8', errors='ignore') @@ -568,7 +568,7 @@ def run_cmd(cmd, input_str=None, from_dir=None, verbose=None, errput = errput.strip() stat = proc.wait() - if six.PY2: + if CIME.six.PY2: if isinstance(arg_stdout, file): # pylint: disable=undefined-variable arg_stdout.close() # pylint: disable=no-member if isinstance(arg_stderr, file) and arg_stderr is not arg_stdout: # pylint: disable=undefined-variable @@ -618,11 +618,11 @@ def run_cmd_no_fail(cmd, input_str=None, from_dir=None, verbose=None, errput = output if not errput else errput if errput is None: if combine_output: - if isinstance(arg_stdout, six.string_types): + if isinstance(arg_stdout, CIME.six.string_types): errput = "See {}".format(_get_path(arg_stdout, from_dir)) else: errput = "" - elif isinstance(arg_stderr, six.string_types): + elif isinstance(arg_stderr, CIME.six.string_types): errput = "See {}".format(_get_path(arg_stderr, from_dir)) else: errput = "" @@ -1346,11 +1346,11 @@ def convert_to_string(value, type_str=None, vid=""): >>> convert_to_string(6.01, type_str="real") == '6.01' True """ - if value is not None and not isinstance(value, six.string_types): + if value is not None and not isinstance(value, CIME.six.string_types): if type_str == "char": - expect(isinstance(value, six.string_types), "Wrong type for entry id '{}'".format(vid)) + expect(isinstance(value, CIME.six.string_types), "Wrong type for entry id '{}'".format(vid)) elif type_str == "integer": - expect(isinstance(value, six.integer_types), "Wrong type for entry id '{}'".format(vid)) + expect(isinstance(value, CIME.six.integer_types), "Wrong type for entry id '{}'".format(vid)) value = str(value) elif type_str == "logical": expect(type(value) is bool, "Wrong type for entry id '{}'".format(vid)) diff --git a/CIME/wait_for_tests.py b/CIME/wait_for_tests.py index 4db9a2872cd..740e9f965fb 100644 --- a/CIME/wait_for_tests.py +++ b/CIME/wait_for_tests.py @@ -1,5 +1,5 @@ #pylint: disable=import-error -from six.moves import queue +from CIME.six.moves import queue import os, time, threading, socket, signal, shutil, glob #pylint: disable=import-error from distutils.spawn import find_executable diff --git a/scripts/tests/scripts_regression_tests.py b/scripts/tests/scripts_regression_tests.py index 876a7348366..73a1b2a4590 100755 --- a/scripts/tests/scripts_regression_tests.py +++ b/scripts/tests/scripts_regression_tests.py @@ -16,8 +16,8 @@ # Remove all pyc files to ensure we're testing the right things import subprocess, argparse subprocess.call('/bin/rm -f $(find . -name "*.pyc")', shell=True, cwd=LIB_DIR) -import six -from six import assertRaisesRegex +import CIME.six +from CIME.six import assertRaisesRegex import stat as osstat import collections @@ -2094,7 +2094,7 @@ def test_cime_case_prereq(self): for batch_cmd in batch_commands: self.assertTrue(isinstance(batch_cmd, collections.Sequence), "case.submit_jobs did not return a sequence of sequences") self.assertTrue(len(batch_cmd) > batch_cmd_index, "case.submit_jobs returned internal sequences with length <= {}".format(batch_cmd_index)) - self.assertTrue(isinstance(batch_cmd[1], six.string_types), "case.submit_jobs returned internal sequences without the batch command string as the second parameter: {}".format(batch_cmd[1])) + self.assertTrue(isinstance(batch_cmd[1], CIME.six.string_types), "case.submit_jobs returned internal sequences without the batch command string as the second parameter: {}".format(batch_cmd[1])) batch_cmd_args = batch_cmd[1] jobid_ident = "jobid" @@ -2756,8 +2756,8 @@ def get_macros(macro_maker, build_xml, build_system): """ # Build.write_macros expects file-like objects as input, so # we need to wrap the strings in StringIO objects. - xml = six.StringIO(str(build_xml)) - output = six.StringIO() + xml = CIME.six.StringIO(str(build_xml)) + output = CIME.six.StringIO() output_format = None if build_system == "Makefile": output_format = "make"