From a17ae6f07e9e45a70f49abb5439b431c1819ba62 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 19 Oct 2015 11:13:56 -0700 Subject: [PATCH] Clean up pyflakes warnings in inventory --- lib/ansible/inventory/__init__.py | 6 ++---- lib/ansible/inventory/ini.py | 4 ++-- lib/ansible/inventory/script.py | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 427a4d77f8..cedca17024 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -23,7 +23,6 @@ import fnmatch import os import sys import re -import stat import itertools from ansible.compat.six import string_types @@ -134,7 +133,7 @@ class Inventory(object): return re.search(pattern_str[1:], str) else: return fnmatch.fnmatch(str, pattern_str) - except Exception as e: + except Exception: raise AnsibleError('invalid host pattern: %s' % pattern_str) def _match_list(self, items, item_attr, pattern_str): @@ -144,7 +143,7 @@ class Inventory(object): pattern = re.compile(fnmatch.translate(pattern_str)) else: pattern = re.compile(pattern_str[1:]) - except Exception as e: + except Exception: raise AnsibleError('invalid host pattern: %s' % pattern_str) for item in items: @@ -397,7 +396,6 @@ class Inventory(object): """ results = [] - hosts = [] hostnames = set() def __append_host_to_results(host): diff --git a/lib/ansible/inventory/ini.py b/lib/ansible/inventory/ini.py index 040073237a..537fde1ef9 100644 --- a/lib/ansible/inventory/ini.py +++ b/lib/ansible/inventory/ini.py @@ -23,7 +23,7 @@ import ast import re from ansible import constants as C -from ansible.errors import * +from ansible.errors import AnsibleError from ansible.inventory.host import Host from ansible.inventory.group import Group from ansible.inventory.expand_hosts import detect_range @@ -231,7 +231,7 @@ class InventoryParser(object): try: tokens = shlex_split(line, comments=True) except ValueError as e: - self._raise_error("Error parsing host definition '%s': %s" % (varstring, e)) + self._raise_error("Error parsing host definition '%s': %s" % (line, e)) (hostnames, port) = self._expand_hostpattern(tokens[0]) hosts = self._Hosts(hostnames, port) diff --git a/lib/ansible/inventory/script.py b/lib/ansible/inventory/script.py index 8fa53c05db..6dfb1d2af0 100644 --- a/lib/ansible/inventory/script.py +++ b/lib/ansible/inventory/script.py @@ -27,7 +27,7 @@ from collections import Mapping from ansible.compat.six import iteritems from ansible import constants as C -from ansible.errors import * +from ansible.errors import AnsibleError from ansible.inventory.host import Host from ansible.inventory.group import Group from ansible.module_utils.basic import json_dict_bytes_to_unicode