From 628cfbffe2677c9e7e1437a89bacc05f1c7bd5f0 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 6 Apr 2010 11:18:41 -0700 Subject: [PATCH] Item.move() now takes a library as an argument --HG-- branch : device --- beets/library.py | 6 +++--- bts | 2 +- test/test_files.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/beets/library.py b/beets/library.py index 15d8882af..1575f6172 100644 --- a/beets/library.py +++ b/beets/library.py @@ -264,7 +264,7 @@ class Item(object): #### dealing with files themselves #### - def move(self, copy=False): + def move(self, library, copy=False): """Move the item to its designated location within the library directory (provided by destination()). Subdirectories are created as needed. If the operation succeeds, the item's path field is updated to @@ -278,7 +278,7 @@ class Item(object): Note that one should almost certainly call store() and library.save() after this method in order to keep on-disk data consistent. """ - dest = self.library.destination(self) + dest = library.destination(self) # Create necessary ancestry for the move. Like os.renames but only # halfway. @@ -685,7 +685,7 @@ class Library(BaseLibrary): #FIXME make a deep copy of the item? item.library = self if copy: - item.move(copy=True) + item.move(self, copy=True) # build essential parts of query columns = ','.join([key for key in item_keys if key != 'id']) diff --git a/bts b/bts index 2915c09c4..d0fe3ed08 100755 --- a/bts +++ b/bts @@ -95,7 +95,7 @@ def tag_album(items, lib): # Change metadata and add to library. autotag.apply_metadata(items, info) for item in items: - item.move(True) + item.move(lib, True) item.add() item.write() diff --git a/test/test_files.py b/test/test_files.py index e40ad5166..9ed59eb97 100755 --- a/test/test_files.py +++ b/test/test_files.py @@ -52,23 +52,23 @@ class MoveTest(unittest.TestCase): shutil.rmtree(self.libdir) def test_move_arrives(self): - self.i.move() + self.i.move(self.lib) self.assertTrue(os.path.exists(self.dest)) def test_move_departs(self): - self.i.move() + self.i.move(self.lib) self.assertTrue(not os.path.exists(self.path)) def test_copy_arrives(self): - self.i.move(copy=True) + self.i.move(self.lib, copy=True) self.assertTrue(os.path.exists(self.dest)) def test_copy_does_not_depart(self): - self.i.move(copy=True) + self.i.move(self.lib, copy=True) self.assertTrue(os.path.exists(self.path)) def test_move_changes_path(self): - self.i.move() + self.i.move(self.lib) self.assertEqual(self.i.path, beets.library._normpath(self.dest)) class WalkTest(unittest.TestCase):