Idiomatic Python: use in operator instead of method find
This commit is contained in:
parent
7babd30cf7
commit
7aee588918
1 changed files with 3 additions and 3 deletions
|
@ -63,7 +63,7 @@ class Inventory(object):
|
||||||
self._subset = None
|
self._subset = None
|
||||||
|
|
||||||
if isinstance(host_list, basestring):
|
if isinstance(host_list, basestring):
|
||||||
if host_list.find(",") != -1:
|
if "," in host_list:
|
||||||
host_list = host_list.split(",")
|
host_list = host_list.split(",")
|
||||||
host_list = [ h for h in host_list if h and h.strip() ]
|
host_list = [ h for h in host_list if h and h.strip() ]
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ class Inventory(object):
|
||||||
all = Group('all')
|
all = Group('all')
|
||||||
self.groups = [ all ]
|
self.groups = [ all ]
|
||||||
for x in host_list:
|
for x in host_list:
|
||||||
if x.find(":") != -1:
|
if ":" in x:
|
||||||
tokens = x.split(":",1)
|
tokens = x.split(":", 1)
|
||||||
all.add_host(Host(tokens[0], tokens[1]))
|
all.add_host(Host(tokens[0], tokens[1]))
|
||||||
else:
|
else:
|
||||||
all.add_host(Host(x))
|
all.add_host(Host(x))
|
||||||
|
|
Loading…
Reference in a new issue