* morituri/image/cue.py:
getRealPath should be here, it doesn't need anything outside the .cue file * morituri/image/image.py: Proxy it here.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2009-04-25 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/image/cue.py:
|
||||
getRealPath should be here, it doesn't need anything outside
|
||||
the .cue file
|
||||
* morituri/image/image.py:
|
||||
Proxy it here.
|
||||
|
||||
2009-04-25 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/common/checksum.py:
|
||||
|
||||
@@ -26,6 +26,7 @@ Reading .cue files
|
||||
See http://digitalx.org/cuesheetsyntax.php
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
_REM_RE = re.compile("^REM\s(\w+)\s(.*)$")
|
||||
@@ -147,6 +148,38 @@ class Cue:
|
||||
# FIXME: more logic
|
||||
return -1
|
||||
|
||||
def getRealPath(self, path):
|
||||
"""
|
||||
Translate the .cue's FILE to an existing path.
|
||||
"""
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
|
||||
# .cue FILE statements have Windows-style path separators, so convert
|
||||
tpath = os.path.join(*path.split('\\'))
|
||||
candidatePaths = []
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
class File:
|
||||
"""
|
||||
I represent a FILE line in a cue file.
|
||||
|
||||
@@ -47,32 +47,7 @@ class Image:
|
||||
"""
|
||||
Translate the .cue's FILE to an existing path.
|
||||
"""
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
|
||||
# .cue FILE statements have Windows-style path separators, so convert
|
||||
tpath = os.path.join(*path.split('\\'))
|
||||
candidatePaths = []
|
||||
|
||||
# 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
|
||||
return self.cue.getRealPath(path)
|
||||
|
||||
def setup(self, runner):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user