From 7aa9f6754ad3ba558ae070f303e0bde19490c637 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 19 Oct 2015 11:58:36 -0700 Subject: [PATCH] Cleanup more pyflakes warnings (2 real problems) --- lib/ansible/plugins/lookup/csvfile.py | 3 +-- lib/ansible/plugins/lookup/dig.py | 5 +++-- lib/ansible/plugins/lookup/dnstxt.py | 6 ++---- lib/ansible/plugins/lookup/file.py | 5 +---- lib/ansible/plugins/lookup/hashi_vault.py | 7 ++----- lib/ansible/plugins/lookup/ini.py | 7 +++---- lib/ansible/plugins/lookup/lines.py | 2 +- 7 files changed, 13 insertions(+), 22 deletions(-) diff --git a/lib/ansible/plugins/lookup/csvfile.py b/lib/ansible/plugins/lookup/csvfile.py index 9ef3e5dded..976e6f58a4 100644 --- a/lib/ansible/plugins/lookup/csvfile.py +++ b/lib/ansible/plugins/lookup/csvfile.py @@ -17,11 +17,10 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import os import codecs import csv -from ansible.errors import * +from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase class LookupModule(LookupBase): diff --git a/lib/ansible/plugins/lookup/dig.py b/lib/ansible/plugins/lookup/dig.py index a3ba43879b..3ef9d4728d 100644 --- a/lib/ansible/plugins/lookup/dig.py +++ b/lib/ansible/plugins/lookup/dig.py @@ -24,8 +24,9 @@ import socket try: import dns.resolver import dns.reversename - from dns.rdatatype import * - from dns.exception import DNSException + from dns.rdatatype import (A, AAAA, CNAME, DLV, DNAME, DNSKEY, DS, HINFO, LOC, + MX, NAPTR, NS, NSEC3PARAM, PTR, RP, SOA, SPF, SRV, SSHFP, TLSA, TXT) + import dns.exception HAVE_DNS = True except ImportError: HAVE_DNS = False diff --git a/lib/ansible/plugins/lookup/dnstxt.py b/lib/ansible/plugins/lookup/dnstxt.py index 59d3820f71..e97ee46d18 100644 --- a/lib/ansible/plugins/lookup/dnstxt.py +++ b/lib/ansible/plugins/lookup/dnstxt.py @@ -17,8 +17,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import os - HAVE_DNS=False try: import dns.resolver @@ -27,7 +25,7 @@ try: except ImportError: pass -from ansible.errors import * +from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase # ============================================================== @@ -58,7 +56,7 @@ class LookupModule(LookupBase): string = 'NXDOMAIN' except dns.resolver.Timeout: string = '' - except dns.exception.DNSException as e: + except DNSException as e: raise AnsibleError("dns.resolver unhandled exception", e) ret.append(''.join(string)) diff --git a/lib/ansible/plugins/lookup/file.py b/lib/ansible/plugins/lookup/file.py index cbfb8f31b4..26b10fce01 100644 --- a/lib/ansible/plugins/lookup/file.py +++ b/lib/ansible/plugins/lookup/file.py @@ -17,10 +17,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import os -import codecs - -from ansible.errors import * +from ansible.errors import AnsibleError, AnsibleParserError from ansible.plugins.lookup import LookupBase class LookupModule(LookupBase): diff --git a/lib/ansible/plugins/lookup/hashi_vault.py b/lib/ansible/plugins/lookup/hashi_vault.py index b1e8adfe0f..4e09d0c7b2 100644 --- a/lib/ansible/plugins/lookup/hashi_vault.py +++ b/lib/ansible/plugins/lookup/hashi_vault.py @@ -31,7 +31,7 @@ __metaclass__ = type import os -from ansible.errors import * +from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase @@ -59,16 +59,13 @@ class HashiVault: raise AnsibleError("Invalid Hashicorp Vault Token Specified") def get(self): - value = "" - data = self.client.read(self.secret) - if data == None: + if data is None: raise AnsibleError("The secret %s doesn't seem to exist" % self.secret) else: return data['data']['value'] - class LookupModule(LookupBase): def run(self, terms, variables, **kwargs): diff --git a/lib/ansible/plugins/lookup/ini.py b/lib/ansible/plugins/lookup/ini.py index 9c1adc90ca..3adbd2c7d6 100644 --- a/lib/ansible/plugins/lookup/ini.py +++ b/lib/ansible/plugins/lookup/ini.py @@ -19,11 +19,10 @@ __metaclass__ = type import StringIO import os -import codecs import ConfigParser import re -from ansible.errors import * +from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase class LookupModule(LookupBase): @@ -47,7 +46,7 @@ class LookupModule(LookupBase): # Retrieve a single value try: value = self.cp.get(section, key) - except ConfigParser.NoOptionError as e: + except ConfigParser.NoOptionError: return dflt return value @@ -77,7 +76,7 @@ class LookupModule(LookupBase): assert(name in paramvals) paramvals[name] = value except (ValueError, AssertionError) as e: - raise errors.AnsibleError(e) + raise AnsibleError(e) path = self._loader.path_dwim_relative(basedir, 'files', paramvals['file']) if paramvals['type'] == "properties": diff --git a/lib/ansible/plugins/lookup/lines.py b/lib/ansible/plugins/lookup/lines.py index 0d842bf148..432b12d040 100644 --- a/lib/ansible/plugins/lookup/lines.py +++ b/lib/ansible/plugins/lookup/lines.py @@ -19,7 +19,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import subprocess -from ansible.errors import * +from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase class LookupModule(LookupBase):