Make Python code more idiomatic
This commit is contained in:
@@ -197,7 +197,7 @@ def getRealPath(refPath, filePath):
|
||||
|
||||
@type filePath: unicode
|
||||
"""
|
||||
assert type(filePath) is unicode, "%r is not unicode" % filePath
|
||||
assert isinstance(filePath, unicode), "%r is not unicode" % filePath
|
||||
|
||||
if os.path.exists(filePath):
|
||||
return filePath
|
||||
|
||||
@@ -25,7 +25,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _listify(listOrString):
|
||||
if type(listOrString) == str:
|
||||
if isinstance(listOrString, str):
|
||||
return [listOrString, ]
|
||||
|
||||
return listOrString
|
||||
|
||||
@@ -115,7 +115,7 @@ class Program:
|
||||
tdict = {}
|
||||
|
||||
# Ignore old cache, since we do not know what offset it used.
|
||||
if type(ptable.object) is dict:
|
||||
if isinstance(ptable.object, dict):
|
||||
tdict = ptable.object
|
||||
|
||||
if offset in tdict:
|
||||
@@ -193,8 +193,8 @@ class Program:
|
||||
- %x: audio extension, lowercase
|
||||
- %X: audio extension, uppercase
|
||||
"""
|
||||
assert type(outdir) is unicode, "%r is not unicode" % outdir
|
||||
assert type(template) is unicode, "%r is not unicode" % template
|
||||
assert isinstance(outdir, unicode), "%r is not unicode" % outdir
|
||||
assert isinstance(template, unicode), "%r is not unicode" % template
|
||||
v = {}
|
||||
v['A'] = 'Unknown Artist'
|
||||
v['d'] = mbdiscid # fallback for title
|
||||
|
||||
Reference in New Issue
Block a user