Don't bother returning whether or not we copied it or not, we can
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 12 Jun 2011 02:20:26 +0000 (21:20 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 12 Jun 2011 02:20:26 +0000 (21:20 -0500)
figure that out by looking to see whether our storage is local or not.

mediagoblin/tests/test_workbench.py
mediagoblin/workbench.py

index f08a26a058e83836eca0c7bc859efa5ce6b219fe..994688c464752fc564c896f1b72723e8d2cd36a6 100644 (file)
@@ -65,9 +65,8 @@ class TestWorkbench(object):
             our_file.write('Our file')
 
         # with a local file storage
-        filename, copied = self.workbench_manager.possibly_localize_file(
+        filename = self.workbench_manager.possibly_localize_file(
             this_workbench, this_storage, filepath)
-        assert copied is False
         assert filename == os.path.join(
             tmpdir, 'dir1/dir2/ourfile.txt')
 
@@ -78,20 +77,20 @@ class TestWorkbench(object):
         with this_storage.get_file(filepath, 'w') as our_file:
             our_file.write('Our file')
 
-        filename, copied = self.workbench_manager.possibly_localize_file(
+        filename = self.workbench_manager.possibly_localize_file(
             this_workbench, this_storage, filepath)
         assert filename == os.path.join(
             this_workbench, 'ourfile.txt')
         
         # fake remote file storage, filename_if_copying set
-        filename, copied = self.workbench_manager.possibly_localize_file(
+        filename = self.workbench_manager.possibly_localize_file(
             this_workbench, this_storage, filepath, 'thisfile')
         assert filename == os.path.join(
             this_workbench, 'thisfile.txt')
 
         # fake remote file storage, filename_if_copying set,
         # keep_extension_if_copying set to false
-        filename, copied = self.workbench_manager.possibly_localize_file(
+        filename = self.workbench_manager.possibly_localize_file(
             this_workbench, this_storage, filepath, 'thisfile.text', False)
         assert filename == os.path.join(
             this_workbench, 'thisfile.text')
index b1198adf35643aaf05371a4bb5ce1384ac510905..360e3e193ce43cdf1ae192be4bb7ee48998d5951 100644 (file)
@@ -89,37 +89,32 @@ class WorkbenchManager(object):
         filename_if_copying yourself, it'll be set for you (assuming such an
         extension can be extacted from the filename in the filepath).
 
-        Also returns whether or not it copied the file locally.
-
         Returns:
-          (localized_filename, copied_locally)
-          The first of these bieng the absolute filename as described above as a
-          unicode string, the second being a boolean stating whether or not we
-          had to copy the file locally.
+          localized_filename
 
         Examples:
           >>> wb_manager.possibly_localize_file(
           ...     '/our/workbench/subdir', local_storage,
           ...     ['path', 'to', 'foobar.jpg'])
-          (u'/local/storage/path/to/foobar.jpg', False)
+          u'/local/storage/path/to/foobar.jpg'
 
           >>> wb_manager.possibly_localize_file(
           ...     '/our/workbench/subdir', remote_storage,
           ...     ['path', 'to', 'foobar.jpg'])
-          (u'/our/workbench/subdir/foobar.jpg', True)
+          '/our/workbench/subdir/foobar.jpg'
 
           >>> wb_manager.possibly_localize_file(
           ...     '/our/workbench/subdir', remote_storage,
           ...     ['path', 'to', 'foobar.jpg'], 'source.jpeg', False)
-          (u'/our/workbench/subdir/foobar.jpeg', True)
+          '/our/workbench/subdir/foobar.jpeg'
 
           >>> wb_manager.possibly_localize_file(
           ...     '/our/workbench/subdir', remote_storage,
           ...     ['path', 'to', 'foobar.jpg'], 'source', True)
-          (u'/our/workbench/subdir/foobar.jpg', True)
+          '/our/workbench/subdir/foobar.jpg'
         """
         if storage.local_storage:
-            return (storage.get_local_path(filepath), False)
+            return storage.get_local_path(filepath)
         else:
             if filename_if_copying is None:
                 dest_filename = filepath[-1]
@@ -137,4 +132,4 @@ class WorkbenchManager(object):
             storage.copy_locally(
                 filepath, full_dest_filename)
 
-            return (full_dest_filename, True)
+            return full_dest_filename