Allow leading ranges in the inventory host entries.

This commit is contained in:
Martynas Mickevicius
2013-10-03 11:41:34 +03:00
parent 6480945184
commit 44279ce34f
4 changed files with 11 additions and 3 deletions

View File

@@ -41,8 +41,7 @@ def detect_range(line = None):
Returnes True if the given line contains a pattern, else False.
'''
if (not line.startswith("[") and
line.find("[") != -1 and
if (line.find("[") != -1 and
line.find(":") != -1 and
line.find("]") != -1 and
line.index("[") < line.index(":") < line.index("]")):

View File

@@ -65,7 +65,7 @@ class InventoryParser(object):
active_group_name = 'ungrouped'
for line in self.lines:
if line.startswith("["):
if line.startswith("[") and line.strip().endswith("]"):
active_group_name = line.split(" #")[0].replace("[","").replace("]","").strip()
if line.find(":vars") != -1 or line.find(":children") != -1:
active_group_name = active_group_name.rsplit(":", 1)[0]