pylint: fix simplifiable-if-statement warnings

fix inefficient if statements, enable pylint check

Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
Jan Barta 2016-06-02 09:58:52 +02:00 committed by Martin Basti
parent 929086e099
commit 36484e8672
9 changed files with 15 additions and 55 deletions

View File

@ -455,14 +455,10 @@ class Env(object):
# Determine if running in source tree:
if 'in_tree' not in self:
if (
self.in_tree = (
self.bin == self.site_packages
and path.isfile(path.join(self.bin, 'setup.py'))
):
self.in_tree = True
else:
self.in_tree = False
)
if self.in_tree and 'mode' not in self:
self.mode = 'developer'

View File

@ -271,10 +271,8 @@ class SystemdService(PlatformService):
ipautil.run(args, skip_output=not capture_output)
if getattr(self.api.env, 'context', None) in ['ipactl', 'installer']:
update_service_list = True
else:
update_service_list = False
update_service_list = getattr(self.api.env, 'context',
None) in ['ipactl', 'installer']
super(SystemdService, self).stop(
instance_name,
update_service_list=update_service_list)
@ -284,10 +282,8 @@ class SystemdService(PlatformService):
self.service_instance(instance_name)],
skip_output=not capture_output)
if getattr(self.api.env, 'context', None) in ['ipactl', 'installer']:
update_service_list = True
else:
update_service_list = False
update_service_list = getattr(self.api.env, 'context',
None) in ['ipactl', 'installer']
if wait and self.is_running(instance_name):
self.wait_for_open_ports(self.service_instance(instance_name))

View File

@ -519,20 +519,14 @@ def nolog_replace(string, nolog):
def file_exists(filename):
try:
mode = os.stat(filename)[stat.ST_MODE]
if stat.S_ISREG(mode):
return True
else:
return False
return bool(stat.S_ISREG(mode))
except Exception:
return False
def dir_exists(filename):
try:
mode = os.stat(filename)[stat.ST_MODE]
if stat.S_ISDIR(mode):
return True
else:
return False
return bool(stat.S_ISDIR(mode))
except Exception:
return False

View File

@ -74,10 +74,7 @@ def auth_certificate_callback(sock, check_sig, is_server, certdb):
', '.join(nss.cert_usage_flags(intended_usage)))
# Is the intended usage a proper subset of the approved usage
if approved_usage & intended_usage:
cert_is_valid = True
else:
cert_is_valid = False
cert_is_valid = bool(approved_usage & intended_usage)
# If this is a server, we're finished
if is_server or not cert_is_valid:

View File

@ -437,7 +437,4 @@ class StateFile:
Can be used to determine if a service is configured.
"""
if module in self.modules:
return True
else:
return False
return module in self.modules

View File

@ -126,15 +126,10 @@ def install_step_0(standalone, replica_config, options):
if replica_config is not None:
# Configure the CA if necessary
if standalone:
postinstall = True
else:
postinstall = False
if standalone:
api.Backend.ldap2.disconnect()
cainstance.install_replica_ca(replica_config, postinstall,
cainstance.install_replica_ca(replica_config, standalone,
ra_p12=getattr(options, 'ra_p12', None))
if standalone and not api.Backend.ldap2.isconnected():

View File

@ -1750,10 +1750,7 @@ class ra(rabase.rabase, RestClient):
# Return command result
cmd_result = {}
if parse_result.get('revoked') == 'yes':
cmd_result['revoked'] = True
else:
cmd_result['revoked'] = False
cmd_result['revoked'] = parse_result.get('revoked') == 'yes'
return cmd_result
@ -1814,10 +1811,7 @@ class ra(rabase.rabase, RestClient):
if 'error_string' in parse_result:
cmd_result['error_string'] = parse_result['error_string']
if parse_result.get('unrevoked') == 'yes':
cmd_result['unrevoked'] = True
else:
cmd_result['unrevoked'] = False
cmd_result['unrevoked'] = parse_result.get('unrevoked') == 'yes'
return cmd_result

View File

@ -172,11 +172,7 @@ def host_service_active(host, service):
res = host.run_command(['systemctl', 'is-active', '--quiet', service],
raiseonerr=False)
if res.returncode == 0:
return True
else:
return False
return res.returncode == 0
def fix_apache_semaphores(master):
systemd_available = master.transport.file_exists(paths.SYSTEMCTL)
@ -325,11 +321,7 @@ def master_authoritative_for_client_domain(master, client):
zone = ".".join(client.hostname.split('.')[1:])
result = master.run_command(["ipa", "dnszone-show", zone],
raiseonerr=False)
if result.returncode == 0:
return True
else:
return False
return result.returncode == 0
def replica_prepare(master, replica, extra_args=(),
raiseonerr=True, stdin_text=None):

View File

@ -23,7 +23,6 @@ disable=
interface-not-implemented,
no-self-use,
redefined-variable-type,
simplifiable-if-statement,
too-few-public-methods,
too-many-ancestors,
too-many-arguments,