diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index a8cca8faaf..830d74c01e 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -108,7 +108,7 @@ class Inventory(object): inv_file = open(host_list) first_line = inv_file.readlines()[0] inv_file.close() - if first_line.find('#!') == 0: + if first_line.startswith('#!'): shebang_present = True except: pass diff --git a/lib/ansible/module_utils/known_hosts.py b/lib/ansible/module_utils/known_hosts.py index e6912d9184..68ef282831 100644 --- a/lib/ansible/module_utils/known_hosts.py +++ b/lib/ansible/module_utils/known_hosts.py @@ -98,7 +98,7 @@ def not_in_host_file(self, host): host_fh.close() for line in data.split("\n"): - if line is None or line.find(" ") == -1: + if line is None or " " not in line: continue tokens = line.split() if tokens[0].find(HASHED_KEY_MAGIC) == 0: diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 972089d6a3..2b86034bde 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -314,7 +314,7 @@ def parse_json(raw_data): raise for t in tokens: - if t.find("=") == -1: + if "=" not in t: raise errors.AnsibleError("failed to parse: %s" % orig_data) (key,value) = t.split("=", 1) if key == 'changed' or 'failed': @@ -1035,7 +1035,7 @@ def listify_lookup_plugin_terms(terms, basedir, inject): # not sure why the "/" is in above code :) try: new_terms = template.template(basedir, "{{ %s }}" % terms, inject) - if isinstance(new_terms, basestring) and new_terms.find("{{") != -1: + if isinstance(new_terms, basestring) and "{{" in new_terms: pass else: terms = new_terms diff --git a/library/cloud/gc_storage b/library/cloud/gc_storage index cbf72aa8e9..4bbf9eabae 100644 --- a/library/cloud/gc_storage +++ b/library/cloud/gc_storage @@ -154,7 +154,7 @@ def keysum(module, gs, bucket, obj): key_check = bucket.get_key(obj) if key_check: md5_remote = key_check.etag[1:-1] - etag_multipart = md5_remote.find('-')!=-1 #Check for multipart, etag is not md5 + etag_multipart = '-' in md5_remote # Check for multipart, etag is not md5 if etag_multipart is True: module.fail_json(msg="Files uploaded with multipart of gs are not supported with checksum, unable to compute checksum.") return md5_remote diff --git a/library/cloud/s3 b/library/cloud/s3 index 6d64a3f43f..aaa2e0f4ff 100644 --- a/library/cloud/s3 +++ b/library/cloud/s3 @@ -147,7 +147,7 @@ def keysum(module, s3, bucket, obj): key_check = bucket.get_key(obj) if key_check: md5_remote = key_check.etag[1:-1] - etag_multipart = md5_remote.find('-')!=-1 #Check for multipart, etag is not md5 + etag_multipart = '-' in md5_remote # Check for multipart, etag is not md5 if etag_multipart is True: module.fail_json(msg="Files uploaded with multipart of s3 are not supported with checksum, unable to compute checksum.") return md5_remote diff --git a/library/system/service b/library/system/service index 97a970a951..141b2ac418 100644 --- a/library/system/service +++ b/library/system/service @@ -1008,7 +1008,7 @@ class SunOSService(Service): # enabled true # enabled false for line in stdout.split("\n"): - if line.find("enabled") == 0: + if line.startswith("enabled"): if "true" in line: enabled = True if "temporary" in line: