mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
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:
parent
c29d1e3162
commit
d0d1158c5e
72 changed files with 184 additions and 174 deletions
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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':
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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.")
|
||||
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -276,7 +276,8 @@ from types import MethodType
|
|||
import json
|
||||
|
||||
def _wait_for_completion(azure, promise, wait_timeout, msg):
|
||||
if not promise: return
|
||||
if not promise:
|
||||
return
|
||||
wait_timeout = time.time() + wait_timeout
|
||||
while wait_timeout > time.time():
|
||||
operation_result = azure.get_operation_status(promise.request_id)
|
||||
|
|
|
@ -1553,12 +1553,12 @@ class DockerManager(object):
|
|||
|
||||
image_matches = running_image in repo_tags
|
||||
|
||||
if command == None:
|
||||
if command is None:
|
||||
command_matches = True
|
||||
else:
|
||||
command_matches = (command == details['Config']['Cmd'])
|
||||
|
||||
if entrypoint == None:
|
||||
if entrypoint is None:
|
||||
entrypoint_matches = True
|
||||
else:
|
||||
entrypoint_matches = (
|
||||
|
|
|
@ -176,7 +176,7 @@ try:
|
|||
from ast import literal_eval
|
||||
HAS_PYTHON26 = True
|
||||
except ImportError:
|
||||
HAS_PYTHON26 = False;
|
||||
HAS_PYTHON26 = False
|
||||
|
||||
try:
|
||||
from google.cloud import pubsub
|
||||
|
|
|
@ -88,7 +88,7 @@ try:
|
|||
from ast import literal_eval
|
||||
HAS_PYTHON26 = True
|
||||
except ImportError:
|
||||
HAS_PYTHON26 = False;
|
||||
HAS_PYTHON26 = False
|
||||
|
||||
try:
|
||||
from google.cloud import pubsub
|
||||
|
|
|
@ -382,7 +382,7 @@ def vm_status(conn, vmname):
|
|||
# Get VM object and return it's name if object exists
|
||||
def get_vm(conn, vmname):
|
||||
vm = conn.vms.get(name=vmname)
|
||||
if vm == None:
|
||||
if vm is None:
|
||||
name = "empty"
|
||||
else:
|
||||
name = vm.get_name()
|
||||
|
|
|
@ -139,7 +139,7 @@ def _system_state_change(module, project):
|
|||
else:
|
||||
changed=True
|
||||
|
||||
return changed;
|
||||
return changed
|
||||
|
||||
def main():
|
||||
|
||||
|
|
|
@ -223,7 +223,8 @@ uuid_match = re.compile(
|
|||
|
||||
|
||||
def _wait_for_completion(profitbricks, promise, wait_timeout, msg):
|
||||
if not promise: return
|
||||
if not promise:
|
||||
return
|
||||
wait_timeout = time.time() + wait_timeout
|
||||
while wait_timeout > time.time():
|
||||
time.sleep(5)
|
||||
|
|
|
@ -105,7 +105,8 @@ uuid_match = re.compile(
|
|||
|
||||
|
||||
def _wait_for_completion(profitbricks, promise, wait_timeout, msg):
|
||||
if not promise: return
|
||||
if not promise:
|
||||
return
|
||||
wait_timeout = time.time() + wait_timeout
|
||||
while wait_timeout > time.time():
|
||||
time.sleep(5)
|
||||
|
|
|
@ -107,7 +107,8 @@ uuid_match = re.compile(
|
|||
|
||||
|
||||
def _wait_for_completion(profitbricks, promise, wait_timeout, msg):
|
||||
if not promise: return
|
||||
if not promise:
|
||||
return
|
||||
wait_timeout = time.time() + wait_timeout
|
||||
while wait_timeout > time.time():
|
||||
time.sleep(5)
|
||||
|
|
|
@ -157,7 +157,8 @@ uuid_match = re.compile(
|
|||
|
||||
|
||||
def _wait_for_completion(profitbricks, promise, wait_timeout, msg):
|
||||
if not promise: return
|
||||
if not promise:
|
||||
return
|
||||
wait_timeout = time.time() + wait_timeout
|
||||
while wait_timeout > time.time():
|
||||
time.sleep(5)
|
||||
|
|
|
@ -105,7 +105,8 @@ uuid_match = re.compile(
|
|||
|
||||
|
||||
def _wait_for_completion(profitbricks, promise, wait_timeout, msg):
|
||||
if not promise: return
|
||||
if not promise:
|
||||
return
|
||||
wait_timeout = time.time() + wait_timeout
|
||||
while wait_timeout > time.time():
|
||||
time.sleep(5)
|
||||
|
|
|
@ -270,9 +270,9 @@ def create_virtual_instance(module):
|
|||
|
||||
|
||||
# Check if OS or Image Template is provided (Can't be both, defaults to OS)
|
||||
if (module.params.get('os_code') != None and module.params.get('os_code') != ''):
|
||||
if (module.params.get('os_code') is not None and module.params.get('os_code') != ''):
|
||||
module.params['image_id'] = ''
|
||||
elif (module.params.get('image_id') != None and module.params.get('image_id') != ''):
|
||||
elif (module.params.get('image_id') is not None and module.params.get('image_id') != ''):
|
||||
module.params['os_code'] = ''
|
||||
module.params['disks'] = [] # Blank out disks since it will use the template
|
||||
else:
|
||||
|
@ -302,7 +302,7 @@ def create_virtual_instance(module):
|
|||
post_uri = module.params.get('post_uri'),
|
||||
tags = tags)
|
||||
|
||||
if instance != None and instance['id'] > 0:
|
||||
if instance is not None and instance['id'] > 0:
|
||||
return True, instance
|
||||
else:
|
||||
return False, None
|
||||
|
@ -325,7 +325,7 @@ def wait_for_instance(module,id):
|
|||
|
||||
def cancel_instance(module):
|
||||
canceled = True
|
||||
if module.params.get('instance_id') == None and (module.params.get('tags') or module.params.get('hostname') or module.params.get('domain')):
|
||||
if module.params.get('instance_id') is None and (module.params.get('tags') or module.params.get('hostname') or module.params.get('domain')):
|
||||
tags = module.params.get('tags')
|
||||
if isinstance(tags, basestring):
|
||||
tags = [module.params.get('tags')]
|
||||
|
|
|
@ -1190,7 +1190,8 @@ def _find_path_in_tree(tree, path):
|
|||
|
||||
def _get_folderid_for_path(vsphere_client, datacenter, path):
|
||||
content = vsphere_client._retrieve_properties_traversal(property_names=['name', 'parent'], obj_type=MORTypes.Folder)
|
||||
if not content: return {}
|
||||
if not content:
|
||||
return {}
|
||||
|
||||
node_list = [
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue