PEP 8 cleanup. (#20789)

* PEP 8 E703 cleanup.
* PEP 8 E701 cleanup.
* PEP 8 E711 cleanup.
* PEP 8 W191 and E101 cleanup.
This commit is contained in:
Matt Clay
2017-01-28 00:12:11 -08:00
committed by GitHub
parent c29d1e3162
commit d0d1158c5e
72 changed files with 184 additions and 174 deletions

View File

@@ -189,7 +189,7 @@ def find_vpc(module, vpc_conn, vpc_id=None, cidr=None):
A VPC object that matches either an ID or CIDR and one or more tag values
"""
if vpc_id == None and cidr == None:
if vpc_id is None and cidr is None:
module.fail_json(
msg='You must specify either a vpc_id or a cidr block + list of unique tags, aborting'
)
@@ -565,7 +565,7 @@ def create_vpc(module, vpc_conn):
old_rt = vpc_conn.get_all_route_tables(
filters={'association.subnet_id': rsn.id, 'vpc_id': vpc.id}
)
old_rt = [ x for x in old_rt if x.id != None ]
old_rt = [ x for x in old_rt if x.id is not None ]
if len(old_rt) == 1:
old_rt = old_rt[0]
association_id = None

View File

@@ -410,7 +410,7 @@ def main():
list_origin_access_identities = module.params.get('list_origin_access_identities')
list_distributions = module.params.get('list_distributions')
list_distributions_by_web_acl_id = module.params.get('list_distributions_by_web_acl_id');
list_distributions_by_web_acl_id = module.params.get('list_distributions_by_web_acl_id')
list_invalidations = module.params.get('list_invalidations')
list_streaming_distributions = module.params.get('list_streaming_distributions')

View File

@@ -1040,7 +1040,7 @@ def create_instances(module, ec2, vpc, override_count=None):
running_instances = []
count_remaining = int(count)
if id != None:
if id is not None:
filter_dict = {'client-token':id, 'instance-state-name' : 'running'}
previous_reservations = ec2.get_all_instances(None, filter_dict)
for res in previous_reservations:

View File

@@ -506,7 +506,7 @@ def deregister_image(module, ec2):
wait_timeout = int(module.params.get('wait_timeout'))
img = ec2.get_image(image_id)
if img == None:
if img is None:
module.fail_json(msg = "Image %s does not exist" % image_id, changed=False)
# Get all associated snapshot ids before deregistering image otherwise this information becomes unavailable
@@ -562,7 +562,7 @@ def update_image(module, ec2, image_id):
launch_permissions['user_ids'] = [str(user_id) for user_id in launch_permissions['user_ids']]
img = ec2.get_image(image_id)
if img == None:
if img is None:
module.fail_json(msg = "Image %s does not exist" % image_id, changed=False)
try:

View File

@@ -210,7 +210,8 @@ def match_asg_tags(tags_to_match, asg):
for tag in asg['Tags']:
if key == tag['Key'] and value == tag['Value']:
break
else: return False
else:
return False
return True
def find_asgs(conn, module, name=None, tags=None):

View File

@@ -886,7 +886,7 @@ class ElbManager(object):
self._disable_zones(zones_to_disable)
def _set_security_groups(self):
if self.security_group_ids != None and set(self.elb.security_groups) != set(self.security_group_ids):
if self.security_group_ids is not None and set(self.elb.security_groups) != set(self.security_group_ids):
self.elb_conn.apply_security_groups_to_lb(self.name, self.security_group_ids)
self.changed = True

View File

@@ -298,16 +298,16 @@ def main():
# First check if we were given a dhcp_options_id
if not params['dhcp_options_id']:
# No, so create new_options from the parameters
if params['dns_servers'] != None:
if params['dns_servers'] is not None:
new_options['domain-name-servers'] = params['dns_servers']
if params['netbios_name_servers'] != None:
if params['netbios_name_servers'] is not None:
new_options['netbios-name-servers'] = params['netbios_name_servers']
if params['ntp_servers'] != None:
if params['ntp_servers'] is not None:
new_options['ntp-servers'] = params['ntp_servers']
if params['domain_name'] != None:
if params['domain_name'] is not None:
# needs to be a list for comparison with boto objects later
new_options['domain-name'] = [ params['domain_name'] ]
if params['netbios_node_type'] != None:
if params['netbios_node_type'] is not None:
# needs to be a list for comparison with boto objects later
new_options['netbios-node-type'] = [ str(params['netbios_node_type']) ]
# If we were given a vpc_id then we need to look at the options on that

View File

@@ -312,14 +312,14 @@ def check_tags(client, module, existing_vgw, vpn_gateway_id):
tags_list[tags['Key']] = tags['Value']
# if existing tags don't match the tags arg, delete existing and recreate with new list
if params['Tags'] != None and tags_list != params['Tags']:
if params['Tags'] is not None and tags_list != params['Tags']:
delete_tags(client, module, vpn_gateway_id)
create_tags(client, module, vpn_gateway_id)
vgw = find_vgw(client, module)
changed = True
#if no tag args are supplied, delete any existing tags with the exception of the name tag
if params['Tags'] == None and tags_list != {}:
if params['Tags'] is None and tags_list != {}:
tags_to_delete = []
for tags in existing_vgw[0]['Tags']:
if tags['Key'] != 'Name':

View File

@@ -163,7 +163,7 @@ def main():
except ValueError as e:
decrypted = None
if decrypted == None:
if decrypted is None:
module.exit_json(win_password='', changed=False)
else:
if wait:

View File

@@ -304,14 +304,14 @@ def main():
policy_name = module.params.get('policy_name')
skip = module.params.get('skip_duplicates')
if module.params.get('policy_document') != None and module.params.get('policy_json') != None:
if module.params.get('policy_document') is not None and module.params.get('policy_json') is not None:
module.fail_json(msg='Only one of "policy_document" or "policy_json" may be set')
if module.params.get('policy_document') != None:
if module.params.get('policy_document') is not None:
with open(module.params.get('policy_document'), 'r') as json_data:
pdoc = json.dumps(json.load(json_data))
json_data.close()
elif module.params.get('policy_json') != None:
elif module.params.get('policy_json') is not None:
pdoc = module.params.get('policy_json')
# if its a string, assume it is already JSON
if not isinstance(pdoc, basestring):

View File

@@ -325,7 +325,7 @@ def get_zone_by_name(conn, module, zone_name, want_private, zone_id, want_vpc_id
# only save this zone id if the private status of the zone matches
# the private_zone_in boolean specified in the params
private_zone = module.boolean(zone.config.get('PrivateZone', False))
if private_zone == want_private and ((zone.name == zone_name and zone_id == None) or zone.id.replace('/hostedzone/', '') == zone_id):
if private_zone == want_private and ((zone.name == zone_name and zone_id is None) or zone.id.replace('/hostedzone/', '') == zone_id):
if want_vpc_id:
# NOTE: These details aren't available in other boto methods, hence the necessary
# extra API call
@@ -464,13 +464,13 @@ def main():
module.fail_json(msg = "parameter 'value' must contain a single dns name for alias create/delete")
elif not alias_hosted_zone_id_in:
module.fail_json(msg = "parameter 'alias_hosted_zone_id' required for alias create/delete")
elif ( weight_in!=None or region_in!=None or failover_in!=None ) and identifier_in==None:
elif ( weight_in is not None or region_in is not None or failover_in is not None ) and identifier_in is None:
module.fail_json(msg= "If you specify failover, region or weight you must also specify identifier")
if command_in == 'create':
if ( weight_in!=None or region_in!=None or failover_in!=None ) and identifier_in==None:
if ( weight_in is not None or region_in is not None or failover_in is not None ) and identifier_in is None:
module.fail_json(msg= "If you specify failover, region or weight you must also specify identifier")
elif ( weight_in==None and region_in==None and failover_in==None ) and identifier_in!=None:
elif ( weight_in is None and region_in is None and failover_in is None ) and identifier_in is not None:
module.fail_json(msg= "You have specified identifier which makes sense only if you specify one of: weight, region or failover.")

View File

@@ -643,7 +643,7 @@ def main():
# Delete an object from a bucket, not the entire bucket
if mode == 'delobj':
if obj is None:
module.fail_json(msg="object parameter is required", failed=True);
module.fail_json(msg="object parameter is required", failed=True)
if bucket:
bucketrtn = bucket_check(module, s3, bucket)
if bucketrtn is True: