[SCM] morituri/master: * morituri/image/cue.py: getRealPath should be here, it doesn't need anything outside the .cue file * morituri/image/image.py: Proxy it here.

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:08:49 UTC 2014


The following commit has been merged in the master branch:
commit 03ef79ec847ea70fe86ad3107e09fb204b28cbaa
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Sat Apr 25 16:06:23 2009 +0000

    	* morituri/image/cue.py:
    	  getRealPath should be here, it doesn't need anything outside
    	  the .cue file
    	* morituri/image/image.py:
    	  Proxy it here.

diff --git a/ChangeLog b/ChangeLog
index 5dc800a..1cd3d32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 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:
 	  Add some debugging.
 	* morituri/test/test_image_image.py:
diff --git a/morituri/image/cue.py b/morituri/image/cue.py
index 3a99499..b562975 100644
--- a/morituri/image/cue.py
+++ b/morituri/image/cue.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.
diff --git a/morituri/image/image.py b/morituri/image/image.py
index 812bae8..73062a5 100644
--- a/morituri/image/image.py
+++ b/morituri/image/image.py
@@ -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):
         """

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list