mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
better names: add vs. add_path
--HG-- branch : device
This commit is contained in:
parent
d3d485195c
commit
4d1944f939
3 changed files with 9 additions and 9 deletions
|
|
@ -218,7 +218,7 @@ class Item(object):
|
|||
self.library = library
|
||||
if not self.library:
|
||||
raise LibraryError('no library to add to')
|
||||
self.library.add_item(self, copy)
|
||||
self.library.add(self, copy)
|
||||
return self.id
|
||||
|
||||
def remove(self):
|
||||
|
|
@ -532,7 +532,7 @@ class BaseLibrary(object):
|
|||
|
||||
### basic operations ###
|
||||
|
||||
def add_item(self, item, copy=False): #FIXME rename to "add", copy default to true
|
||||
def add(self, item, copy=False): #FIXME copy should default to true
|
||||
"""Add the item as a new object to the library database. The id field
|
||||
will be updated; the new id is returned. If copy, then each item is
|
||||
copied to the destination location before it is added.
|
||||
|
|
@ -616,14 +616,14 @@ class BaseLibrary(object):
|
|||
|
||||
### convenience methods ###
|
||||
|
||||
def add(self, path, copy=False): #FIXME change name to add_path()
|
||||
def add_path(self, path, copy=False):
|
||||
items = []
|
||||
for f in _walk_files(path):
|
||||
try:
|
||||
item = Item.from_path(_normpath(f), self)
|
||||
except FileTypeError:
|
||||
log.warn(f + ' of unknown type, skipping')
|
||||
self.add_item(item, copy)
|
||||
self.add(item, copy)
|
||||
|
||||
|
||||
class Library(BaseLibrary):
|
||||
|
|
@ -692,7 +692,7 @@ class Library(BaseLibrary):
|
|||
|
||||
#### main interface ####
|
||||
|
||||
def add_item(self, item, copy=False):
|
||||
def add(self, item, copy=False):
|
||||
#FIXME make a deep copy of the item?
|
||||
item.library = self
|
||||
if copy:
|
||||
|
|
|
|||
|
|
@ -106,8 +106,8 @@ class AddTest(unittest.TestCase):
|
|||
'where composer="the composer"').fetchone()['grouping']
|
||||
self.assertEqual(new_grouping, self.i.grouping)
|
||||
|
||||
def test_library_add_inserts_row(self):
|
||||
self.lib.add(os.path.join('rsrc', 'full.mp3'))
|
||||
def test_library_add_path_inserts_row(self):
|
||||
self.lib.add_path(os.path.join('rsrc', 'full.mp3'))
|
||||
new_grouping = self.lib.conn.execute('select grouping from items '
|
||||
'where composer="the composer"').fetchone()['grouping']
|
||||
self.assertEqual(new_grouping, self.i.grouping)
|
||||
|
|
|
|||
|
|
@ -146,8 +146,8 @@ class AddTest(unittest.TestCase):
|
|||
if os.path.exists(self.dir):
|
||||
shutil.rmtree(self.dir)
|
||||
|
||||
def test_library_add_copies(self):
|
||||
self.lib.add(os.path.join('rsrc', 'full.mp3'), copy=True)
|
||||
def test_library_add_path_copies(self):
|
||||
self.lib.add_path(os.path.join('rsrc', 'full.mp3'), copy=True)
|
||||
self.assertTrue(os.path.isfile(os.path.join(self.dir, 'item.mp3')))
|
||||
|
||||
class HelperTest(unittest.TestCase):
|
||||
|
|
|
|||
Loading…
Reference in a new issue