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

@ -55,7 +55,7 @@ from ansible.module_utils.urls import open_url
def api_get(link, config):
try:
if link == None:
if link is None:
url = config.get('api','uri') + config.get('api','login_path')
headers = {"Accept": config.get('api','login_type')}
else:
@ -148,7 +148,7 @@ def generate_inv_from_api(enterprise_entity,config):
if ((config.getboolean('defaults', 'deployed_only') == True) and (vmcollection['state'] == 'NOT_ALLOCATED')):
vm_state = False
if not vm_nic == None and vm_state:
if vm_nic is not None and vm_state:
if vm_vapp not in inventory:
inventory[vm_vapp] = {}
inventory[vm_vapp]['children'] = []

View file

@ -297,7 +297,7 @@ class LibcloudInventory(object):
'''
if key in my_dict:
my_dict[key].append(element);
my_dict[key].append(element)
else:
my_dict[key] = [element]
@ -358,4 +358,4 @@ def main():
LibcloudInventory()
if __name__ == '__main__':
main()
main()

View file

@ -179,7 +179,7 @@ class CloudStackInventory(object):
})
if nic['isdefault']:
data['default_ip'] = nic['ipaddress']
break;
break
return data

View file

@ -399,7 +399,7 @@ class ConsulInventory(object):
new_dict = {}
for k, v in d.items():
if v != None:
if v is not None:
new_dict[self.to_safe(str(k))] = self.to_safe(str(v))
return new_dict

View file

@ -442,7 +442,7 @@ class Ec2Inventory(object):
# Do we need to exclude hosts that match a pattern?
try:
pattern_exclude = config.get('ec2', 'pattern_exclude');
pattern_exclude = config.get('ec2', 'pattern_exclude')
if pattern_exclude and len(pattern_exclude) > 0:
self.pattern_exclude = re.compile(pattern_exclude)
else:

View file

@ -428,8 +428,10 @@ class GceInventory(object):
if zones and zone not in zones:
continue
if zone in groups: groups[zone].append(name)
else: groups[zone] = [name]
if zone in groups:
groups[zone].append(name)
else:
groups[zone] = [name]
tags = node.extra['tags']
for t in tags:
@ -437,26 +439,36 @@ class GceInventory(object):
tag = t[6:]
else:
tag = 'tag_%s' % t
if tag in groups: groups[tag].append(name)
else: groups[tag] = [name]
if tag in groups:
groups[tag].append(name)
else:
groups[tag] = [name]
net = node.extra['networkInterfaces'][0]['network'].split('/')[-1]
net = 'network_%s' % net
if net in groups: groups[net].append(name)
else: groups[net] = [name]
if net in groups:
groups[net].append(name)
else:
groups[net] = [name]
machine_type = node.size
if machine_type in groups: groups[machine_type].append(name)
else: groups[machine_type] = [name]
if machine_type in groups:
groups[machine_type].append(name)
else:
groups[machine_type] = [name]
image = node.image and node.image or 'persistent_disk'
if image in groups: groups[image].append(name)
else: groups[image] = [name]
if image in groups:
groups[image].append(name)
else:
groups[image] = [name]
status = node.extra['status']
stat = 'status_%s' % status.lower()
if stat in groups: groups[stat].append(name)
else: groups[stat] = [name]
if stat in groups:
groups[stat].append(name)
else:
groups[stat] = [name]
groups["_meta"] = meta

View file

@ -300,7 +300,7 @@ class LinodeInventory(object):
def push(self, my_dict, key, element):
"""Pushed an element onto an array that may not have been defined in the dict."""
if key in my_dict:
my_dict[key].append(element);
my_dict[key].append(element)
else:
my_dict[key] = [element]

View file

@ -69,9 +69,9 @@ class MDTInventory(object):
Gets host from MDT Database
'''
if hostname:
query = "SELECT t1.ID, t1.Description, t1.MacAddress, t2.Role FROM ComputerIdentity as t1 join Settings_Roles as t2 on t1.ID = t2.ID where t1.Description = '%s'" % hostname
query = "SELECT t1.ID, t1.Description, t1.MacAddress, t2.Role FROM ComputerIdentity as t1 join Settings_Roles as t2 on t1.ID = t2.ID where t1.Description = '%s'" % hostname
else:
query = 'SELECT t1.ID, t1.Description, t1.MacAddress, t2.Role FROM ComputerIdentity as t1 join Settings_Roles as t2 on t1.ID = t2.ID'
query = 'SELECT t1.ID, t1.Description, t1.MacAddress, t2.Role FROM ComputerIdentity as t1 join Settings_Roles as t2 on t1.ID = t2.ID'
self._connect(query)
# Configure to group name configured in Ansible Tower for this inventory

