mirror of
https://github.com/beetbox/beets.git
synced 2026-01-06 16:02:53 +01:00
reintroduce default arguments, adapt all occurences of TrackInfo and AlbumInfo to the absence of positional arguments
This commit is contained in:
parent
62566ee61d
commit
f507f04639
5 changed files with 116 additions and 31 deletions
|
|
@ -100,7 +100,51 @@ class AlbumInfo(Map):
|
|||
``mediums`` along with the fields up through ``tracks`` are required.
|
||||
The others are optional and may be None.
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
def __init__(self, album=None, album_id=None, artist=None, artist_id=None,
|
||||
tracks, asin=None, albumtype=None, va=False, year=None,
|
||||
month=None, day=None, label=None, mediums=None,
|
||||
artist_sort=None, releasegroup_id=None, catalognum=None,
|
||||
script=None, language=None, country=None, style=None,
|
||||
genre=None, albumstatus=None, media=None, albumdisambig=None,
|
||||
releasegroupdisambig=None, artist_credit=None,
|
||||
original_year=None, original_month=None,
|
||||
original_day=None, data_source=None, data_url=None,
|
||||
discogs_albumid=None, discogs_labelid=None,
|
||||
discogs_artistid=None, **kwargs):
|
||||
self.album = album
|
||||
self.album_id = album_id
|
||||
self.artist = artist
|
||||
self.artist_id = artist_id
|
||||
self.tracks = tracks
|
||||
self.asin = asin
|
||||
self.albumtype = albumtype
|
||||
self.va = va
|
||||
self.year = year
|
||||
self.month = month
|
||||
self.day = day
|
||||
self.label = label
|
||||
self.mediums = mediums
|
||||
self.artist_sort = artist_sort
|
||||
self.releasegroup_id = releasegroup_id
|
||||
self.catalognum = catalognum
|
||||
self.script = script
|
||||
self.language = language
|
||||
self.country = country
|
||||
self.style = style
|
||||
self.genre = genre
|
||||
self.albumstatus = albumstatus
|
||||
self.media = media
|
||||
self.albumdisambig = albumdisambig
|
||||
self.releasegroupdisambig = releasegroupdisambig
|
||||
self.artist_credit = artist_credit
|
||||
self.original_year = original_year
|
||||
self.original_month = original_month
|
||||
self.original_day = original_day
|
||||
self.data_source = data_source
|
||||
self.data_url = data_url
|
||||
self.discogs_albumid = discogs_albumid
|
||||
self.discogs_labelid = discogs_labelid
|
||||
self.discogs_artistid = discogs_artistid
|
||||
for arg in kwargs:
|
||||
self.__setattr__(arg, kwargs[arg])
|
||||
|
||||
|
|
@ -129,7 +173,43 @@ class TrackInfo(Map):
|
|||
may be None. The indices ``index``, ``medium``, and ``medium_index``
|
||||
are all 1-based.
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
def __init__(self, title=None, track_id=None, release_track_id=None,
|
||||
artist=None, artist_id=None, length=None, index=None,
|
||||
medium=None, medium_index=None, medium_total=None,
|
||||
artist_sort=None, disctitle=None, artist_credit=None,
|
||||
data_source=None, data_url=None, media=None, lyricist=None,
|
||||
composer=None, composer_sort=None, arranger=None,
|
||||
performer=None, track_alt=None, work=None, mb_workid=None,
|
||||
work_disambig=None, bpm=None, initial_key=None, genre=None,
|
||||
**kwargs):
|
||||
self.title = title
|
||||
self.track_id = track_id
|
||||
self.release_track_id = release_track_id
|
||||
self.artist = artist
|
||||
self.artist_id = artist_id
|
||||
self.length = length
|
||||
self.index = index
|
||||
self.media = media
|
||||
self.medium = medium
|
||||
self.medium_index = medium_index
|
||||
self.medium_total = medium_total
|
||||
self.artist_sort = artist_sort
|
||||
self.disctitle = disctitle
|
||||
self.artist_credit = artist_credit
|
||||
self.data_source = data_source
|
||||
self.data_url = data_url
|
||||
self.lyricist = lyricist
|
||||
self.composer = composer
|
||||
self.composer_sort = composer_sort
|
||||
self.arranger = arranger
|
||||
self.performer = performer
|
||||
self.track_alt = track_alt
|
||||
self.work = work
|
||||
self.mb_workid = mb_workid
|
||||
self.work_disambig = work_disambig
|
||||
self.bpm = bpm
|
||||
self.initial_key = initial_key
|
||||
self.genre = genre
|
||||
for arg in kwargs:
|
||||
self.__setattr__(arg, kwargs[arg])
|
||||
|
||||
|
|
|
|||
|
|
@ -53,5 +53,6 @@ class CuePlugin(BeetsPlugin):
|
|||
title = "dunno lol"
|
||||
track_id = "wtf"
|
||||
index = int(path.basename(t)[len("split-track"):-len(".wav")])
|
||||
yield TrackInfo(title, track_id, index=index, artist=artist)
|
||||
yield TrackInfo(title=title, track_id=track_id, index=index,
|
||||
artist=artist)
|
||||
# generate TrackInfo instances
|
||||
|
|
|
|||
|
|
@ -356,7 +356,8 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
# a master release, otherwise fetch the master release.
|
||||
original_year = self.get_master_year(master_id) if master_id else year
|
||||
|
||||
return AlbumInfo(album, album_id, artist, artist_id, tracks, asin=None,
|
||||
return AlbumInfo(album=album, album_id=album_id, artist=artist,
|
||||
artist_id=artist_id, tracks=tracks, asin=None,
|
||||
albumtype=albumtype, va=va, year=year, month=None,
|
||||
day=None, label=label, mediums=len(set(mediums)),
|
||||
artist_sort=None, releasegroup_id=master_id,
|
||||
|
|
@ -567,8 +568,8 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
track.get('artists', [])
|
||||
)
|
||||
length = self.get_track_length(track['duration'])
|
||||
return TrackInfo(title, track_id, artist=artist, artist_id=artist_id,
|
||||
length=length, index=index,
|
||||
return TrackInfo(title=title, track_id=track_id, artist=artist,
|
||||
artist_id=artist_id, length=length, index=index,
|
||||
medium=medium, medium_index=medium_index,
|
||||
artist_sort=None, disctitle=None, artist_credit=None)
|
||||
|
||||
|
|
|
|||
|
|
@ -106,9 +106,9 @@ def _make_item(title, track, artist=u'some artist'):
|
|||
|
||||
def _make_trackinfo():
|
||||
return [
|
||||
TrackInfo(u'one', None, artist=u'some artist', length=1, index=1),
|
||||
TrackInfo(u'two', None, artist=u'some artist', length=1, index=2),
|
||||
TrackInfo(u'three', None, artist=u'some artist', length=1, index=3),
|
||||
TrackInfo(title=u'one', track_id=one, artist=u'some artist', length=1, index=1),
|
||||
TrackInfo(title=u'two', track_id=None, artist=u'some artist', length=1, index=2),
|
||||
TrackInfo(title=u'three', track_id=None, artist=u'some artist', length=1, index=3),
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -503,9 +503,9 @@ class AssignmentTest(unittest.TestCase):
|
|||
items.append(self.item(u'three', 2))
|
||||
items.append(self.item(u'two', 3))
|
||||
trackinfo = []
|
||||
trackinfo.append(TrackInfo(u'one', None))
|
||||
trackinfo.append(TrackInfo(u'two', None))
|
||||
trackinfo.append(TrackInfo(u'three', None))
|
||||
trackinfo.append(TrackInfo(title=u'one', track_id=None))
|
||||
trackinfo.append(TrackInfo(title=u'two', track_id=None))
|
||||
trackinfo.append(TrackInfo(title=u'three', track_id=None))
|
||||
mapping, extra_items, extra_tracks = \
|
||||
match.assign_items(items, trackinfo)
|
||||
self.assertEqual(extra_items, [])
|
||||
|
|
@ -522,9 +522,9 @@ class AssignmentTest(unittest.TestCase):
|
|||
items.append(self.item(u'three', 1))
|
||||
items.append(self.item(u'two', 1))
|
||||
trackinfo = []
|
||||
trackinfo.append(TrackInfo(u'one', None))
|
||||
trackinfo.append(TrackInfo(u'two', None))
|
||||
trackinfo.append(TrackInfo(u'three', None))
|
||||
trackinfo.append(TrackInfo(title=u'one', track_id=None))
|
||||
trackinfo.append(TrackInfo(title=u'two', track_id=None))
|
||||
trackinfo.append(TrackInfo(title=u'three', track_id=None))
|
||||
mapping, extra_items, extra_tracks = \
|
||||
match.assign_items(items, trackinfo)
|
||||
self.assertEqual(extra_items, [])
|
||||
|
|
@ -540,9 +540,9 @@ class AssignmentTest(unittest.TestCase):
|
|||
items.append(self.item(u'one', 1))
|
||||
items.append(self.item(u'three', 3))
|
||||
trackinfo = []
|
||||
trackinfo.append(TrackInfo(u'one', None))
|
||||
trackinfo.append(TrackInfo(u'two', None))
|
||||
trackinfo.append(TrackInfo(u'three', None))
|
||||
trackinfo.append(TrackInfo(title=u'one', track_id=None))
|
||||
trackinfo.append(TrackInfo(title=u'two', track_id=None))
|
||||
trackinfo.append(TrackInfo(title=u'three', track_id=None))
|
||||
mapping, extra_items, extra_tracks = \
|
||||
match.assign_items(items, trackinfo)
|
||||
self.assertEqual(extra_items, [])
|
||||
|
|
@ -558,8 +558,8 @@ class AssignmentTest(unittest.TestCase):
|
|||
items.append(self.item(u'two', 2))
|
||||
items.append(self.item(u'three', 3))
|
||||
trackinfo = []
|
||||
trackinfo.append(TrackInfo(u'one', None))
|
||||
trackinfo.append(TrackInfo(u'three', None))
|
||||
trackinfo.append(TrackInfo(title=u'one', track_id=None))
|
||||
trackinfo.append(TrackInfo(title=u'three', track_id=None))
|
||||
mapping, extra_items, extra_tracks = \
|
||||
match.assign_items(items, trackinfo)
|
||||
self.assertEqual(extra_items, [items[1]])
|
||||
|
|
@ -595,7 +595,8 @@ class AssignmentTest(unittest.TestCase):
|
|||
items.append(item(12, 186.45916150485752))
|
||||
|
||||
def info(index, title, length):
|
||||
return TrackInfo(title, None, length=length, index=index)
|
||||
return TrackInfo(title=title, track_id=None, length=length,
|
||||
index=index)
|
||||
trackinfo = []
|
||||
trackinfo.append(info(1, u'Alone', 238.893))
|
||||
trackinfo.append(info(2, u'The Woman in You', 341.44))
|
||||
|
|
@ -638,8 +639,8 @@ class ApplyTest(_common.TestCase, ApplyTestUtil):
|
|||
self.items.append(Item({}))
|
||||
trackinfo = []
|
||||
trackinfo.append(TrackInfo(
|
||||
u'oneNew',
|
||||
u'dfa939ec-118c-4d0f-84a0-60f3d1e6522c',
|
||||
title=u'oneNew',
|
||||
track_id=u'dfa939ec-118c-4d0f-84a0-60f3d1e6522c',
|
||||
medium=1,
|
||||
medium_index=1,
|
||||
medium_total=1,
|
||||
|
|
@ -648,8 +649,8 @@ class ApplyTest(_common.TestCase, ApplyTestUtil):
|
|||
artist_sort='trackArtistSort',
|
||||
))
|
||||
trackinfo.append(TrackInfo(
|
||||
u'twoNew',
|
||||
u'40130ed1-a27c-42fd-a328-1ebefb6caef4',
|
||||
title=u'twoNew',
|
||||
track_id=u'40130ed1-a27c-42fd-a328-1ebefb6caef4',
|
||||
medium=2,
|
||||
medium_index=1,
|
||||
index=2,
|
||||
|
|
@ -828,15 +829,15 @@ class ApplyCompilationTest(_common.TestCase, ApplyTestUtil):
|
|||
self.items.append(Item({}))
|
||||
trackinfo = []
|
||||
trackinfo.append(TrackInfo(
|
||||
u'oneNew',
|
||||
u'dfa939ec-118c-4d0f-84a0-60f3d1e6522c',
|
||||
title=u'oneNew',
|
||||
track_id=u'dfa939ec-118c-4d0f-84a0-60f3d1e6522c',
|
||||
artist=u'artistOneNew',
|
||||
artist_id=u'a05686fc-9db2-4c23-b99e-77f5db3e5282',
|
||||
index=1,
|
||||
))
|
||||
trackinfo.append(TrackInfo(
|
||||
u'twoNew',
|
||||
u'40130ed1-a27c-42fd-a328-1ebefb6caef4',
|
||||
title=u'twoNew',
|
||||
track_id=u'40130ed1-a27c-42fd-a328-1ebefb6caef4',
|
||||
artist=u'artistTwoNew',
|
||||
artist_id=u'80b3cf5e-18fe-4c59-98c7-e5bb87210710',
|
||||
index=2,
|
||||
|
|
|
|||
|
|
@ -1051,8 +1051,10 @@ class ShowChangeTest(_common.TestCase):
|
|||
self.items[0].track = 1
|
||||
self.items[0].path = b'/path/to/file.mp3'
|
||||
self.info = autotag.AlbumInfo(
|
||||
u'the album', u'album id', u'the artist', u'artist id', [
|
||||
autotag.TrackInfo(u'the title', u'track id', index=1)
|
||||
album=u'the album', album_id=u'album id', artist=u'the artist',
|
||||
artist_id=u'artist id', tracks=[
|
||||
autotag.TrackInfo(title=u'the title', track_id=u'track id',
|
||||
index=1)
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue