Skip to content

Commit 7dbba36

Browse files
committed
Merge branch 'develop' into 5.0.x
2 parents 7b082cb + 415cbcd commit 7dbba36

File tree

23 files changed

+112
-73
lines changed

23 files changed

+112
-73
lines changed

easybuild/base/fancylogger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def makeRecord(self, name, level, pathname, lineno, msg, args, excinfo, func=Non
285285
overwrite make record to use a fancy record (with more options)
286286
"""
287287
logrecordcls = logging.LogRecord
288-
if hasattr(self, 'fancyrecord') and self.fancyrecord:
288+
if getattr(self, 'fancyrecord', None):
289289
logrecordcls = FancyLogRecord
290290
try:
291291
new_msg = str(msg)

easybuild/base/generaloption.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def set_columns(cols=None):
9393
pass
9494

9595
if cols is not None:
96-
os.environ['COLUMNS'] = "%s" % cols
96+
os.environ['COLUMNS'] = str(cols)
9797

9898

9999
def what_str_list_tuple(name):
@@ -825,8 +825,8 @@ def get_env_options(self):
825825
self.environment_arguments.append("%s=%s" % (lo, val))
826826
else:
827827
# interpretation of values: 0/no/false means: don't set it
828-
if ("%s" % val).lower() not in ("0", "no", "false",):
829-
self.environment_arguments.append("%s" % lo)
828+
if str(val).lower() not in ("0", "no", "false",):
829+
self.environment_arguments.append(str(lo))
830830
else:
831831
self.log.debug("Environment variable %s is not set" % env_opt_name)
832832

@@ -1034,7 +1034,7 @@ def main_options(self):
10341034
# make_init is deprecated
10351035
if hasattr(self, 'make_init'):
10361036
self.log.debug('main_options: make_init is deprecated. Rename function to main_options.')
1037-
getattr(self, 'make_init')()
1037+
self.make_init()
10381038
else:
10391039
# function names which end with _options and do not start with main or _
10401040
reg_main_options = re.compile("^(?!_|main).*_options$")
@@ -1192,7 +1192,7 @@ def add_group_parser(self, opt_dict, description, prefix=None, otherdefaults=Non
11921192
for extra_detail in details[4:]:
11931193
if isinstance(extra_detail, (list, tuple,)):
11941194
# choices
1195-
nameds['choices'] = ["%s" % x for x in extra_detail] # force to strings
1195+
nameds['choices'] = [str(x) for x in extra_detail] # force to strings
11961196
hlp += ' (choices: %s)' % ', '.join(nameds['choices'])
11971197
elif isinstance(extra_detail, str) and len(extra_detail) == 1:
11981198
args.insert(0, "-%s" % extra_detail)

easybuild/base/optcomplete.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,15 @@ def autocomplete(parser, arg_completer=None, opt_completer=None, subcmd_complete
512512
if option:
513513
if option.nargs > 0:
514514
optarg = True
515-
if hasattr(option, 'completer'):
515+
try:
516516
completer = option.completer
517-
elif option.choices:
518-
completer = ListCompleter(option.choices)
519-
elif option.type in ('string',):
520-
completer = opt_completer
521-
else:
522-
completer = NoneCompleter()
517+
except AttributeError:
518+
if option.choices:
519+
completer = ListCompleter(option.choices)
520+
elif option.type in ('string',):
521+
completer = opt_completer
522+
else:
523+
completer = NoneCompleter()
523524
# Warn user at least, it could help him figure out the problem.
524525
elif hasattr(option, 'completer'):
525526
msg = "Error: optparse option with a completer does not take arguments: %s" % (option)
@@ -615,11 +616,9 @@ class CmdComplete(object):
615616
def autocomplete(self, completer=None):
616617
parser = OPTIONPARSER_CLASS(self.__doc__.strip())
617618
if hasattr(self, 'addopts'):
618-
fnc = getattr(self, 'addopts')
619-
fnc(parser)
619+
self.addopts(parser)
620620

621-
if hasattr(self, 'completer'):
622-
completer = getattr(self, 'completer')
621+
completer = getattr(self, 'completer', completer)
623622

624623
return autocomplete(parser, completer)
625624

easybuild/framework/easyconfig/format/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def parse(self, configobj):
369369
for key, value in self.supported.items():
370370
if key not in self.VERSION_OPERATOR_VALUE_TYPES:
371371
raise EasyBuildError('Unsupported key %s in %s section', key, self.SECTION_MARKER_SUPPORTED)
372-
self.sections['%s' % key] = value
372+
self.sections[key] = value
373373

374374
for key, supported_key, fn_name in [('version', 'versions', 'get_version_str'),
375375
('toolchain', 'toolchains', 'as_dict')]:

easybuild/framework/easyconfig/format/pyheaderconfigobj.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,13 @@ def pyheader_env(self):
233233
current_builtins = globals()['__builtins__']
234234
builtins = {}
235235
for name in self.PYHEADER_ALLOWED_BUILTINS:
236-
if hasattr(current_builtins, name):
236+
try:
237237
builtins[name] = getattr(current_builtins, name)
238-
elif isinstance(current_builtins, dict) and name in current_builtins:
239-
builtins[name] = current_builtins[name]
240-
else:
241-
self.log.warning('No builtin %s found.' % name)
238+
except AttributeError:
239+
if isinstance(current_builtins, dict) and name in current_builtins:
240+
builtins[name] = current_builtins[name]
241+
else:
242+
self.log.warning('No builtin %s found.' % name)
242243
global_vars['__builtins__'] = builtins
243244
self.log.debug("Available builtins: %s" % global_vars['__builtins__'])
244245

easybuild/framework/easyconfig/tweak.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def __repr__(self):
323323
newval = "%s + %s" % (fval, res.group('val'))
324324
_log.debug("Prepending %s to %s" % (fval, key))
325325
else:
326-
newval = "%s" % fval
326+
newval = str(fval)
327327
_log.debug("Overwriting %s with %s" % (key, fval))
328328
ectxt = regexp.sub("%s = %s" % (res.group('key'), newval), ectxt)
329329
_log.info("Tweaked %s list to '%s'" % (key, newval))

easybuild/tools/configobj.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ def set_section(in_section, this_section):
12521252
self.configspec = None
12531253
return
12541254

1255-
elif getattr(infile, 'read', MISSING) is not MISSING:
1255+
elif hasattr(infile, 'read'):
12561256
# This supports file like objects
12571257
infile = infile.read() or []
12581258
# needs splitting into lines - but needs doing *after* decoding

easybuild/tools/docs.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def avail_easyconfig_licenses_md():
307307
lics = sorted(EASYCONFIG_LICENSES_DICT.items())
308308
table_values = [
309309
["``%s``" % lic().name for _, lic in lics],
310-
["%s" % lic().description for _, lic in lics],
310+
[lic().description or '' for _, lic in lics],
311311
["``%s``" % lic().version for _, lic in lics],
312312
]
313313

@@ -1250,10 +1250,9 @@ def avail_toolchain_opts(name, output_format=FORMAT_TXT):
12501250

12511251
tc_dict = {}
12521252
for cst in ['COMPILER_SHARED_OPTS', 'COMPILER_UNIQUE_OPTS', 'MPI_SHARED_OPTS', 'MPI_UNIQUE_OPTS']:
1253-
if hasattr(tc, cst):
1254-
opts = getattr(tc, cst)
1255-
if opts is not None:
1256-
tc_dict.update(opts)
1253+
opts = getattr(tc, cst, None)
1254+
if opts is not None:
1255+
tc_dict.update(opts)
12571256

12581257
return generate_doc('avail_toolchain_opts_%s' % output_format, [name, tc_dict])
12591258

@@ -1267,7 +1266,7 @@ def avail_toolchain_opts_md(name, tc_dict):
12671266
tc_items = sorted(tc_dict.items())
12681267
table_values = [
12691268
['``%s``' % val[0] for val in tc_items],
1270-
['%s' % val[1][1] for val in tc_items],
1269+
[val[1][1] for val in tc_items],
12711270
['``%s``' % val[1][0] for val in tc_items],
12721271
]
12731272

@@ -1285,7 +1284,7 @@ def avail_toolchain_opts_rst(name, tc_dict):
12851284
tc_items = sorted(tc_dict.items())
12861285
table_values = [
12871286
['``%s``' % val[0] for val in tc_items],
1288-
['%s' % val[1][1] for val in tc_items],
1287+
[val[1][1] for val in tc_items],
12891288
['``%s``' % val[1][0] for val in tc_items],
12901289
]
12911290

easybuild/tools/github.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,9 @@ def setup_repo_from(git_repo, github_url, target_account, branch_name, silent=Fa
720720
raise EasyBuildError("Fetching branch '%s' from remote %s failed: empty result", branch_name, origin)
721721

722722
# git checkout -b <branch>; git pull
723-
if hasattr(origin.refs, branch_name):
723+
try:
724724
origin_branch = getattr(origin.refs, branch_name)
725-
else:
725+
except AttributeError:
726726
raise EasyBuildError("Branch '%s' not found at %s", branch_name, github_url)
727727

728728
_log.debug("Checking out branch '%s' from remote %s", branch_name, github_url)

easybuild/tools/module_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ def get_description(self, conflict=True):
12881288
extensions_list = self._generate_extensions_list()
12891289

12901290
if extensions_list:
1291-
extensions_stmt = 'extensions("%s")' % ','.join(['%s' % x for x in extensions_list])
1291+
extensions_stmt = 'extensions("%s")' % ','.join([str(x) for x in extensions_list])
12921292
# put this behind a Lmod version check as 'extensions' is only (well) supported since Lmod 8.2.8,
12931293
# see https://lmod.readthedocs.io/en/latest/330_extensions.html#module-extensions and
12941294
# https://github.com/TACC/Lmod/issues/428

0 commit comments

Comments
 (0)