View file

@ -95,7 +95,7 @@ class SoftLayerInventory(object):
'''Push an element onto an array that may not have been defined in the dict'''
if key in my_dict:
my_dict[key].append(element);
my_dict[key].append(element)
else:
my_dict[key] = [element]

View file

@ -110,9 +110,9 @@ parser.add_option('-H', '--human', dest="human",
default=False, action="store_true",
help="Produce a friendlier version of either server list or host detail")
parser.add_option('-o', '--org', default=None, dest="org_number",
help="Limit to spacewalk organization number")
help="Limit to spacewalk organization number")
parser.add_option('-p', default=False, dest="prefix_org_name", action="store_true",
help="Prefix the group name with the organization number")
help="Prefix the group name with the organization number")
(options, args) = parser.parse_args()
@ -133,13 +133,13 @@ if os.path.exists(INI_FILE):
#------------------------------
org_groups = {}
try:
for group in spacewalk_report('system-groups'):
org_groups[group['spacewalk_group_id']] = group['spacewalk_org_id']
for group in spacewalk_report('system-groups'):
org_groups[group['spacewalk_group_id']] = group['spacewalk_org_id']
except (OSError) as e:
print('Problem executing the command "%s system-groups": %s' %
print('Problem executing the command "%s system-groups": %s' %
(SW_REPORT, str(e)), file=sys.stderr)
sys.exit(2)
sys.exit(2)
# List out the known server from Spacewalk

View file

@ -374,7 +374,7 @@ class VMWareInventory(object):
if cfm is not None and cfm.field:
for f in cfm.field:
if f.managedObjectType == vim.VirtualMachine:
self.custom_fields[f.key] = f.name;
self.custom_fields[f.key] = f.name
self.debugl('%d custom fieds collected' % len(self.custom_fields))
return instance_tuples

View file

@ -246,7 +246,7 @@ class AzureInventory(object):
def push(self, my_dict, key, element):
"""Pushed an element onto an array that may not have been defined in the dict."""
if key in my_dict:
my_dict[key].append(element);
my_dict[key].append(element)
else:
my_dict[key] = [element]

View file

@ -55,9 +55,9 @@ class ZabbixInventory(object):
config = ConfigParser.SafeConfigParser()
conf_path = './zabbix.ini'
if not os.path.exists(conf_path):
conf_path = os.path.dirname(os.path.realpath(__file__)) + '/zabbix.ini'
conf_path = os.path.dirname(os.path.realpath(__file__)) + '/zabbix.ini'
if os.path.exists(conf_path):
config.read(conf_path)
config.read(conf_path)
# server
if config.has_option('zabbix', 'server'):
self.zabbix_server = config.get('zabbix', 'server')

View file

@ -91,7 +91,7 @@ def seek_end_of_dict(module_data, start_line, start_col, next_node_line, next_no
ANSIBLE_METADATA = {}EOF
"""
if next_node_line == None:
if next_node_line is None:
# The dict is the last statement in the file
snippet = module_data.splitlines()[start_line:]
next_node_col = 0

View file

@ -50,7 +50,7 @@ class GalaxyLogin(object):
self.github_username = None
self.github_password = None
if github_token == None:
if github_token is None:
self.get_credentials()
def get_credentials(self):

View file

@ -379,7 +379,7 @@ class AzureRMModuleBase(object):
mod = importlib.import_module(module_name)
for mod_class_name, mod_class_obj in inspect.getmembers(mod, predicate=inspect.isclass):
dependencies[mod_class_name] = mod_class_obj
self.log("dependencies: ");
self.log("dependencies: ")
self.log(str(dependencies))
serializer = Serializer(classes=dependencies)
return serializer.body(obj, class_name)

View file

@ -1169,9 +1169,12 @@ class AnsibleModule(object):
def _apply_operation_to_mode(self, user, operator, mode_to_apply, current_mode):
if operator == '=':
if user == 'u': mask = stat.S_IRWXU | stat.S_ISUID
elif user == 'g': mask = stat.S_IRWXG | stat.S_ISGID
elif user == 'o': mask = stat.S_IRWXO | stat.S_ISVTX
if user == 'u':
mask = stat.S_IRWXU | stat.S_ISUID
elif user == 'g':
mask = stat.S_IRWXG | stat.S_ISGID
elif user == 'o':
mask = stat.S_IRWXO | stat.S_ISVTX
# mask out u, g, or o permissions from current_mode and apply new permissions
inverse_mask = mask ^ PERM_BITS
@ -2361,7 +2364,7 @@ class AnsibleModule(object):
# No pipes are left to read but process is not yet terminated
# Only then it is safe to wait for the process to be finished
# NOTE: Actually cmd.poll() is always None here if rpipes is empty
elif not rpipes and cmd.poll() == None:
elif not rpipes and cmd.poll() is None:
cmd.wait()
# The process is terminated. Since no pipes to read from are
# left, there is no need to call select() again.

View file

@ -2186,7 +2186,8 @@ class AIX(Hardware):
# nfs or cifs based mount
# in case of nfs if no mount options are provided on command line
# add into fields empty string...
if len(fields) < 8: fields.append("")
if len(fields) < 8:
fields.append("")
self.facts['mounts'].append({'mount': fields[2],
'device': '%s:%s' % (fields[0], fields[1]),
'fstype' : fields[3],

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:

View file

@ -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)

View file

@ -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 = (

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -139,7 +139,7 @@ def _system_state_change(module, project):
else:
changed=True
return changed;
return changed
def main():

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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')]

View file

@ -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 = [
{

View file

@ -234,7 +234,7 @@ def remove_value(module):
index, existing = consul_api.kv.get(
key, recurse=module.params.get('recurse'))
changed = existing != None
changed = existing is not None
if changed and not module.check_mode:
consul_api.kv.delete(key, module.params.get('recurse'))

View file

@ -238,7 +238,7 @@ class InvalidPrivsError(Exception):
# User Authentication Management was change in MySQL 5.7
# This is a generic check for if the server version is less than version 5.7
def server_version_check(cursor):
cursor.execute("SELECT VERSION()");
cursor.execute("SELECT VERSION()")
result = cursor.fetchone()
version_str = result[0]
version = version_str.split('.')

View file

@ -329,7 +329,7 @@ def main():
module.fail_json(msg="'entry' MUST NOT be set when 'state=query'.")
default_flag, etype, entity, permissions = split_entry(entry)
if default_flag != None:
if default_flag is not None:
default = default_flag
if get_platform().lower() == 'freebsd':

View file

@ -227,7 +227,8 @@ def sizefilter(st, size):
def contentfilter(fsname, pattern):
'''filter files which contain the given expression'''
if pattern is None: return True
if pattern is None:
return True
try:
f = open(fsname)

View file

@ -349,8 +349,10 @@ class ZipArchive(object):
continue
# Check first and seventh field in order to skip header/footer
if len(pcs[0]) != 7 and len(pcs[0]) != 10: continue
if len(pcs[6]) != 15: continue
if len(pcs[0]) != 7 and len(pcs[0]) != 10:
continue
if len(pcs[6]) != 15:
continue
# Possible entries:
# -rw-rws--- 1.9 unx 2802 t- defX 11-Aug-91 13:48 perms.2660

View file

@ -109,15 +109,15 @@ def post_annotation(annotation, api_key):
def create_annotation(module):
''' Takes ansible module object '''
annotation = {}
if module.params['duration'] != None:
if module.params['duration'] is not None:
duration = module.params['duration']
else:
duration = 0
if module.params['start'] != None:
if module.params['start'] is not None:
start = module.params['start']
else:
start = int(time.time())
if module.params['stop'] != None:
if module.params['stop'] is not None:
stop = module.params['stop']
else:
stop = int(time.time())+ duration

View file

@ -117,15 +117,15 @@ def post_annotation(module):
params = {}
params['title'] = title
if module.params['source'] != None:
if module.params['source'] is not None:
params['source'] = module.params['source']
if module.params['description'] != None:
if module.params['description'] is not None:
params['description'] = module.params['description']
if module.params['start_time'] != None:
if module.params['start_time'] is not None:
params['start_time'] = module.params['start_time']
if module.params['end_time'] != None:
if module.params['end_time'] is not None:
params['end_time'] = module.params['end_time']
if module.params['links'] != None:
if module.params['links'] is not None:
params['links'] = module.params['links']
json_body = module.jsonify(params)

View file

@ -276,8 +276,10 @@ def main():
# check if we need to update
if rr['ttl'] != ttl or rr['prio'] != priority:
data = {}
if ttl: data['ttl'] = ttl
if priority: data['prio'] = priority
if ttl:
data['ttl'] = ttl
if priority:
data['prio'] = priority
if module.check_mode:
module.exit_json(changed=True)
else:
@ -291,8 +293,10 @@ def main():
'record_type': record_type,
'content': value,
}
if ttl: data['ttl'] = ttl
if priority: data['prio'] = priority
if ttl:
data['ttl'] = ttl
if priority:
data['prio'] = priority
if module.check_mode:
module.exit_json(changed=True)
else:

View file

@ -332,9 +332,9 @@ class ExoDnsRecord(ExoDns):
def present_record(self):
record = self.get_record()
if not record:
record = self._create_record(record);
record = self._create_record(record)
else:
record = self._update_record(record);
record = self._update_record(record)
return record
def absent_record(self):

View file

@ -209,10 +209,10 @@ def main():
module.fail_json(msg='Community not set when using snmp version 2')
if m_args['version'] == "v3":
if m_args['username'] == None:
if m_args['username'] is None:
module.fail_json(msg='Username not set when using snmp version 3')
if m_args['level'] == "authPriv" and m_args['privacy'] == None:
if m_args['level'] == "authPriv" and m_args['privacy'] is None:
module.fail_json(msg='Privacy algorithm not set when using authPriv')

View file

@ -252,7 +252,7 @@ def main():
sendgrid_lib_args = [api_key, bcc, cc, headers, from_name, html_body, attachments]
if any(lib_arg != None for lib_arg in sendgrid_lib_args) and not HAS_SENDGRID:
if any(lib_arg is not None for lib_arg in sendgrid_lib_args) and not HAS_SENDGRID:
module.fail_json(msg='You must install the sendgrid python library if you want to use any of the following arguments: api_key, bcc, cc, headers, from_name, html_body, attachments')
response, info = post_sendgrid_api(module, username, password,

View file

@ -77,7 +77,8 @@ def get_local_version(pear_output):
for line in lines:
if 'Installed ' in line:
installed = line.rsplit(None, 1)[-1].strip()
if installed == '-': continue
if installed == '-':
continue
return installed
return None

View file

@ -103,7 +103,8 @@ except ImportError:
HAS_LAYMAN_API = False
class ModuleError(Exception): pass
class ModuleError(Exception):
pass
def init_layman(config=None):
@ -201,7 +202,8 @@ def uninstall_overlay(module, name):
module.exit_json(changed=True, msg=mymsg)
layman.delete_repos(name)
if layman.get_errors(): raise ModuleError(layman.get_errors())
if layman.get_errors():
raise ModuleError(layman.get_errors())
return True

View file

@ -161,9 +161,9 @@ def get_package_state(names, pkg_spec, module):
# find multiple packages with that name.
pkg_spec[name]['installed_names'] = [installed_name for installed_name in stdout.splitlines()]
module.debug("get_package_state(): installed_names = %s" % pkg_spec[name]['installed_names'])
pkg_spec[name]['installed_state'] = True;
pkg_spec[name]['installed_state'] = True
else:
pkg_spec[name]['installed_state'] = False;
pkg_spec[name]['installed_state'] = False
# Function used to make sure a package is present.
def package_present(names, pkg_spec, module):

View file

@ -111,7 +111,7 @@ def modify_publisher(module, params):
if name in existing:
for option in ['origin', 'mirror', 'sticky', 'enabled']:
if params[option] != None:
if params[option] is not None:
if params[option] != existing[name][option]:
return set_publisher(module, params)
else:
@ -124,21 +124,21 @@ def set_publisher(module, params):
name = params['name']
args = []
if params['origin'] != None:
if params['origin'] is not None:
args.append('--remove-origin=*')
args.extend(['--add-origin=' + u for u in params['origin']])
if params['mirror'] != None:
if params['mirror'] is not None:
args.append('--remove-mirror=*')
args.extend(['--add-mirror=' + u for u in params['mirror']])
if params['sticky'] != None and params['sticky']:
if params['sticky'] is not None and params['sticky']:
args.append('--sticky')
elif params['sticky'] != None:
elif params['sticky'] is not None:
args.append('--non-sticky')
if params['enabled'] != None and params['enabled']:
if params['enabled'] is not None and params['enabled']:
args.append('--enable')
elif params['enabled'] != None:
elif params['enabled'] is not None:
args.append('--disable')
rc, out, err = module.run_command(

View file

@ -140,7 +140,7 @@ def main():
changed = False
msg = "No changed"
rc = 0
if ( state == 'present' or state == 'latest' ) and depot == None:
if ( state == 'present' or state == 'latest' ) and depot is None:
output = "depot parameter is mandatory in present or latest task"
module.fail_json(name=name, msg=output, rc=rc)

View file

@ -515,10 +515,10 @@ def main():
## Verify required params are provided
if module.params['source'] == None and module.params['permanent'] == None:
if module.params['source'] is None and module.params['permanent'] is None:
module.fail_json(msg='permanent is a required parameter')
if module.params['interface'] != None and module.params['zone'] == None:
if module.params['interface'] is not None and module.params['zone'] is None:
module.fail(msg='zone is a required parameter')
if module.params['immediate'] and fw_offline:
@ -531,14 +531,14 @@ def main():
rich_rule = module.params['rich_rule']
source = module.params['source']
if module.params['port'] != None:
if module.params['port'] is not None:
port, protocol = module.params['port'].split('/')
if protocol == None:
if protocol is None:
module.fail_json(msg='improper port format (missing protocol?)')
else:
port = None
if module.params['zone'] != None:
if module.params['zone'] is not None:
zone = module.params['zone']
else:
if fw_offline:
@ -554,21 +554,21 @@ def main():
masquerade = module.params['masquerade']
modification_count = 0
if service != None:
if service is not None:
modification_count += 1
if port != None:
if port is not None:
modification_count += 1
if rich_rule != None:
if rich_rule is not None:
modification_count += 1
if interface != None:
if interface is not None:
modification_count += 1
if masquerade != None:
if masquerade is not None:
modification_count += 1
if modification_count > 1:
module.fail_json(msg='can only operate on port, service, rich_rule or interface at once')
if service != None:
if service is not None:
if immediate and permanent:
is_enabled_permanent = action_handler(
get_service_enabled_permanent,
@ -676,7 +676,7 @@ def main():
# FIXME - source type does not handle non-permanent mode, this was an
# oversight in the past.
if source != None:
if source is not None:
is_enabled = action_handler(get_source, (zone, source))
if desired_state == "enabled":
if is_enabled == False:
@ -695,7 +695,7 @@ def main():
changed=True
msgs.append("Removed %s from zone %s" % (source, zone))
if port != None:
if port is not None:
if immediate and permanent:
is_enabled_permanent = action_handler(
get_port_enabled_permanent,
@ -800,7 +800,7 @@ def main():
msgs.append("Changed port %s to %s" % ("%s/%s" % (port, protocol), \
desired_state))
if rich_rule != None:
if rich_rule is not None:
if immediate and permanent:
is_enabled_permanent = action_handler(
get_rich_rule_enabled_permanent,
@ -903,7 +903,7 @@ def main():
if changed == True:
msgs.append("Changed rich_rule %s to %s" % (rich_rule, desired_state))
if interface != None:
if interface is not None:
if immediate and permanent:
is_enabled_permanent = action_handler(
get_interface_permanent,
@ -986,7 +986,7 @@ def main():
changed=True
msgs.append("Removed %s from zone %s" % (interface, zone))
if masquerade != None:
if masquerade is not None:
if immediate and permanent:
is_enabled_permanent = action_handler(

View file

@ -436,13 +436,13 @@ def main():
# Clean up if last element is empty. Consider that yml can look like this:
# cluster="{% for host in groups['glusterfs'] %}{{ hostvars[host]['private_ip'] }},{% endfor %}"
if cluster != None and len(cluster) > 1 and cluster[-1] == '':
if cluster is not None and len(cluster) > 1 and cluster[-1] == '':
cluster = cluster[0:-1]
if cluster == None or cluster[0] == '':
if cluster is None or cluster[0] == '':
cluster = [myhostname]
if brick_paths != None and "," in brick_paths:
if brick_paths is not None and "," in brick_paths:
brick_paths = brick_paths.split(",")
else:
brick_paths = [brick_paths]

View file

@ -262,7 +262,7 @@ def main():
# Determine if the "--yes" option should be used
version_found = get_lvm_version(module)
if version_found == None:
if version_found is None:
module.fail_json(msg="Failed to get LVM version number")
version_yesopt = mkversion(2, 2, 99) # First LVM with the "--yes" option
if version_found >= version_yesopt:
@ -320,7 +320,8 @@ def main():
try:
float(size)
if not size[0].isdigit(): raise ValueError()
if not size[0].isdigit():
raise ValueError()
except ValueError:
module.fail_json(msg="Bad size specification of '%s'" % size)

View file

@ -1953,7 +1953,7 @@ class AIX(User):
else:
(rc2, out2, err2) = (None, '', '')
if rc != None:
if rc is not None:
return (rc, out+out2, err+err2)
else:
return (rc2, out+out2, err+err2)

View file

@ -374,7 +374,7 @@ def main():
if HAS_BEAUTIFULSOUP is False:
module.fail_json(msg="python module 'BeautifulSoup' is required!")
if module.params['state'] != None:
if module.params['state'] is not None:
states = module.params['state'].split(',')
if (len(states) > 1) and (("present" in states) or ("enabled" in states)):
module.fail_json(msg="state present/enabled is mutually exclusive with other states!")

View file

@ -82,7 +82,7 @@ class CallbackModule(CallbackBase):
self.task_output_limit = os.getenv('PROFILE_TASKS_TASK_OUTPUT_LIMIT', 20)
if self.sort_order == 'ascending':
self.sort_order = False;
self.sort_order = False
if self.task_output_limit == 'all':
self.task_output_limit = None

View file

@ -265,7 +265,7 @@ def get_encrypted_password(password, hashtype='sha512', salt=None):
encrypted = crypt.crypt(password, saltstring)
else:
if hashtype == 'blowfish':
cls = passlib.hash.bcrypt;
cls = passlib.hash.bcrypt
else:
cls = getattr(passlib.hash, '%s_crypt' % hashtype)

View file

@ -65,11 +65,11 @@ def union(a, b):
def min(a):
_min = __builtins__.get('min')
return _min(a);
return _min(a)
def max(a):
_max = __builtins__.get('max')
return _max(a);
return _max(a)
def logarithm(x, base=math.e):

View file

@ -50,12 +50,12 @@ class HashiVault:
self.url = kwargs.get('url', ANSIBLE_HASHI_VAULT_ADDR)
self.token = kwargs.get('token')
if self.token==None:
if self.token is None:
raise AnsibleError("No Vault Token specified")
# split secret arg, which has format 'secret/hello:value' into secret='secret/hello' and secret_field='value'
s = kwargs.get('secret')
if s==None:
if s is None:
raise AnsibleError("No secret specified")
s_f = s.split(':')

View file

@ -75,7 +75,7 @@ def run_cmd(cmd, live=False, readsize=10):
if (not rpipes or not rfd) and p.poll() is not None:
break
# Calling wait while there are still pipes to read can cause a lock
elif not rpipes and p.poll() == None:
elif not rpipes and p.poll() is None:
p.wait()
return p.returncode, stdout, stderr

View file

@ -19,7 +19,7 @@
class ModuleDocFragment(object):
# Standard Infinibox documentation fragment
# Standard Infinibox documentation fragment
DOCUMENTATION = '''
options:
system:

View file

@ -1,5 +1,4 @@
contrib/inventory/abiquo.py
contrib/inventory/apache-libcloud.py
contrib/inventory/azure_rm.py
contrib/inventory/cloudstack.py
contrib/inventory/consul_io.py
@ -7,17 +6,12 @@ contrib/inventory/digital_ocean.py
contrib/inventory/docker.py
contrib/inventory/ec2.py
contrib/inventory/gce.py
contrib/inventory/linode.py
contrib/inventory/mdt_dynamic_inventory.py
contrib/inventory/openvz.py
contrib/inventory/rax.py
contrib/inventory/softlayer.py
contrib/inventory/spacewalk.py
contrib/inventory/ssh_config.py
contrib/inventory/vbox.py
contrib/inventory/vmware_inventory.py
contrib/inventory/windows_azure.py
contrib/inventory/zabbix.py
contrib/inventory/zone.py
docs/api/conf.py
docs/docsite/conf.py
@ -38,7 +32,6 @@ lib/ansible/errors/__init__.py
lib/ansible/executor/play_iterator.py
lib/ansible/executor/stats.py
lib/ansible/executor/task_executor.py
lib/ansible/galaxy/login.py
lib/ansible/galaxy/role.py
lib/ansible/inventory/dir.py
lib/ansible/inventory/script.py
@ -180,7 +173,6 @@ lib/ansible/modules/cloud/openstack/_quantum_subnet.py
lib/ansible/modules/cloud/openstack/os_auth.py
lib/ansible/modules/cloud/openstack/os_nova_host_aggregate.py
lib/ansible/modules/cloud/openstack/os_object.py
lib/ansible/modules/cloud/openstack/os_project.py
lib/ansible/modules/cloud/openstack/os_quota.py
lib/ansible/modules/cloud/openstack/os_recordset.py
lib/ansible/modules/cloud/openstack/os_zone.py
@ -188,9 +180,6 @@ lib/ansible/modules/cloud/packet/packet_device.py
lib/ansible/modules/cloud/packet/packet_sshkey.py
lib/ansible/modules/cloud/profitbricks/profitbricks.py
lib/ansible/modules/cloud/profitbricks/profitbricks_datacenter.py
lib/ansible/modules/cloud/profitbricks/profitbricks_nic.py
lib/ansible/modules/cloud/profitbricks/profitbricks_volume.py
lib/ansible/modules/cloud/profitbricks/profitbricks_volume_attachments.py
lib/ansible/modules/cloud/softlayer/sl_vm.py
lib/ansible/modules/cloud/vmware/vca_fw.py
lib/ansible/modules/cloud/vmware/vmware_guest.py
@ -240,7 +229,6 @@ lib/ansible/modules/messaging/rabbitmq_binding.py
lib/ansible/modules/messaging/rabbitmq_exchange.py
lib/ansible/modules/messaging/rabbitmq_queue.py
lib/ansible/modules/monitoring/boundary_meter.py
lib/ansible/modules/monitoring/circonus_annotation.py
lib/ansible/modules/monitoring/datadog_monitor.py
lib/ansible/modules/monitoring/librato_annotation.py
lib/ansible/modules/monitoring/logicmonitor.py
@ -338,18 +326,15 @@ lib/ansible/modules/packaging/language/bundler.py
lib/ansible/modules/packaging/language/composer.py
lib/ansible/modules/packaging/language/cpanm.py
lib/ansible/modules/packaging/language/maven_artifact.py
lib/ansible/modules/packaging/language/pear.py
lib/ansible/modules/packaging/os/apt.py
lib/ansible/modules/packaging/os/apt_key.py
lib/ansible/modules/packaging/os/apt_rpm.py
lib/ansible/modules/packaging/os/dnf.py
lib/ansible/modules/packaging/os/dpkg_selections.py
lib/ansible/modules/packaging/os/homebrew.py
lib/ansible/modules/packaging/os/layman.py
lib/ansible/modules/packaging/os/openbsd_pkg.py
lib/ansible/modules/packaging/os/opkg.py
lib/ansible/modules/packaging/os/pacman.py
lib/ansible/modules/packaging/os/pkg5_publisher.py
lib/ansible/modules/packaging/os/pkgin.py
lib/ansible/modules/packaging/os/pkgng.py
lib/ansible/modules/packaging/os/portinstall.py
@ -446,15 +431,12 @@ lib/ansible/plugins/callback/dense.py
lib/ansible/plugins/callback/foreman.py
lib/ansible/plugins/callback/logentries.py
lib/ansible/plugins/callback/oneline.py
lib/ansible/plugins/callback/profile_tasks.py
lib/ansible/plugins/callback/selective.py
lib/ansible/plugins/connection/accelerate.py
lib/ansible/plugins/connection/paramiko_ssh.py
lib/ansible/plugins/connection/ssh.py
lib/ansible/plugins/connection/winrm.py
lib/ansible/plugins/filter/core.py
lib/ansible/plugins/filter/ipaddr.py
lib/ansible/plugins/filter/mathstuff.py
lib/ansible/plugins/lookup/dig.py
lib/ansible/plugins/lookup/dnstxt.py
lib/ansible/plugins/lookup/first_found.py
@ -467,14 +449,12 @@ lib/ansible/plugins/strategy/__init__.py
lib/ansible/plugins/strategy/debug.py
lib/ansible/plugins/strategy/linear.py
lib/ansible/template/__init__.py
lib/ansible/utils/cmd_functions.py
lib/ansible/utils/encrypt.py
lib/ansible/utils/module_docs.py
lib/ansible/utils/module_docs_fragments/aws.py
lib/ansible/utils/module_docs_fragments/azure_tags.py
lib/ansible/utils/module_docs_fragments/ec2.py
lib/ansible/utils/module_docs_fragments/files.py
lib/ansible/utils/module_docs_fragments/infinibox.py
lib/ansible/utils/module_docs_fragments/netapp.py
lib/ansible/utils/module_docs_fragments/ovirt.py
lib/ansible/utils/module_docs_fragments/ovirt_facts.py

View file

@ -1,4 +1,3 @@
E101
E111
E114
E115
@ -9,9 +8,5 @@ E126
E129
E131
E501
E701
E703
E711
E712
E721
W191