From 10cd2cd1b787bff544acb52ff3ecabfa41119318 Mon Sep 17 00:00:00 2001 From: John Barker Date: Thu, 7 Dec 2017 17:41:31 +0000 Subject: [PATCH] Manually fix issues that autopep8 introduced * iam.py 161 -> 160 chars * lamba -> single line function -> multiline function Avoid redefining key iam line length iam.py now clean --- lib/ansible/modules/cloud/amazon/iam.py | 4 ++-- lib/ansible/modules/net_tools/snmp_facts.py | 3 ++- lib/ansible/modules/network/eos/eos_eapi.py | 3 ++- lib/ansible/modules/network/eos/eos_system.py | 3 ++- lib/ansible/modules/network/eos/eos_user.py | 6 ++++-- lib/ansible/modules/network/ios/ios_system.py | 3 ++- lib/ansible/modules/network/nxos/nxos_nxapi.py | 3 ++- lib/ansible/modules/network/nxos/nxos_system.py | 6 ++++-- lib/ansible/modules/network/nxos/nxos_user.py | 9 ++++++--- .../modules/storage/netapp/netapp_e_storagepool.py | 8 +++++--- test/sanity/pep8/legacy-files.txt | 9 --------- 11 files changed, 31 insertions(+), 26 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/iam.py b/lib/ansible/modules/cloud/amazon/iam.py index 346ac2095e8..d2fc1ac8c8c 100644 --- a/lib/ansible/modules/cloud/amazon/iam.py +++ b/lib/ansible/modules/cloud/amazon/iam.py @@ -559,8 +559,8 @@ def create_role(module, iam, name, path, role_list, prof_list, trust_policy_doc) path=path).create_role_response.create_role_result.role if name not in prof_list: - instance_profile_result = iam.create_instance_profile(name, - path=path).create_instance_profile_response.create_instance_profile_result.instance_profile + instance_profile_result = iam.create_instance_profile(name, path=path) \ + .create_instance_profile_response.create_instance_profile_result.instance_profile iam.add_role_to_instance_profile(name, name) else: instance_profile_result = iam.get_instance_profile(name).get_instance_profile_response.get_instance_profile_result.instance_profile diff --git a/lib/ansible/modules/net_tools/snmp_facts.py b/lib/ansible/modules/net_tools/snmp_facts.py index 84c905dcf6f..c37c1837a6d 100644 --- a/lib/ansible/modules/net_tools/snmp_facts.py +++ b/lib/ansible/modules/net_tools/snmp_facts.py @@ -243,7 +243,8 @@ def main(): # Use v without a prefix to use with return values v = DefineOid(dotprefix=False) - def Tree(): return defaultdict(Tree) + def Tree(): + return defaultdict(Tree) results = Tree() diff --git a/lib/ansible/modules/network/eos/eos_eapi.py b/lib/ansible/modules/network/eos/eos_eapi.py index 22d4a8d1d85..b1f1b6fd7d8 100644 --- a/lib/ansible/modules/network/eos/eos_eapi.py +++ b/lib/ansible/modules/network/eos/eos_eapi.py @@ -223,7 +223,8 @@ def map_obj_to_commands(updates, module, warnings): commands = list() want, have = updates - def needs_update(x): return want.get(x) is not None and (want.get(x) != have.get(x)) + def needs_update(x): + return want.get(x) is not None and (want.get(x) != have.get(x)) def add(cmd): if 'management api http-commands' not in commands: diff --git a/lib/ansible/modules/network/eos/eos_system.py b/lib/ansible/modules/network/eos/eos_system.py index 44fdd1725e4..3ab319f5e70 100644 --- a/lib/ansible/modules/network/eos/eos_system.py +++ b/lib/ansible/modules/network/eos/eos_system.py @@ -150,7 +150,8 @@ def map_obj_to_commands(want, have, module): commands = list() state = module.params['state'] - def needs_update(x): return want.get(x) and (want.get(x) != have.get(x)) + def needs_update(x): + return want.get(x) and (want.get(x) != have.get(x)) if state == 'absent': if have['domain_name']: diff --git a/lib/ansible/modules/network/eos/eos_user.py b/lib/ansible/modules/network/eos/eos_user.py index be4b8950009..2b8d0bf9a72 100644 --- a/lib/ansible/modules/network/eos/eos_user.py +++ b/lib/ansible/modules/network/eos/eos_user.py @@ -174,9 +174,11 @@ def map_obj_to_commands(updates, module): for update in updates: want, have = update - def needs_update(x): return want.get(x) and (want.get(x) != have.get(x)) + def needs_update(x): + return want.get(x) and (want.get(x) != have.get(x)) - def add(x): return commands.append('username %s %s' % (want['name'], x)) + def add(x): + return commands.append('username %s %s' % (want['name'], x)) if want['state'] == 'absent': commands.append('no username %s' % want['name']) diff --git a/lib/ansible/modules/network/ios/ios_system.py b/lib/ansible/modules/network/ios/ios_system.py index e0baf07c4b3..7b59e14859e 100644 --- a/lib/ansible/modules/network/ios/ios_system.py +++ b/lib/ansible/modules/network/ios/ios_system.py @@ -150,7 +150,8 @@ def map_obj_to_commands(want, have, module): commands = list() state = module.params['state'] - def needs_update(x): return want.get(x) is not None and (want.get(x) != have.get(x)) + def needs_update(x): + return want.get(x) is not None and (want.get(x) != have.get(x)) if state == 'absent': if have['hostname'] != 'Router': diff --git a/lib/ansible/modules/network/nxos/nxos_nxapi.py b/lib/ansible/modules/network/nxos/nxos_nxapi.py index 3f75808c88d..ff6a587c98e 100644 --- a/lib/ansible/modules/network/nxos/nxos_nxapi.py +++ b/lib/ansible/modules/network/nxos/nxos_nxapi.py @@ -164,7 +164,8 @@ def check_args(module, warnings): def map_obj_to_commands(want, have, module): commands = list() - def needs_update(x): return want.get(x) is not None and (want.get(x) != have.get(x)) + def needs_update(x): + return want.get(x) is not None and (want.get(x) != have.get(x)) if needs_update('state'): if want['state'] == 'absent': diff --git a/lib/ansible/modules/network/nxos/nxos_system.py b/lib/ansible/modules/network/nxos/nxos_system.py index 41dbfb4a2e6..ac236ee355e 100644 --- a/lib/ansible/modules/network/nxos/nxos_system.py +++ b/lib/ansible/modules/network/nxos/nxos_system.py @@ -134,9 +134,11 @@ def map_obj_to_commands(want, have, module): commands = list() state = module.params['state'] - def needs_update(x): return want.get(x) and (want.get(x) != have.get(x)) + def needs_update(x): + return want.get(x) and (want.get(x) != have.get(x)) - def difference(x, y, z): return [item for item in x[z] if item not in y[z]] + def difference(x, y, z): + return [item for item in x[z] if item not in y[z]] def remove(cmd, commands, vrf=None): if vrf: diff --git a/lib/ansible/modules/network/nxos/nxos_user.py b/lib/ansible/modules/network/nxos/nxos_user.py index 599409f8ab4..57ddb0f64ba 100644 --- a/lib/ansible/modules/network/nxos/nxos_user.py +++ b/lib/ansible/modules/network/nxos/nxos_user.py @@ -175,11 +175,14 @@ def map_obj_to_commands(updates, module): for update in updates: want, have = update - def needs_update(x): return want.get(x) and (want.get(x) != have.get(x)) + def needs_update(x): + return want.get(x) and (want.get(x) != have.get(x)) - def add(x): return commands.append('username %s %s' % (want['name'], x)) + def add(x): + return commands.append('username %s %s' % (want['name'], x)) - def remove(x): return commands.append('no username %s %s' % (want['name'], x)) + def remove(x): + return commands.append('no username %s %s' % (want['name'], x)) if want['state'] == 'absent': commands.append('no username %s' % want['name']) diff --git a/lib/ansible/modules/storage/netapp/netapp_e_storagepool.py b/lib/ansible/modules/storage/netapp/netapp_e_storagepool.py index 994376ecbe6..e0a0c7dc948 100644 --- a/lib/ansible/modules/storage/netapp/netapp_e_storagepool.py +++ b/lib/ansible/modules/storage/netapp/netapp_e_storagepool.py @@ -121,12 +121,14 @@ def select(predicate, iterable): yield x +def _identity(obj): + return obj + + class GroupBy(object): # python 2, 3 generic grouping. def __init__(self, iterable, key=None): - if key is None: - def key(x): return x - self.keyfunc = key + self.keyfunc = key if key else _identity self.it = iter(iterable) self.tgtkey = self.currkey = self.currvalue = object() diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 4ab50620fa1..ac9455dd56f 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -2,7 +2,6 @@ lib/ansible/modules/cloud/amazon/aws_kms.py lib/ansible/modules/cloud/amazon/ec2_elb.py lib/ansible/modules/cloud/amazon/ecs_task.py lib/ansible/modules/cloud/amazon/elb_instance.py -lib/ansible/modules/cloud/amazon/iam.py lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py lib/ansible/modules/cloud/centurylink/clc_loadbalancer.py lib/ansible/modules/cloud/openstack/os_security_group_rule.py @@ -20,17 +19,9 @@ lib/ansible/modules/network/aos/aos_logical_device_map.py lib/ansible/modules/network/aos/aos_logical_device.py lib/ansible/modules/network/aos/aos_rack_type.py lib/ansible/modules/network/aos/aos_template.py -lib/ansible/modules/network/eos/eos_eapi.py -lib/ansible/modules/network/eos/eos_system.py -lib/ansible/modules/network/eos/eos_user.py -lib/ansible/modules/network/ios/ios_system.py -lib/ansible/modules/network/nxos/nxos_nxapi.py -lib/ansible/modules/network/nxos/nxos_system.py -lib/ansible/modules/network/nxos/nxos_user.py lib/ansible/modules/network/ovs/openvswitch_bridge.py lib/ansible/modules/network/ovs/openvswitch_port.py lib/ansible/modules/network/sros/sros_rollback.py lib/ansible/modules/packaging/language/maven_artifact.py lib/ansible/modules/packaging/os/homebrew_cask.py lib/ansible/modules/packaging/os/homebrew.py -lib/ansible/modules/storage/netapp/netapp_e_storagepool.py