1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Clean up pyflakes warnings in inventory

This commit is contained in:
Toshio Kuratomi 2015-10-19 11:13:56 -07:00
parent 63add130d4
commit a17ae6f07e
3 changed files with 5 additions and 7 deletions

View file

@ -23,7 +23,6 @@ import fnmatch
import os import os
import sys import sys
import re import re
import stat
import itertools import itertools
from ansible.compat.six import string_types from ansible.compat.six import string_types
@ -134,7 +133,7 @@ class Inventory(object):
return re.search(pattern_str[1:], str) return re.search(pattern_str[1:], str)
else: else:
return fnmatch.fnmatch(str, pattern_str) return fnmatch.fnmatch(str, pattern_str)
except Exception as e: except Exception:
raise AnsibleError('invalid host pattern: %s' % pattern_str) raise AnsibleError('invalid host pattern: %s' % pattern_str)
def _match_list(self, items, item_attr, 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)) pattern = re.compile(fnmatch.translate(pattern_str))
else: else:
pattern = re.compile(pattern_str[1:]) pattern = re.compile(pattern_str[1:])
except Exception as e: except Exception:
raise AnsibleError('invalid host pattern: %s' % pattern_str) raise AnsibleError('invalid host pattern: %s' % pattern_str)
for item in items: for item in items:
@ -397,7 +396,6 @@ class Inventory(object):
""" """
results = [] results = []
hosts = []
hostnames = set() hostnames = set()
def __append_host_to_results(host): def __append_host_to_results(host):

View file

@ -23,7 +23,7 @@ import ast
import re import re
from ansible import constants as C from ansible import constants as C
from ansible.errors import * from ansible.errors import AnsibleError
from ansible.inventory.host import Host from ansible.inventory.host import Host
from ansible.inventory.group import Group from ansible.inventory.group import Group
from ansible.inventory.expand_hosts import detect_range from ansible.inventory.expand_hosts import detect_range
@ -231,7 +231,7 @@ class InventoryParser(object):
try: try:
tokens = shlex_split(line, comments=True) tokens = shlex_split(line, comments=True)
except ValueError as e: 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]) (hostnames, port) = self._expand_hostpattern(tokens[0])
hosts = self._Hosts(hostnames, port) hosts = self._Hosts(hostnames, port)

View file

@ -27,7 +27,7 @@ from collections import Mapping
from ansible.compat.six import iteritems from ansible.compat.six import iteritems
from ansible import constants as C from ansible import constants as C
from ansible.errors import * from ansible.errors import AnsibleError
from ansible.inventory.host import Host from ansible.inventory.host import Host
from ansible.inventory.group import Group from ansible.inventory.group import Group
from ansible.module_utils.basic import json_dict_bytes_to_unicode from ansible.module_utils.basic import json_dict_bytes_to_unicode