Commit 7babd30c by Nicolas Grilly

Idiomatic Python: use isinstance instead of type

parent 8f3b2b28
...@@ -62,12 +62,12 @@ class Inventory(object): ...@@ -62,12 +62,12 @@ class Inventory(object):
self._also_restriction = None self._also_restriction = None
self._subset = None self._subset = None
if type(host_list) in [ str, unicode ]: if isinstance(host_list, basestring):
if host_list.find(",") != -1: if host_list.find(",") != -1:
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() ]
if type(host_list) == list: if isinstance(host_list, list):
self.parser = None self.parser = None
all = Group('all') all = Group('all')
self.groups = [ all ] self.groups = [ all ]
...@@ -316,7 +316,7 @@ class Inventory(object): ...@@ -316,7 +316,7 @@ class Inventory(object):
to exclude failed hosts in main playbook code, don't use this for other to exclude failed hosts in main playbook code, don't use this for other
reasons. reasons.
""" """
if type(restriction) != list: if not isinstance(restriction, list):
restriction = [ restriction ] restriction = [ restriction ]
self._restriction = restriction self._restriction = restriction
...@@ -325,7 +325,7 @@ class Inventory(object): ...@@ -325,7 +325,7 @@ class Inventory(object):
Works like restict_to but offers an additional restriction. Playbooks use this Works like restict_to but offers an additional restriction. Playbooks use this
to implement serial behavior. to implement serial behavior.
""" """
if type(restriction) != list: if not isinstance(restriction, list):
restriction = [ restriction ] restriction = [ restriction ]
self._also_restriction = restriction self._also_restriction = restriction
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment