Merge pull request #12502 from mgedmin/py3k

Python 3: make test_variable_manager_precedence pass
This commit is contained in:
James Cammarata
2015-09-25 03:05:02 -04:00
7 changed files with 126 additions and 11 deletions

View File

@@ -38,6 +38,12 @@ class Host:
def __eq__(self, other):
return self.name == other.name
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return hash(self.name)
def serialize(self):
groups = []
for group in self.groups:

View File

@@ -20,7 +20,6 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import ast
import shlex
import re
from ansible import constants as C
@@ -30,7 +29,8 @@ from ansible.inventory.group import Group
from ansible.inventory.expand_hosts import detect_range
from ansible.inventory.expand_hosts import expand_hostname_range
from ansible.parsing.utils.addresses import parse_address
from ansible.utils.unicode import to_unicode, to_bytes
from ansible.utils.shlex import shlex_split
from ansible.utils.unicode import to_unicode
class InventoryParser(object):
"""
@@ -231,13 +231,11 @@ class InventoryParser(object):
# beta:2345 user=admin # we'll tell shlex
# gamma sudo=True user=root # to ignore comments
line = to_bytes(line)
try:
tokens = shlex.split(line, comments=True)
tokens = shlex_split(line, comments=True)
except ValueError as e:
self._raise_error("Error parsing host definition '%s': %s" % (varstring, e))
tokens = [ to_unicode(t) for t in tokens]
(hostnames, port) = self._expand_hostpattern(tokens[0])
hosts = self._Hosts(hostnames, port)