Address misc pylint issues in CLI scripts

The CLI script files have additional pylint issues that were not noticed
before. The violations include using dict.keys() without directly
iterating of the result, inconsistent return statements and set([])
instead of set literals.

* dict-keys-not-iterating
* inconsistent-return-statements
* onsider-using-set-comprehensio

See: https://pagure.io/freeipa/issue/7772
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
This commit is contained in:
Christian Heimes 2018-11-26 11:42:56 +01:00
parent d8791f8f9b
commit bb4b558164
4 changed files with 11 additions and 9 deletions

View File

@ -70,8 +70,7 @@ def parse_options():
if len(args):
n = len(args) - 1
k = commands.keys()
for cmd in k:
for cmd in commands:
if cmd == args[0]:
v = commands[cmd]
err = None

View File

@ -209,6 +209,8 @@ def main(debug=DEBUG, time_limit=TIME_LIMIT):
except Exception as e:
logger.error('%s', str(e))
return 1
else:
return 0
if __name__ == '__main__':

View File

@ -637,6 +637,7 @@ def main():
time.sleep(3600)
logger.info(
"Connection check timeout: terminating listening program")
return 0
if __name__ == "__main__":

View File

@ -111,8 +111,7 @@ def parse_options():
if len(args):
n = len(args) - 1
k = commands.keys()
for cmd in k:
for cmd in commands:
if cmd == args[0]:
v = commands[cmd]
err = None
@ -432,7 +431,7 @@ def get_ruv_both_suffixes(realm, host, dirman_passwd, verbose, nolookup=False):
print(err)
logger.debug('%s', err)
if not ruvs.keys():
if not ruvs:
raise NoRUVsFound("No RUV records found.")
return ruvs
@ -480,6 +479,7 @@ def get_rid_by_host(realm, sourcehost, host, dirman_passwd, nolookup=False):
for (netloc, rid) in servers:
if '%s:389' % host == netloc:
return int(rid)
return None
def clean_ruv(realm, ruv, options):
@ -717,15 +717,15 @@ def clean_dangling_ruvs(realm, host, options):
# get_ruv_both_suffixes returns server names with :port
# This needs needs to be split off
if ruv_dict.get('domain'):
master_info['ruvs'] = set([
master_info['ruvs'] = {
(re.sub(':\d+', '', x), y)
for (x, y) in ruv_dict['domain']
])
}
if ruv_dict.get('ca'):
master_info['csruvs'] = set([
master_info['csruvs'] = {
(re.sub(':\d+', '', x), y)
for (x, y) in ruv_dict['ca']
])
}
except Exception as e:
sys.exit("Failed to obtain information from '{host}': {error}"
.format(host=master_cn, error=str(e)))