[SCM] morituri/master: * morituri/image/toc.py: * morituri/test/test_image_toc.py: Add test for getRealPath. Fix bug found by it for absolute paths.

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:09:44 UTC 2014


The following commit has been merged in the master branch:
commit 56f1de4c5ca3b6cf1f1e14b23300653e232337c7
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Mon Nov 19 08:50:09 2012 +0000

    	* morituri/image/toc.py:
    	* morituri/test/test_image_toc.py:
    	  Add test for getRealPath.  Fix bug found by it for absolute paths.

diff --git a/ChangeLog b/ChangeLog
index 734c92e..cb8237f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-11-19  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* morituri/image/toc.py:
+	* morituri/test/test_image_toc.py:
+	  Add test for getRealPath.  Fix bug found by it for absolute paths.
+
 2012-11-18  Thomas Vander Stichele  <thomas at apestaart dot org>
 
 	* morituri/image/table.py:
diff --git a/morituri/image/toc.py b/morituri/image/toc.py
index 3b16476..70d5d0c 100644
--- a/morituri/image/toc.py
+++ b/morituri/image/toc.py
@@ -324,7 +324,7 @@ class TocFile(object, log.Loggable):
 
     def getRealPath(self, path):
         """
-        Translate the .cue's FILE to an existing path.
+        Translate the .toc's FILE to an existing path.
 
         @type  path: unicode
         """
@@ -334,15 +334,18 @@ class TocFile(object, log.Loggable):
             return path
 
         # .cue FILE statements have Windows-style path separators, so convert
-        tpath = os.path.join(*path.split('\\'))
+        parts = path.split('\\')
+        if parts[0] == '':
+            parts[0] = os.path.sep
+        tpath = os.path.join(*parts)
         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:
+            # if the path is relative:
+            # - check relatively to the cue file
+            # - check only the filename part relative to the cue file
             candidatePaths.append(os.path.join(
                 os.path.dirname(self._path), tpath))
             candidatePaths.append(os.path.join(
diff --git a/morituri/test/test_image_toc.py b/morituri/test/test_image_toc.py
index 67362ba..fb44a48 100644
--- a/morituri/test/test_image_toc.py
+++ b/morituri/test/test_image_toc.py
@@ -92,6 +92,17 @@ class CureTestCase(common.TestCase):
             'http://www.accuraterip.com/accuraterip/'
             '3/c/4/dBAR-013-0019d4c3-00fe8924-b90c650d.bin')
 
+
+    def testGetRealPath(self):
+        self.assertRaises(KeyError, self.toc.getRealPath, u'track01.wav')
+        (fd, path) = tempfile.mkstemp(suffix=u'.morituri.test.wav')
+        self.assertEquals(self.toc.getRealPath(path), path)
+
+        winpath = path.replace('/', '\\')
+        self.assertEquals(self.toc.getRealPath(winpath), path)
+        os.close(fd)
+        os.unlink(path)
+
 # Bloc Party - Silent Alarm has a Hidden Track One Audio
 
 

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list