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

Merge pull request #3770 from rishid/devel

Add support for INI comments that begin with '#' or ';'
This commit is contained in:
Michael DeHaan 2013-08-06 13:29:39 -07:00
commit ff44c981e9

View file

@ -75,7 +75,7 @@ class InventoryParser(object):
elif active_group_name not in self.groups: elif active_group_name not in self.groups:
new_group = self.groups[active_group_name] = Group(name=active_group_name) new_group = self.groups[active_group_name] = Group(name=active_group_name)
all.add_child_group(new_group) all.add_child_group(new_group)
elif line.startswith("#") or line == '': elif line.startswith("#") or line.startswith(";") or line == '':
pass pass
elif active_group_name: elif active_group_name:
tokens = shlex.split(line.split(" #")[0]) tokens = shlex.split(line.split(" #")[0])
@ -132,7 +132,7 @@ class InventoryParser(object):
group = self.groups.get(line, None) group = self.groups.get(line, None)
if group is None: if group is None:
group = self.groups[line] = Group(name=line) group = self.groups[line] = Group(name=line)
elif line.startswith("#"): elif line.startswith("#") or line.startswith(";"):
pass pass
elif line.startswith("["): elif line.startswith("["):
group = None group = None
@ -157,7 +157,7 @@ class InventoryParser(object):
group = self.groups.get(line, None) group = self.groups.get(line, None)
if group is None: if group is None:
raise errors.AnsibleError("can't add vars to undefined group: %s" % line) raise errors.AnsibleError("can't add vars to undefined group: %s" % line)
elif line.startswith("#"): elif line.startswith("#") or line.startswith(";"):
pass pass
elif line.startswith("["): elif line.startswith("["):
group = None group = None