mirror of
https://github.com/munki/munki.git
synced 2026-05-02 02:09:19 -05:00
Replace 'type(foo) == bar' with 'isinstance(foo, bar)' to fit Python 3 idiom
This commit is contained in:
@@ -58,9 +58,9 @@ class ShareAuthenticationNeededException(ShareMountException):
|
||||
|
||||
def unicodeize(path):
|
||||
'''Convert a path to unicode'''
|
||||
if type(path) is str:
|
||||
if isinstance(path, str):
|
||||
return unicode(path, 'utf-8')
|
||||
elif type(path) is not unicode:
|
||||
elif not isinstance(path, unicode):
|
||||
return unicode(path)
|
||||
return path
|
||||
|
||||
|
||||
@@ -52,16 +52,16 @@ def format_time(timestamp=None):
|
||||
def printreportitem(label, value, indent=0):
|
||||
"""Prints a report item in an 'attractive' way"""
|
||||
indentspace = ' '
|
||||
if type(value) == type(None):
|
||||
if isinstance(value, type(None)):
|
||||
print(indentspace*indent, '%s: !NONE!' % label)
|
||||
elif type(value) == list or type(value).__name__ == 'NSCFArray':
|
||||
elif isinstance(value, list) or type(value).__name__ == 'NSCFArray':
|
||||
if label:
|
||||
print(indentspace*indent, '%s:' % label)
|
||||
index = 0
|
||||
for item in value:
|
||||
index += 1
|
||||
printreportitem(index, item, indent+1)
|
||||
elif type(value) == dict or type(value).__name__ == 'NSCFDictionary':
|
||||
elif isinstance(value, dict) or type(value).__name__ == 'NSCFDictionary':
|
||||
if label:
|
||||
print(indentspace*indent, '%s:' % label)
|
||||
for subkey in value.keys():
|
||||
|
||||
Reference in New Issue
Block a user