Skip to content

Commit

Permalink
Fixes six and six_additions imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonb5 committed Sep 17, 2021
1 parent 2c5c043 commit 407a345
Show file tree
Hide file tree
Showing 24 changed files with 89 additions and 89 deletions.
2 changes: 1 addition & 1 deletion CIME/BuildTools/macrowriterbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
4 changes: 2 additions & 2 deletions CIME/SystemTests/system_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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__()
Expand Down
4 changes: 2 additions & 2 deletions CIME/XML/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions CIME/XML/entry_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions CIME/XML/generic_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -357,15 +357,15 @@ 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()

# xmllint provides a better format option for the output file
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))
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions CIME/bless_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

###############################################################################
Expand All @@ -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:
Expand Down Expand Up @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions CIME/case/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand All @@ -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":
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CIME/case/case_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions CIME/case/check_lockedfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

logger = logging.getLogger(__name__)

import glob, six
import glob, CIME.six

def check_pelayouts_require_rebuild(self, models):
"""
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CIME/code_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
8 changes: 4 additions & 4 deletions CIME/compare_namelists.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
... /
...
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions CIME/get_tests.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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(".")
Expand Down
14 changes: 7 additions & 7 deletions CIME/namelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 407a345

Please sign in to comment.