* morituri/image/image.py:
Also look for audio file basename relative to cue file.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2009-04-13 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/image/image.py:
|
||||
Also look for audio file basename relative to cue file.
|
||||
|
||||
2009-04-13 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* examples/ARcue.py:
|
||||
|
||||
@@ -52,15 +52,25 @@ class Image:
|
||||
|
||||
# .cue FILE statements have Windows-style path separators, so convert
|
||||
tpath = os.path.join(*path.split('\\'))
|
||||
# if the path is relative, make it absolute relative to the cue file
|
||||
if tpath != os.path.abspath(tpath):
|
||||
tpath = os.path.join(os.path.dirname(self._path), tpath)
|
||||
candidatePaths = []
|
||||
|
||||
noext, _ = os.path.splitext(tpath)
|
||||
for ext in ['wav', 'flac']:
|
||||
cpath = '%s.%s' % (noext, ext)
|
||||
if os.path.exists(cpath):
|
||||
return cpath
|
||||
# if the path is relative:
|
||||
# - check relatively to the cue file
|
||||
# - check only the filename part relative to the cue file
|
||||
if tpath == os.path.abspath(tpath):
|
||||
candidatePaths.append(tPath)
|
||||
else:
|
||||
candidatePaths.append(os.path.join(
|
||||
os.path.dirname(self._path), tpath))
|
||||
candidatePaths.append(os.path.join(
|
||||
os.path.dirname(self._path), os.path.basename(tpath)))
|
||||
|
||||
for candidate in candidatePaths:
|
||||
noext, _ = os.path.splitext(candidate)
|
||||
for ext in ['wav', 'flac']:
|
||||
cpath = '%s.%s' % (noext, ext)
|
||||
if os.path.exists(cpath):
|
||||
return cpath
|
||||
|
||||
raise KeyError, "Cannot find file for %s" % path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user