diff options
| author | Jan Barta <55042barta@sstebrno.eu> | 2016-06-02 09:58:52 +0200 |
|---|---|---|
| committer | Martin Basti <mbasti@redhat.com> | 2016-09-22 16:52:57 +0200 |
| commit | 36484e8672f5ee1fdc2bd57622e330ab8dbb7671 (patch) | |
| tree | 1f06a3e4aebbc0e6e7fe28e15c9e677e396932a3 | |
| parent | 929086e0992cc32a654b4dfa435f536ecb0c665b (diff) | |
| download | freeipa-36484e8672f5ee1fdc2bd57622e330ab8dbb7671.tar.gz freeipa-36484e8672f5ee1fdc2bd57622e330ab8dbb7671.tar.xz freeipa-36484e8672f5ee1fdc2bd57622e330ab8dbb7671.zip | |
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>
| -rw-r--r-- | ipalib/config.py | 8 | ||||
| -rw-r--r-- | ipaplatform/base/services.py | 12 | ||||
| -rw-r--r-- | ipapython/ipautil.py | 10 | ||||
| -rw-r--r-- | ipapython/nsslib.py | 5 | ||||
| -rw-r--r-- | ipapython/sysrestore.py | 5 | ||||
| -rw-r--r-- | ipaserver/install/ca.py | 7 | ||||
| -rw-r--r-- | ipaserver/plugins/dogtag.py | 10 | ||||
| -rw-r--r-- | ipatests/test_integration/tasks.py | 12 | ||||
| -rw-r--r-- | pylintrc | 1 |
9 files changed, 15 insertions, 55 deletions
diff --git a/ipalib/config.py b/ipalib/config.py index 55a95bb98..eb6c3aed3 100644 --- a/ipalib/config.py +++ b/ipalib/config.py @@ -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' diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py index a36b2f4ff..750d97953 100644 --- a/ipaplatform/base/services.py +++ b/ipaplatform/base/services.py @@ -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)) diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 64901b524..62d029d41 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -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 diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py index b5e5b6586..1573de96f 100644 --- a/ipapython/nsslib.py +++ b/ipapython/nsslib.py @@ -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: diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py index e0d090856..cd09caee5 100644 --- a/ipapython/sysrestore.py +++ b/ipapython/sysrestore.py @@ -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 diff --git a/ipaserver/install/ca.py b/ipaserver/install/ca.py index 00e0b038c..dcda19a22 100644 --- a/ipaserver/install/ca.py +++ b/ipaserver/install/ca.py @@ -127,14 +127,9 @@ 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(): diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py index 644b41e90..ffe6ead26 100644 --- a/ipaserver/plugins/dogtag.py +++ b/ipaserver/plugins/dogtag.py @@ -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 diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py index b39df34a5..6b3082a78 100644 --- a/ipatests/test_integration/tasks.py +++ b/ipatests/test_integration/tasks.py @@ -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): @@ -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, |
