Package lastfm :: Module objectcache
[hide private]
[frames] | no frames]

Source Code for Module lastfm.objectcache

 1  #!/usr/bin/env python 
 2   
 3  __author__ = "Abhinav Sarkar <abhinav@abhinavsarkar.net>" 
 4  __version__ = "0.2" 
 5  __license__ = "GNU Lesser General Public License" 
 6   
 7  from lastfm.album import Album 
 8  from lastfm.artist import Artist 
 9  from lastfm.mixins import Cacheable 
10  from lastfm.error import InvalidParametersError 
11  from lastfm.event import Event 
12  from lastfm.geo import Location, Country 
13  from lastfm.group import Group 
14  from lastfm.playlist import Playlist 
15  from lastfm.tag import Tag 
16  from lastfm.track import Track 
17  from lastfm.user import User 
18  from lastfm.venue import Venue 
19  from lastfm.weeklychart import WeeklyAlbumChart, WeeklyArtistChart, WeeklyTrackChart 
20   
21 -class ObjectCache(object):
22 """The registry to contain all the entities""" 23 keys = [c.__name__ for c in [Album, Artist, Event, Location, Country, Group, 24 Playlist, Tag, Track, User, Venue, WeeklyAlbumChart, WeeklyArtistChart, WeeklyTrackChart]] 25
26 - def __getitem__(self, name):
27 if name not in ObjectCache.keys: 28 raise InvalidParametersError("Key does not correspond to a valid class") 29 else: 30 try: 31 vals = Cacheable.registry[eval(name)].values() 32 vals.sort() 33 return vals 34 except KeyError: 35 return []
36
37 - def __repr__(self):
38 return "<lastfm.ObjectCache>"
39