Replace 'type(foo) == bar' with 'isinstance(foo, bar)' to fit Python 3 idiom

This commit is contained in:
Greg Neagle
2019-05-03 21:57:05 -07:00
parent 453524a5b0
commit 6bc83d08e6
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -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
+3 -3
View File
@@ -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():