mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
pylint: Fix consider-using-dict-items
Pylint 2.9 introduced new check: > New checker consider-using-dict-items. Emitted when iterating over dictionary keys and then indexing the same dictionary with the key within loop body. Fixes: https://pagure.io/freeipa/issue/9117 Signed-off-by: Stanislav Levin <slev@altlinux.org> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
committed by
Rob Crittenden
parent
f9d0fc8a8c
commit
851f6d48ac
@@ -294,8 +294,8 @@ class IntegrationLogs:
|
||||
def init_method_logs(self):
|
||||
"""Initilize method logs with the class ones"""
|
||||
self._method_logs = {}
|
||||
for k in self._class_logs:
|
||||
self._method_logs[k] = list(self._class_logs[k])
|
||||
for host, logs in self._class_logs.items():
|
||||
self._method_logs[host] = list(logs)
|
||||
|
||||
def collect_class_log(self, host, filename):
|
||||
"""Add class scope log
|
||||
|
||||
@@ -499,13 +499,13 @@ class TestEPN(IntegrationTest):
|
||||
),
|
||||
)
|
||||
|
||||
for key in users:
|
||||
for user_info in users.values():
|
||||
tasks.user_add(
|
||||
self.master,
|
||||
users[key]["uid"],
|
||||
user_info["uid"],
|
||||
extra_args=[
|
||||
"--password-expiration",
|
||||
users[key]["krbpasswordexpiration"],
|
||||
user_info["krbpasswordexpiration"],
|
||||
],
|
||||
password=None,
|
||||
)
|
||||
|
||||
@@ -1719,8 +1719,8 @@ def modify_permissions():
|
||||
|
||||
# Restore the previous state
|
||||
host = state.pop('host')
|
||||
for path in state:
|
||||
(owner, group, mode) = state[path].split(':')
|
||||
for path, path_state in state.items():
|
||||
(owner, group, mode) = path_state.split(":", maxsplit=2)
|
||||
host.run_command(["chown", "%s:%s" % (owner, group), path])
|
||||
host.run_command(["chmod", mode, path])
|
||||
|
||||
|
||||
@@ -73,11 +73,11 @@ class TestNFS(IntegrationTest):
|
||||
"euripides": "s"
|
||||
}
|
||||
temp_pass = 'temppass'
|
||||
for user in users:
|
||||
for user, last in users.items():
|
||||
self.master.run_command([
|
||||
"ipa", "user-add",
|
||||
"%s" % user, "--first", "%s" % user,
|
||||
"--last", "%s" % users[user],
|
||||
user, "--first", user,
|
||||
"--last", last,
|
||||
'--password'], stdin_text="%s\n%s\n" % (temp_pass, temp_pass)
|
||||
)
|
||||
self.master.run_command(["kdestroy", "-A"])
|
||||
@@ -111,12 +111,12 @@ class TestNFS(IntegrationTest):
|
||||
"stdnfs": "*(ro)",
|
||||
"home": "*(sec=krb5p,rw)"
|
||||
}
|
||||
for export in exports:
|
||||
for export, options in exports.items():
|
||||
exportpath = os.sep.join(('', basedir, export))
|
||||
exportfile = os.sep.join((
|
||||
'', 'etc', 'exports.d', "%s.exports" % export
|
||||
))
|
||||
exportline = " ".join((exportpath, exports[export]))
|
||||
exportline = " ".join((exportpath, options))
|
||||
nfssrv.run_command(["mkdir", "-p", exportpath])
|
||||
nfssrv.run_command(["chmod", "770", exportpath])
|
||||
nfssrv.put_file_contents(exportfile, exportline)
|
||||
|
||||
@@ -783,8 +783,8 @@ class TestSubCAkeyReplication(IntegrationTest):
|
||||
# give replication some time
|
||||
time.sleep(15)
|
||||
|
||||
for name in subcas:
|
||||
self.check_subca(replica, name, subcas[name])
|
||||
for name, cert_nick in subcas.items():
|
||||
self.check_subca(replica, name, cert_nick)
|
||||
self.del_subca(replica, name)
|
||||
|
||||
|
||||
|
||||
@@ -83,12 +83,11 @@ def check_removal_disconnects_topology(
|
||||
)
|
||||
}
|
||||
|
||||
for suffix in err_messages_by_suffix:
|
||||
for suffix, err_str in err_messages_by_suffix.items():
|
||||
if suffix in affected_suffixes:
|
||||
tasks.assert_error(
|
||||
result, err_messages_by_suffix[suffix], returncode=1)
|
||||
tasks.assert_error(result, err_str, returncode=1)
|
||||
else:
|
||||
assert err_messages_by_suffix[suffix] not in result.stderr_text
|
||||
assert err_str not in result.stderr_text
|
||||
|
||||
|
||||
class ServerDelBase(IntegrationTest):
|
||||
|
||||
@@ -196,24 +196,26 @@ class UserTracker(CertmapdataMixin, KerberosAliasMixin, Tracker):
|
||||
ipantsecurityidentifier=[fuzzy_user_or_group_sid],
|
||||
)
|
||||
|
||||
for key in self.kwargs:
|
||||
if key == u'krbprincipalname':
|
||||
for key, value in self.kwargs.items():
|
||||
if key == "krbprincipalname":
|
||||
try:
|
||||
self.attrs[key] = [u'%s@%s' % (
|
||||
(self.kwargs[key].split('@'))[0].lower(),
|
||||
(self.kwargs[key].split('@'))[1]
|
||||
)]
|
||||
princ_splitted = value.split("@", maxsplit=1)
|
||||
self.attrs[key] = [
|
||||
"{}@{}".format(
|
||||
princ_splitted[0].lower(),
|
||||
princ_splitted[1],
|
||||
)
|
||||
]
|
||||
except IndexError:
|
||||
# we can provide just principal part
|
||||
self.attrs[key] = [u'%s@%s' % (
|
||||
(self.kwargs[key].lower(),
|
||||
self.api.env.realm)
|
||||
)]
|
||||
self.attrs[key] = [
|
||||
"{}@{}".format(value.lower(), self.api.env.realm)
|
||||
]
|
||||
else:
|
||||
if type(self.kwargs[key]) is not list:
|
||||
self.attrs[key] = [self.kwargs[key]]
|
||||
if not isinstance(value, list):
|
||||
self.attrs[key] = [value]
|
||||
else:
|
||||
self.attrs[key] = self.kwargs[key]
|
||||
self.attrs[key] = value
|
||||
|
||||
self.exists = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user