PEP 8 whitespace cleanup. (#20783)

* PEP 8 E271 whitespace cleanup.
* PEP 8 W293 whitespace cleanup.
* Fix whitespace issue from recent PR.
This commit is contained in:
Matt Clay 2017-01-27 15:45:23 -08:00 committed by GitHub
parent 802fbcadf8
commit 95789f3949
132 changed files with 287 additions and 313 deletions

View file

@ -289,7 +289,7 @@ class ConsulInventory(object):
and the node name add each entry in the dictionary to the the node's
metadata '''
node = node_data['Node']
if self.config.has_config('kv_metadata'):
if self.config.has_config('kv_metadata'):
key = "%s/%s/%s" % (self.config.kv_metadata, self.current_dc, node['Node'])
index, metadata = self.consul_api.kv.get(key)
if metadata and metadata['Value']:
@ -305,7 +305,7 @@ class ConsulInventory(object):
kv_groups config value and the node name add the node address to each
group found '''
node = node_data['Node']
if self.config.has_config('kv_groups'):
if self.config.has_config('kv_groups'):
key = "%s/%s/%s" % (self.config.kv_groups, self.current_dc, node['Node'])
index, groups = self.consul_api.kv.get(key)
if groups and groups['Value']:

View file

@ -39,7 +39,7 @@ def list_groups(api):
if 'member_host' in hostgroup:
members = [host for host in hostgroup['member_host']]
if 'memberindirect_host' in hostgroup:
members += (host for host in hostgroup['memberindirect_host'])
members += (host for host in hostgroup['memberindirect_host'])
inventory[hostgroup['cn'][0]] = {'hosts': [host for host in members]}
for member in members:

View file

@ -3,10 +3,10 @@
import optparse
from jinja2 import Environment, FileSystemLoader
from ansible.playbook import Play
from ansible.playbook.block import Block
from ansible.playbook.role import Role
from ansible.playbook.task import Task
from ansible.playbook import Play
from ansible.playbook.block import Block
from ansible.playbook.role import Role
from ansible.playbook.task import Task
template_file = 'playbooks_directives.rst.j2'
oblist = {}

View file

@ -59,7 +59,7 @@ class AggregateStats:
if host is None:
host = '_run'
if host not in self.custom:
if host not in self.custom:
self.custom[host] = {which: what}
else:
self.custom[host][which] = what

View file

@ -208,7 +208,7 @@ class GalaxyRole(object):
# create tar file from scm url
tmp_file = RoleRequirement.scm_archive_role(**self.spec)
elif self.src:
if os.path.isfile(self.src):
if os.path.isfile(self.src):
# installing a local tar.gz
local_file = True
tmp_file = self.src

View file

@ -368,7 +368,7 @@ class Facts(object):
self.facts['service_mgr'] = proc_1_map.get(proc_1, proc_1)
# start with the easy ones
elif self.facts['distribution'] == 'MacOSX':
elif self.facts['distribution'] == 'MacOSX':
#FIXME: find way to query executable, version matching is not ideal
if LooseVersion(platform.mac_ver()[0]) >= LooseVersion('10.4'):
self.facts['service_mgr'] = 'launchd'
@ -2155,7 +2155,7 @@ class AIX(Hardware):
rc, out, err = self.module.run_command(cmd)
if rc == 0 and out:
pp_size = re.search(r'PP SIZE:\s+(\d+\s+\S+)',out).group(1)
for n in re.finditer(r'(\S+)\s+(\w+)\s+(\d+)\s+(\d+).*',m.group(0)):
for n in re.finditer(r'(\S+)\s+(\w+)\s+(\d+)\s+(\d+).*',m.group(0)):
pv_info = { 'pv_name': n.group(1),
'pv_state': n.group(2),
'total_pps': n.group(3),

View file

@ -827,7 +827,7 @@ def wait_for_term_inst(connection, module, term_instances):
lifecycle = instance_facts[i]['lifecycle_state']
health = instance_facts[i]['health_status']
log.debug("Instance {0} has state of {1},{2}".format(i,lifecycle,health ))
if lifecycle == 'Terminating' or health == 'Unhealthy':
if lifecycle == 'Terminating' or health == 'Unhealthy':
count += 1
time.sleep(10)

View file

@ -457,7 +457,7 @@ def delete_group(module=None, iam=None, name=None):
iam.delete_group_policy(name, policy)
try:
iam.delete_group(name)
except boto.exception.BotoServerError as err:
except boto.exception.BotoServerError as err:
error_msg = boto_exception(err)
if ('must detach all policies first') in error_msg:
module.fail_json(changed=changed, msg="All inline polices have been removed. Though it appears"

View file

@ -470,7 +470,7 @@ def main():
if command_in == 'create':
if ( weight_in!=None or region_in!=None or failover_in!=None ) and identifier_in==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==None and region_in==None and failover_in==None ) and identifier_in!=None:
module.fail_json(msg= "You have specified identifier which makes sense only if you specify one of: weight, region or failover.")

View file

@ -372,7 +372,7 @@ class AzureRMStorageBlob(AzureRMModuleBase):
self.log('Create container %s' % self.container)
tags = None
if not self.blob and self.tags:
if not self.blob and self.tags:
# when a blob is present, then tags are assigned at the blob level
tags = self.tags

View file

@ -918,7 +918,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
interface_dict['properties'] = nic_dict['properties']
# Expand public IPs to include config properties
for interface in result['properties']['networkProfile']['networkInterfaces']:
for interface in result['properties']['networkProfile']['networkInterfaces']:
for config in interface['properties']['ipConfigurations']:
if config['properties'].get('publicIPAddress'):
pipid_dict = azure_id_to_dict(config['properties']['publicIPAddress']['id'])

View file

@ -347,7 +347,7 @@ class AzureRMVirtualNetwork(AzureRMModuleBase):
try:
poller = self.network_client.virtual_networks.create_or_update(self.resource_group, self.name, vnet)
new_vnet = self.get_poller_result(poller)
except Exception as exc:
except Exception as exc:
self.fail("Error creating or updating virtual network {0} - {1}".format(self.name, str(exc)))
return virtual_network_to_dict(new_vnet)

View file

@ -232,7 +232,7 @@ class AnsibleCloudStackInstanceFacts(AnsibleCloudStack):
if not instance:
self.module.fail_json(msg="Instance not found: %s" % self.module.params.get('name'))
self.facts['cloudstack_instance'] = self.get_result(instance)
return self.facts
return self.facts
def get_result(self, instance):

View file

@ -180,7 +180,7 @@ def _add_gateway_router(neutron, module, router_id, network_id):
module.fail_json(msg = "Error in adding gateway to router: %s" % e.message)
return True
def _remove_gateway_router(neutron, module, router_id):
def _remove_gateway_router(neutron, module, router_id):
try:
neutron.remove_gateway_router(router_id)
except Exception as e:

View file

@ -193,7 +193,7 @@ def _get_port_id(neutron, module, router_id, subnet_id):
module.fail_json( msg = "Error in listing ports: %s" % e.message)
if not ports['ports']:
return None
for port in ports['ports']:
for port in ports['ports']:
for subnet in port['fixed_ips']:
if subnet['subnet_id'] == subnet_id:
return port['id']
@ -209,7 +209,7 @@ def _add_interface_router(neutron, module, router_id, subnet_id):
module.fail_json(msg = "Error in adding interface to router: %s" % e.message)
return True
def _remove_interface_router(neutron, module, router_id, subnet_id):
def _remove_interface_router(neutron, module, router_id, subnet_id):
kwargs = {
'subnet_id': subnet_id
}

View file

@ -395,7 +395,7 @@ def parse_service(module):
module.fail_json( msg="service_name supplied but no service_port, a port is required to configure a service. Did you configure the 'port' argument meaning 'service_port'?")
class ConsulService():
class ConsulService():
def __init__(self, service_id=None, name=None, address=None, port=-1,
tags=None, loaded=None):

View file

@ -253,12 +253,12 @@ def main():
if lang_exists(cursor, lang):
lang_trusted = lang_istrusted(cursor, lang)
if (lang_trusted and not trust) or (not lang_trusted and trust):
if module.check_mode:
if module.check_mode:
changed = True
else:
changed = lang_altertrust(cursor, lang, trust)
else:
if module.check_mode:
if module.check_mode:
changed = True
else:
changed = lang_add(cursor, lang, trust)
@ -267,7 +267,7 @@ def main():
else:
if lang_exists(cursor, lang):
if module.check_mode:
if module.check_mode:
changed = True
kw['lang_dropped'] = True
else:

View file

@ -688,7 +688,7 @@ def main():
module.fail_json(msg=str(e))
else:
if user_exists(cursor, user):
if module.check_mode:
if module.check_mode:
changed = True
kw['user_removed'] = True
else:

View file

@ -121,9 +121,9 @@ def build_url(name, apiid, action, meter_id=None, cert_type=None):
elif action == "certificates":
return "https://%s/%s/meters/%s/%s.pem" % (api_host, apiid, meter_id, cert_type)
elif action == "tags":
return "https://%s/%s/meters/%s/tags" % (api_host, apiid, meter_id)
return "https://%s/%s/meters/%s/tags" % (api_host, apiid, meter_id)
elif action == "delete":
return "https://%s/%s/meters/%s" % (api_host, apiid, meter_id)
return "https://%s/%s/meters/%s" % (api_host, apiid, meter_id)
def http_request(module, name, apiid, apikey, action, data=None, meter_id=None, cert_type=None):

View file

@ -391,7 +391,7 @@ class CloudflareAPI(object):
error_msg += "; Failed to parse API response: {0}".format(content)
# received an error status but no data with details on what failed
if (info['status'] not in [200,304]) and (result is None):
if (info['status'] not in [200,304]) and (result is None):
self.module.fail_json(msg=error_msg)
if not result['success']:

View file

@ -283,7 +283,7 @@ def map_config_to_obj(module):
'state': parse_state(out)
}
def map_params_to_obj(module):
def map_params_to_obj(module):
obj = {
'http': module.params['http'],
'http_port': module.params['http_port'],
@ -310,7 +310,7 @@ def collect_facts(module, result):
for each in out[0]['urls']:
intf, url = each.split(' : ')
key = str(intf).strip()
if key not in facts['eos_eapi_urls']:
if key not in facts['eos_eapi_urls']:
facts['eos_eapi_urls'][key] = list()
facts['eos_eapi_urls'][key].append(str(url).strip())
result['ansible_facts'] = facts

View file

@ -612,7 +612,7 @@ def get_custom_string_value(config, arg, module):
elif arg.startswith('dampening'):
REGEX = re.compile(r'(?:{0}\s)(?P<value>.*)$'.format(
PARAM_TO_COMMAND_KEYMAP[arg]), re.M)
if arg == 'dampen_igp_metric' or arg == 'dampening_routemap':
if arg == 'dampen_igp_metric' or arg == 'dampening_routemap':
value = ''
if PARAM_TO_COMMAND_KEYMAP[arg] in config:
value = REGEX.search(config).group('value')

View file

@ -295,7 +295,7 @@ def main():
supports_check_mode=True)
splitted_ssm_range = module.params['ssm_range'].split('.')
if len(splitted_ssm_range) != 4 and module.params['ssm_range'] != 'none':
if len(splitted_ssm_range) != 4 and module.params['ssm_range'] != 'none':
module.fail_json(msg="Valid ssm_range values are multicast addresses "
"or the keyword 'none'.")

View file

@ -108,7 +108,7 @@ class IncludeRole(Task):
# build options for role includes
for key in ['tasks', 'vars', 'defaults']:
from_key ='%s_from' % key
if ir.args.get(from_key):
if ir.args.get(from_key):
ir._from_files[key] = basename(ir.args.get(from_key))
#FIXME: find a way to make this list come from object ( attributes does not work as per below)

View file

@ -51,7 +51,7 @@ class ActionModule(ActionBase):
if module == 'auto':
facts = self._execute_module(module_name='setup', module_args=dict(filter='ansible_pkg_mgr', gather_subset='!all'), task_vars=task_vars)
display.debug("Facts %s" % facts)
if 'ansible_facts' in facts and 'ansible_pkg_mgr' in facts['ansible_facts']:
if 'ansible_facts' in facts and 'ansible_pkg_mgr' in facts['ansible_facts']:
module = getattr(facts['ansible_facts'], 'ansible_pkg_mgr', 'auto')
if module != 'auto':

View file

@ -50,7 +50,7 @@ class ActionModule(ActionBase):
if module == 'auto':
facts = self._execute_module(module_name='setup', module_args=dict(gather_subset='!all', filter='ansible_service_mgr'), task_vars=task_vars)
self._display.debug("Facts %s" % facts)
if 'ansible_facts' in facts and 'ansible_service_mgr' in facts['ansible_facts']:
if 'ansible_facts' in facts and 'ansible_service_mgr' in facts['ansible_facts']:
module = facts['ansible_facts']['ansible_service_mgr']
if not module or module == 'auto' or module not in self._shared_loader_obj.module_loader:

View file

@ -899,7 +899,7 @@ class StrategyBase:
elif meta_action == 'end_play':
if _evaluate_conditional(target_host):
for host in self._inventory.get_hosts(iterator._play.hosts):
if not host.name in self._tqm._unreachable_hosts:
if not host.name in self._tqm._unreachable_hosts:
iterator._host_states[host.name].run_state = iterator.ITERATING_COMPLETE
msg="ending play"
#elif meta_action == 'reset_connection':

View file

@ -371,7 +371,7 @@ class VariableManager:
# special case for the 'environment' magic variable, as someone
# may have set it as a variable and we don't want to stomp on it
if task:
if 'environment' not in all_vars:
if 'environment' not in all_vars:
all_vars['environment'] = task.environment
else:
display.warning("The variable 'environment' appears to be used already, which is also used internally for environment variables set on the task/block/play. You should use a different variable name to avoid conflicts with this internal variable")

View file

@ -75,10 +75,10 @@ def prompt_and_delete(item, prompt, assumeyes):
assumeyes = raw_input(prompt).lower() == 'y'
assert hasattr(item, 'delete') or hasattr(item, 'terminate') , "Class <%s> has no delete or terminate attribute" % item.__class__
if assumeyes:
if hasattr(item, 'delete'):
if hasattr(item, 'delete'):
item.delete()
print ("Deleted %s" % item)
if hasattr(item, 'terminate'):
if hasattr(item, 'terminate'):
item.terminate()
print ("Terminated %s" % item)

View file

@ -6,7 +6,6 @@ contrib/inventory/consul_io.py
contrib/inventory/digital_ocean.py
contrib/inventory/docker.py
contrib/inventory/ec2.py
contrib/inventory/fleet.py
contrib/inventory/freeipa.py
contrib/inventory/gce.py
contrib/inventory/linode.py
@ -16,7 +15,6 @@ contrib/inventory/rax.py
contrib/inventory/softlayer.py
contrib/inventory/spacewalk.py
contrib/inventory/ssh_config.py
contrib/inventory/stacki.py
contrib/inventory/vbox.py
contrib/inventory/vmware_inventory.py
contrib/inventory/windows_azure.py
@ -27,7 +25,6 @@ docs/docsite/conf.py
docs/docsite/rst/conf.py
docs/docsite/rst/dev_guide/conf.py
examples/scripts/uptime.py
hacking/dump_playbook_attributes.py
hacking/metadata-tool.py
hacking/module_formatter.py
hacking/tests/gen_distribution_version_testcase.py
@ -142,16 +139,13 @@ lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py
lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py
lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py
lib/ansible/modules/cloud/azure/azure_rm_securitygroup_facts.py
lib/ansible/modules/cloud/azure/azure_rm_storageblob.py
lib/ansible/modules/cloud/azure/azure_rm_subnet.py
lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py
lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py
lib/ansible/modules/cloud/centurylink/clc_loadbalancer.py
lib/ansible/modules/cloud/cloudscale/cloudscale_server.py
lib/ansible/modules/cloud/cloudstack/cs_firewall.py
lib/ansible/modules/cloud/cloudstack/cs_host.py
lib/ansible/modules/cloud/cloudstack/cs_instance.py
lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py
lib/ansible/modules/cloud/cloudstack/cs_iso.py
lib/ansible/modules/cloud/cloudstack/cs_portforward.py
lib/ansible/modules/cloud/cloudstack/cs_securitygroup_rule.py
@ -163,7 +157,6 @@ lib/ansible/modules/cloud/docker/docker_image.py
lib/ansible/modules/cloud/docker/docker_service.py
lib/ansible/modules/cloud/google/gc_storage.py
lib/ansible/modules/cloud/google/gcdns_record.py
lib/ansible/modules/cloud/google/gcdns_zone.py
lib/ansible/modules/cloud/google/gce_img.py
lib/ansible/modules/cloud/google/gce_lb.py
lib/ansible/modules/cloud/google/gce_mig.py
@ -212,7 +205,6 @@ lib/ansible/modules/cloud/profitbricks/profitbricks_volume_attachments.py
lib/ansible/modules/cloud/rackspace/rax_cbs.py
lib/ansible/modules/cloud/rackspace/rax_cbs_attachments.py
lib/ansible/modules/cloud/rackspace/rax_clb.py
lib/ansible/modules/cloud/rackspace/rax_facts.py
lib/ansible/modules/cloud/rackspace/rax_identity.py
lib/ansible/modules/cloud/rackspace/rax_network.py
lib/ansible/modules/cloud/rackspace/rax_queue.py
@ -220,7 +212,6 @@ lib/ansible/modules/cloud/softlayer/sl_vm.py
lib/ansible/modules/cloud/vmware/vca_fw.py
lib/ansible/modules/cloud/vmware/vmware_guest.py
lib/ansible/modules/cloud/vmware/vmware_local_user_manager.py
lib/ansible/modules/cloud/vmware/vmware_vswitch.py
lib/ansible/modules/cloud/vmware/vsphere_copy.py
lib/ansible/modules/cloud/vmware/vsphere_guest.py
lib/ansible/modules/cloud/webfaction/webfaction_app.py
@ -234,10 +225,8 @@ lib/ansible/modules/clustering/consul_kv.py
lib/ansible/modules/clustering/consul_session.py
lib/ansible/modules/commands/command.py
lib/ansible/modules/commands/script.py
lib/ansible/modules/crypto/openssl_privatekey.py
lib/ansible/modules/crypto/openssl_publickey.py
lib/ansible/modules/database/influxdb/influxdb_retention_policy.py
lib/ansible/modules/database/misc/elasticsearch_plugin.py
lib/ansible/modules/database/misc/kibana_plugin.py
lib/ansible/modules/database/misc/mongodb_parameter.py
lib/ansible/modules/database/misc/mongodb_user.py
@ -254,7 +243,6 @@ lib/ansible/modules/database/postgresql/postgresql_lang.py
lib/ansible/modules/database/postgresql/postgresql_privs.py
lib/ansible/modules/database/postgresql/postgresql_schema.py
lib/ansible/modules/database/postgresql/postgresql_user.py
lib/ansible/modules/database/vertica/vertica_configuration.py
lib/ansible/modules/database/vertica/vertica_role.py
lib/ansible/modules/database/vertica/vertica_schema.py
lib/ansible/modules/database/vertica/vertica_user.py
@ -280,7 +268,6 @@ lib/ansible/modules/monitoring/logicmonitor.py
lib/ansible/modules/monitoring/logicmonitor_facts.py
lib/ansible/modules/monitoring/monit.py
lib/ansible/modules/monitoring/nagios.py
lib/ansible/modules/monitoring/newrelic_deployment.py
lib/ansible/modules/monitoring/pagerduty.py
lib/ansible/modules/monitoring/pagerduty_alert.py
lib/ansible/modules/monitoring/pingdom.py
@ -297,7 +284,6 @@ lib/ansible/modules/network/a10/a10_virtual_server.py
lib/ansible/modules/network/basics/get_url.py
lib/ansible/modules/network/basics/slurp.py
lib/ansible/modules/network/basics/uri.py
lib/ansible/modules/network/bigswitch/bigmon_chain.py
lib/ansible/modules/network/cloudengine/ce_command.py
lib/ansible/modules/network/cloudflare_dns.py
lib/ansible/modules/network/dellos10/dellos10_facts.py
@ -307,7 +293,6 @@ lib/ansible/modules/network/dellos9/dellos9_config.py
lib/ansible/modules/network/dellos9/dellos9_facts.py
lib/ansible/modules/network/dnsimple.py
lib/ansible/modules/network/dnsmadeeasy.py
lib/ansible/modules/network/eos/eos_eapi.py
lib/ansible/modules/network/exoscale/exo_dns_record.py
lib/ansible/modules/network/f5/bigip_facts.py
lib/ansible/modules/network/f5/bigip_monitor_tcp.py
@ -382,7 +367,6 @@ lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py
lib/ansible/modules/network/ovs/openvswitch_port.py
lib/ansible/modules/network/panos/panos_nat_policy.py
lib/ansible/modules/network/snmp_facts.py
lib/ansible/modules/network/wakeonlan.py
lib/ansible/modules/notification/flowdock.py
lib/ansible/modules/notification/hall.py
lib/ansible/modules/notification/irc.py
@ -507,13 +491,10 @@ lib/ansible/playbook/play_context.py
lib/ansible/playbook/playbook_include.py
lib/ansible/playbook/role/__init__.py
lib/ansible/playbook/role/metadata.py
lib/ansible/playbook/role_include.py
lib/ansible/playbook/taggable.py
lib/ansible/plugins/action/__init__.py
lib/ansible/plugins/action/add_host.py
lib/ansible/plugins/action/async.py
lib/ansible/plugins/action/package.py
lib/ansible/plugins/action/service.py
lib/ansible/plugins/action/set_fact.py
lib/ansible/plugins/action/set_stats.py
lib/ansible/plugins/action/synchronize.py
@ -522,14 +503,12 @@ lib/ansible/plugins/cache/jsonfile.py
lib/ansible/plugins/callback/default.py
lib/ansible/plugins/callback/dense.py
lib/ansible/plugins/callback/foreman.py
lib/ansible/plugins/callback/jabber.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/callback/syslog_json.py
lib/ansible/plugins/connection/accelerate.py
lib/ansible/plugins/connection/iocage.py
lib/ansible/plugins/connection/paramiko_ssh.py
lib/ansible/plugins/connection/ssh.py
lib/ansible/plugins/connection/winrm.py
@ -581,14 +560,12 @@ test/units/module_utils/basic/test_log.py
test/units/module_utils/basic/test_no_log.py
test/units/module_utils/basic/test_safe_eval.py
test/units/module_utils/basic/test_set_mode_if_different.py
test/units/module_utils/gcp/test_auth.py
test/units/module_utils/json_utils/test_filter_non_json_lines.py
test/units/module_utils/test_basic.py
test/units/module_utils/test_distribution_version.py
test/units/module_utils/test_facts.py
test/units/module_utils/test_text.py
test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py
test/units/modules/cloud/google/test_gce_tag.py
test/units/parsing/test_mod_args.py
test/units/parsing/yaml/test_loader.py
test/units/playbook/test_block.py
@ -599,7 +576,6 @@ test/units/playbook/test_task.py
test/units/plugins/action/test_raw.py
test/units/plugins/action/test_synchronize.py
test/units/plugins/lookup/test_ini.py
test/units/plugins/lookup/test_lastpass.py
test/units/plugins/lookup/test_password.py
test/units/plugins/strategy/test_strategy_base.py
test/units/template/test_templar.py

View file

@ -8,7 +8,6 @@ E125
E126
E129
E131
E271
E501
E701
E703
@ -17,4 +16,3 @@ E712
E721
W191
W291
W293