From: Christopher Allan Webber Date: Sun, 12 Jun 2011 02:20:26 +0000 (-0500) Subject: Don't bother returning whether or not we copied it or not, we can X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fdc5003903584ec8a1e83ccf80ebb6d3be3c671e;p=mediagoblin.git Don't bother returning whether or not we copied it or not, we can figure that out by looking to see whether our storage is local or not. --- diff --git a/mediagoblin/tests/test_workbench.py b/mediagoblin/tests/test_workbench.py index f08a26a0..994688c4 100644 --- a/mediagoblin/tests/test_workbench.py +++ b/mediagoblin/tests/test_workbench.py @@ -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') diff --git a/mediagoblin/workbench.py b/mediagoblin/workbench.py index b1198adf..360e3e19 100644 --- a/mediagoblin/workbench.py +++ b/mediagoblin/workbench.py @@ -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