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
|
self.library = library
|
||||||
if not self.library:
|
if not self.library:
|
||||||
raise LibraryError('no library to add to')
|
raise LibraryError('no library to add to')
|
||||||
self.library.add_item(self, copy)
|
self.library.add(self, copy)
|
||||||
return self.id
|
return self.id
|
||||||
|
|
||||||
def remove(self):
|
def remove(self):
|
||||||
|
|
@ -532,7 +532,7 @@ class BaseLibrary(object):
|
||||||
|
|
||||||
### basic operations ###
|
### 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
|
"""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
|
will be updated; the new id is returned. If copy, then each item is
|
||||||
copied to the destination location before it is added.
|
copied to the destination location before it is added.
|
||||||
|
|
@ -616,14 +616,14 @@ class BaseLibrary(object):
|
||||||
|
|
||||||
### convenience methods ###
|
### convenience methods ###
|
||||||
|
|
||||||
def add(self, path, copy=False): #FIXME change name to add_path()
|
def add_path(self, path, copy=False):
|
||||||
items = []
|
items = []
|
||||||
for f in _walk_files(path):
|
for f in _walk_files(path):
|
||||||
try:
|
try:
|
||||||
item = Item.from_path(_normpath(f), self)
|
item = Item.from_path(_normpath(f), self)
|
||||||
except FileTypeError:
|
except FileTypeError:
|
||||||
log.warn(f + ' of unknown type, skipping')
|
log.warn(f + ' of unknown type, skipping')
|
||||||
self.add_item(item, copy)
|
self.add(item, copy)
|
||||||
|
|
||||||
|
|
||||||
class Library(BaseLibrary):
|
class Library(BaseLibrary):
|
||||||
|
|
@ -692,7 +692,7 @@ class Library(BaseLibrary):
|
||||||
|
|
||||||
#### main interface ####
|
#### main interface ####
|
||||||
|
|
||||||
def add_item(self, item, copy=False):
|
def add(self, item, copy=False):
|
||||||
#FIXME make a deep copy of the item?
|
#FIXME make a deep copy of the item?
|
||||||
item.library = self
|
item.library = self
|
||||||
if copy:
|
if copy:
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,8 @@ class AddTest(unittest.TestCase):
|
||||||
'where composer="the composer"').fetchone()['grouping']
|
'where composer="the composer"').fetchone()['grouping']
|
||||||
self.assertEqual(new_grouping, self.i.grouping)
|
self.assertEqual(new_grouping, self.i.grouping)
|
||||||
|
|
||||||
def test_library_add_inserts_row(self):
|
def test_library_add_path_inserts_row(self):
|
||||||
self.lib.add(os.path.join('rsrc', 'full.mp3'))
|
self.lib.add_path(os.path.join('rsrc', 'full.mp3'))
|
||||||
new_grouping = self.lib.conn.execute('select grouping from items '
|
new_grouping = self.lib.conn.execute('select grouping from items '
|
||||||
'where composer="the composer"').fetchone()['grouping']
|
'where composer="the composer"').fetchone()['grouping']
|
||||||
self.assertEqual(new_grouping, self.i.grouping)
|
self.assertEqual(new_grouping, self.i.grouping)
|
||||||
|
|
|
||||||
|
|
@ -146,8 +146,8 @@ class AddTest(unittest.TestCase):
|
||||||
if os.path.exists(self.dir):
|
if os.path.exists(self.dir):
|
||||||
shutil.rmtree(self.dir)
|
shutil.rmtree(self.dir)
|
||||||
|
|
||||||
def test_library_add_copies(self):
|
def test_library_add_path_copies(self):
|
||||||
self.lib.add(os.path.join('rsrc', 'full.mp3'), copy=True)
|
self.lib.add_path(os.path.join('rsrc', 'full.mp3'), copy=True)
|
||||||
self.assertTrue(os.path.isfile(os.path.join(self.dir, 'item.mp3')))
|
self.assertTrue(os.path.isfile(os.path.join(self.dir, 'item.mp3')))
|
||||||
|
|
||||||
class HelperTest(unittest.TestCase):
|
class HelperTest(unittest.TestCase):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue