python-lastfm/src/registry.py

37 lines
1.2 KiB
Python
Raw Normal View History

2008-07-16 18:36:42 +05:30
#!/usr/bin/env python
__author__ = "Abhinav Sarkar <abhinav@abhinavsarkar.net>"
2008-07-16 18:36:42 +05:30
__version__ = "0.1"
__license__ = "GNU Lesser General Public License"
from album import Album
from artist import Artist
from base import LastfmBase
from error import LastfmError
2008-07-16 18:36:42 +05:30
from event import Event
from geo import Location, Country
from group import Group
from playlist import Playlist
from tag import Tag
from track import Track
from user import User
from weeklychart import WeeklyAlbumChart, WeeklyArtistChart, WeeklyTrackChart
2008-07-16 18:36:42 +05:30
class Registry(object):
2008-07-16 18:36:42 +05:30
"""The registry to contain all the entities"""
keys = [Album, Artist, Event, Location, Country, Group,
Playlist, Tag, Track, User, WeeklyAlbumChart, WeeklyArtistChart, WeeklyTrackChart]
2008-07-16 18:36:42 +05:30
def get(self, name):
if name not in Registry.keys:
raise LastfmError("Key does not correspond to a valid class")
else:
try:
vals = LastfmBase.registry[name].values()
vals.sort()
return vals
except KeyError:
return []
def __repr__(self):
return "<lastfm.Registry>"