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

Idiomatic Python: use isinstance instead of type

This commit is contained in:
Nicolas Grilly 2013-05-23 18:33:29 +02:00
parent 8f3b2b281f
commit 7babd30cf7

View file

@ -62,12 +62,12 @@ class Inventory(object):
self._also_restriction = None
self._subset = None
if type(host_list) in [ str, unicode ]:
if isinstance(host_list, basestring):
if host_list.find(",") != -1:
host_list = host_list.split(",")
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
all = Group('all')
self.groups = [ all ]
@ -316,7 +316,7 @@ class Inventory(object):
to exclude failed hosts in main playbook code, don't use this for other
reasons.
"""
if type(restriction) != list:
if not isinstance(restriction, list):
restriction = [ restriction ]
self._restriction = restriction
@ -325,7 +325,7 @@ class Inventory(object):
Works like restict_to but offers an additional restriction. Playbooks use this
to implement serial behavior.
"""
if type(restriction) != list:
if not isinstance(restriction, list):
restriction = [ restriction ]
self._also_restriction = restriction