Migrate ITEM_KEYS_META

This commit is contained in:
Thomas Scholtes 2014-04-03 13:51:57 +02:00
parent 43ae730a6a
commit b262edd972
2 changed files with 62 additions and 67 deletions

View file

@ -122,71 +122,71 @@ class PathType(types.Type):
# - Is the field writable?
# - Does the field reflect an attribute of a MediaFile?
ITEM_FIELDS = [
('id', types.Id(), False),
('path', PathType(), False),
('album_id', types.Integer(), False),
('id', types.Id()),
('path', PathType()),
('album_id', types.Integer()),
('title', types.String(), True),
('artist', types.String(), True),
('artist_sort', types.String(), True),
('artist_credit', types.String(), True),
('album', types.String(), True),
('albumartist', types.String(), True),
('albumartist_sort', types.String(), True),
('albumartist_credit', types.String(), True),
('genre', types.String(), True),
('composer', types.String(), True),
('grouping', types.String(), True),
('year', types.PaddedInt(4), True),
('month', types.PaddedInt(2), True),
('day', types.PaddedInt(2), True),
('track', types.PaddedInt(2), True),
('tracktotal', types.PaddedInt(2), True),
('disc', types.PaddedInt(2), True),
('disctotal', types.PaddedInt(2), True),
('lyrics', types.String(), True),
('comments', types.String(), True),
('bpm', types.Integer(), True),
('comp', types.Boolean(), True),
('mb_trackid', types.String(), True),
('mb_albumid', types.String(), True),
('mb_artistid', types.String(), True),
('mb_albumartistid', types.String(), True),
('albumtype', types.String(), True),
('label', types.String(), True),
('acoustid_fingerprint', types.String(), True),
('acoustid_id', types.String(), True),
('mb_releasegroupid', types.String(), True),
('asin', types.String(), True),
('catalognum', types.String(), True),
('script', types.String(), True),
('language', types.String(), True),
('country', types.String(), True),
('albumstatus', types.String(), True),
('media', types.String(), True),
('albumdisambig', types.String(), True),
('disctitle', types.String(), True),
('encoder', types.String(), True),
('rg_track_gain', types.Float(), True),
('rg_track_peak', types.Float(), True),
('rg_album_gain', types.Float(), True),
('rg_album_peak', types.Float(), True),
('original_year', types.PaddedInt(4), True),
('original_month', types.PaddedInt(2), True),
('original_day', types.PaddedInt(2), True),
('title', types.String()),
('artist', types.String()),
('artist_sort', types.String()),
('artist_credit', types.String()),
('album', types.String()),
('albumartist', types.String()),
('albumartist_sort', types.String()),
('albumartist_credit', types.String()),
('genre', types.String()),
('composer', types.String()),
('grouping', types.String()),
('year', types.PaddedInt(4)),
('month', types.PaddedInt(2)),
('day', types.PaddedInt(2)),
('track', types.PaddedInt(2)),
('tracktotal', types.PaddedInt(2)),
('disc', types.PaddedInt(2)),
('disctotal', types.PaddedInt(2)),
('lyrics', types.String()),
('comments', types.String()),
('bpm', types.Integer()),
('comp', types.Boolean()),
('mb_trackid', types.String()),
('mb_albumid', types.String()),
('mb_artistid', types.String()),
('mb_albumartistid', types.String()),
('albumtype', types.String()),
('label', types.String()),
('acoustid_fingerprint', types.String()),
('acoustid_id', types.String()),
('mb_releasegroupid', types.String()),
('asin', types.String()),
('catalognum', types.String()),
('script', types.String()),
('language', types.String()),
('country', types.String()),
('albumstatus', types.String()),
('media', types.String()),
('albumdisambig', types.String()),
('disctitle', types.String()),
('encoder', types.String()),
('rg_track_gain', types.Float()),
('rg_track_peak', types.Float()),
('rg_album_gain', types.Float()),
('rg_album_peak', types.Float()),
('original_year', types.PaddedInt(4)),
('original_month', types.PaddedInt(2)),
('original_day', types.PaddedInt(2)),
('length', types.Float(), True),
('bitrate', types.ScaledInt(1000, u'kbps'), True),
('format', types.String(), True),
('samplerate', types.ScaledInt(1000, u'kHz'), True),
('bitdepth', types.Integer(), True),
('channels', types.Integer(), True),
('mtime', DateType(), False),
('added', DateType(), False),
('length', types.Float()),
('bitrate', types.ScaledInt(1000, u'kbps')),
('format', types.String()),
('samplerate', types.ScaledInt(1000, u'kHz')),
('bitdepth', types.Integer()),
('channels', types.Integer()),
('mtime', DateType()),
('added', DateType()),
]
ITEM_KEYS_META = [f[0] for f in ITEM_FIELDS if f[2]]
ITEM_KEYS = [f[0] for f in ITEM_FIELDS]
ITEM_KEYS_WRITABLE = set(MediaFile.fields()).intersection(ITEM_KEYS)
ITEM_KEYS_META = set(MediaFile.readable_fields()).intersection(ITEM_KEYS)
# Database fields for the "albums" table.
# The third entry in each tuple indicates whether the field reflects an
@ -328,7 +328,7 @@ class LibModel(dbcore.Model):
class Item(LibModel):
_fields = dict((name, typ) for (name, typ, _) in ITEM_FIELDS)
_fields = dict((name, typ) for (name, typ) in ITEM_FIELDS)
_table = 'items'
_flex_table = 'item_attributes'
_search_fields = ITEM_DEFAULT_FIELDS

View file

@ -26,7 +26,7 @@ from _common import unittest
from beets.mediafile import MediaFile, MediaField, Image, \
MP3StorageStyle, StorageStyle, \
MP4StorageStyle, ASFStorageStyle
from beets.library import ITEM_KEYS_META, ITEM_KEYS, Item
from beets.library import Item
class ArtTestMixin(object):
@ -800,11 +800,6 @@ class MediaFieldTest(unittest.TestCase):
for field in MediaFile.fields():
self.assertIn(field, readable)
def test_readable_fields_are_item_meta_keys(self):
readable = MediaFile.readable_fields()
meta_keys = set(readable).intersection(ITEM_KEYS)
self.assertItemsEqual(meta_keys, ITEM_KEYS_META)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)