Make Python code more idiomatic

This commit is contained in:
JoeLametta
2018-05-02 08:45:00 +00:00
parent a484815106
commit 2b4140d300
12 changed files with 24 additions and 27 deletions

View File

@@ -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

View File

@@ -25,7 +25,7 @@ logger = logging.getLogger(__name__)
def _listify(listOrString):
if type(listOrString) == str:
if isinstance(listOrString, str):
return [listOrString, ]
return listOrString

View File

@@ -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