[rhythmbox] context: minor code style fixes
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rhythmbox] context: minor code style fixes
- Date: Sun, 1 Nov 2009 06:00:48 +0000 (UTC)
commit ea788475439fea0be7ee6d3f2f2d3a284b221357
Author: Jonathan Matthew <jonathan fibula d14n org>
Date: Sat Oct 31 20:25:34 2009 +1000
context: minor code style fixes
plugins/context/context/AlbumTab.py | 96 ++++++++++++++++----------------
plugins/context/context/ArtistTab.py | 92 +++++++++++++++---------------
plugins/context/context/ContextView.py | 51 +++++++++--------
plugins/context/tmpl/album-tmpl.html | 31 ++++++----
plugins/context/tmpl/artist-tmpl.html | 4 +-
5 files changed, 142 insertions(+), 132 deletions(-)
---
diff --git a/plugins/context/context/AlbumTab.py b/plugins/context/context/AlbumTab.py
index 1491a95..488fea1 100644
--- a/plugins/context/context/AlbumTab.py
+++ b/plugins/context/context/AlbumTab.py
@@ -31,14 +31,14 @@ import os
from mako.template import Template
import xml.dom.minidom as dom
-class AlbumTab (gobject.GObject) :
+class AlbumTab (gobject.GObject):
__gsignals__ = {
'switch-tab' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,))
}
- def __init__ (self, shell, buttons, ds, view) :
+ def __init__ (self, shell, buttons, ds, view):
gobject.GObject.__init__ (self)
self.shell = shell
self.sp = shell.get_player ()
@@ -55,35 +55,36 @@ class AlbumTab (gobject.GObject) :
self.button.set_relief( gtk.RELIEF_NONE )
self.button.set_focus_on_click(False)
self.button.connect ('clicked',
- lambda button : self.emit ('switch-tab', 'album'))
+ lambda button: self.emit ('switch-tab', 'album'))
buttons.pack_start (self.button, True, True)
- def activate (self) :
+ def activate (self):
self.button.set_active(True)
self.active = True
self.reload ()
- def deactivate (self) :
+ def deactivate (self):
self.button.set_active(False)
self.active = False
- def reload (self) :
+ def reload (self):
entry = self.sp.get_playing_entry ()
- if entry is None : return None
+ if entry is None:
+ return None
artist = self.db.entry_get (entry, rhythmdb.PROP_ARTIST)
album = self.db.entry_get (entry, rhythmdb.PROP_ALBUM)
- if self.active and artist != self.artist :
+ if self.active and artist != self.artist:
self.view.loading(artist)
self.ds.fetch_album_list (artist)
- else :
+ else:
self.view.load_view()
self.artist = artist
-class AlbumView (gobject.GObject) :
+class AlbumView (gobject.GObject):
- def __init__ (self, shell, plugin, webview, ds) :
+ def __init__ (self, shell, plugin, webview, ds):
gobject.GObject.__init__ (self)
self.webview = webview
self.ds = ds
@@ -97,13 +98,13 @@ class AlbumView (gobject.GObject) :
self.load_tmpl ()
self.connect_signals ()
- def load_view (self) :
+ def load_view (self):
self.webview.load_string(self.file, 'text/html', 'utf-8', self.basepath)
- def connect_signals (self) :
+ def connect_signals (self):
self.ds.connect('albums-ready', self.album_list_ready)
- def loading (self, current_artist) :
+ def loading (self, current_artist):
self.loading_file = self.loading_template.render (
artist = current_artist,
info = "Top Albums",
@@ -111,7 +112,7 @@ class AlbumView (gobject.GObject) :
basepath = self.basepath)
self.webview.load_string (self.loading_file, 'text/html', 'utf-8', self.basepath)
- def load_tmpl (self) :
+ def load_tmpl (self):
self.path = self.plugin.find_file ('tmpl/album-tmpl.html')
self.loading_path = self.plugin.find_file ('tmpl/loading.html')
self.album_template = Template (filename = self.path,
@@ -120,7 +121,7 @@ class AlbumView (gobject.GObject) :
module_directory = '/tmp/context')
self.styles = self.basepath + '/tmpl/main.css'
- def album_list_ready (self, ds) :
+ def album_list_ready (self, ds):
list = ds.get_top_albums ()
self.file = self.album_template.render (error = ds.get_error(),
list = list,
@@ -129,13 +130,13 @@ class AlbumView (gobject.GObject) :
self.load_view ()
-class AlbumDataSource (gobject.GObject) :
+class AlbumDataSource (gobject.GObject):
__gsignals__ = {
'albums-ready' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
}
- def __init__ (self) :
+ def __init__ (self):
gobject.GObject.__init__ (self)
self.api_key = '27151108bfce62e12c1f6341437e0e83'
self.url_prefix = 'http://ws.audioscrobbler.com/2.0/?method='
@@ -143,43 +144,43 @@ class AlbumDataSource (gobject.GObject) :
self.error = None
self.max_albums_fetched = 8
- def extract (self, data, position) :
+ def extract (self, data, position):
"""
Safely extract the data from an xml node. Returns data
at position or None if position does not exist
"""
- try :
+ try:
return data[position].firstChild.data
- except Exception, e :
+ except Exception, e:
return None
- def get_artist (self) :
- return self.artist
+ def get_artist (self):
+ return self.artist
- def get_error (self) :
+ def get_error (self):
return self.error
- def fetch_album_list (self, artist) :
- self.artist = artist
+ def fetch_album_list (self, artist):
+ self.artist = artist
self.error = None
url = "%sartist.gettopalbums&artist=%s&api_key=%s" % (self.url_prefix,
artist.replace(" ", "+"),
self.api_key)
- try :
+ try:
ld = rb.Loader ()
ld.get_url (url, self.fetch_album_list_cb, artist)
- except Exception, e :
+ except Exception, e:
print "problem fetching %s: %s" % (artist, e)
return
- def fetch_album_list_cb (self, data, artist) :
- if data is None :
+ def fetch_album_list_cb (self, data, artist):
+ if data is None:
print "Nothing fetched for %s top albums" % artist
return
parsed = dom.parseString (data)
lfm = parsed.getElementsByTagName ('lfm')[0]
- if lfm.attributes['status'].value == 'failed' :
+ if lfm.attributes['status'].value == 'failed':
self.error = lfm.childNodes[1].firstChild.data
self.emit ('albums-ready')
return
@@ -187,15 +188,16 @@ class AlbumDataSource (gobject.GObject) :
self.albums = []
album_nodes = parsed.getElementsByTagName ('album')
print "num albums: %d" % len(album_nodes)
- if len(album_nodes) == 0 :
+ if len(album_nodes) == 0:
self.error = "No albums found for %s" % artist
self.emit('albums-ready')
return
self.album_info_fetched = min (len (album_nodes) - 1, self.max_albums_fetched)
- for i, album in enumerate (album_nodes) :
- if i >= self.album_info_fetched : break
+ for i, album in enumerate (album_nodes):
+ if i >= self.album_info_fetched:
+ break
album_name = self.extract(album.getElementsByTagName ('name'), 0)
imgs = album.getElementsByTagName ('image')
@@ -203,10 +205,10 @@ class AlbumDataSource (gobject.GObject) :
self.albums.append ({'title' : album_name, 'images' : images })
self.fetch_album_info (artist, album_name, i)
- def get_top_albums (self) :
+ def get_top_albums (self):
return self.albums
- def fetch_album_info (self, artist, album, index) :
+ def fetch_album_info (self, artist, album, index):
url = "%salbum.getinfo&artist=%s&album=%s&api_key=%s" % (self.url_prefix,
artist.replace(" ", "+"),
album.replace(" ", "+"),
@@ -215,15 +217,15 @@ class AlbumDataSource (gobject.GObject) :
ld = rb.Loader()
ld.get_url (url, self.fetch_album_tracklist, album, index)
- def fetch_album_tracklist (self, data, album, index) :
- if data is None :
+ def fetch_album_tracklist (self, data, album, index):
+ if data is None:
self.assemble_info(None, None, None)
parsed = dom.parseString (data)
- try :
+ try:
self.albums[index]['id'] = parsed.getElementsByTagName ('id')[0].firstChild.data
- except Exception, e :
+ except Exception, e:
print "Problem parsing id, exiting: %s" % e
return None
@@ -236,28 +238,28 @@ class AlbumDataSource (gobject.GObject) :
ld = rb.Loader()
ld.get_url (url, self.assemble_info, album, index)
- def assemble_info (self, data, album, index) :
- if data is None :
+ def assemble_info (self, data, album, index):
+ if data is None:
print "nothing fetched for %s tracklist" % album
- else :
+ else:
parsed = dom.parseString (data)
- try :
+ try:
list = parsed.getElementsByTagName ('track')
tracklist = []
album_length = 0
- for i, track in enumerate(list) :
+ for i, track in enumerate(list):
title = track.getElementsByTagName ('title')[0].firstChild.data
duration = int(track.getElementsByTagName ('duration')[0].firstChild.data) / 1000
album_length += duration
tracklist.append ((i, title, duration))
self.albums[index]['tracklist'] = tracklist
self.albums[index]['duration'] = album_length
- except Exception, e :
+ except Exception, e:
print "Problem : %s" % e
gtk.gdk.threads_enter ()
self.album_info_fetched -= 1
print "%s albums left to process" % self.album_info_fetched
gtk.gdk.threads_leave ()
- if self.album_info_fetched == 0 :
+ if self.album_info_fetched == 0:
self.emit('albums-ready')
diff --git a/plugins/context/context/ArtistTab.py b/plugins/context/context/ArtistTab.py
index c071842..47a1cd6 100644
--- a/plugins/context/context/ArtistTab.py
+++ b/plugins/context/context/ArtistTab.py
@@ -32,14 +32,14 @@ import xml.dom.minidom as dom
import webkit
from mako.template import Template
-class ArtistTab (gobject.GObject) :
+class ArtistTab (gobject.GObject):
__gsignals__ = {
'switch-tab' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,))
}
- def __init__ (self, shell, buttons, ds, view) :
+ def __init__ (self, shell, buttons, ds, view):
gobject.GObject.__init__ (self)
self.shell = shell
self.sp = shell.get_player ()
@@ -59,34 +59,34 @@ class ArtistTab (gobject.GObject) :
lambda button : self.emit('switch-tab', 'artist'))
buttons.pack_start (self.button, True, True)
- def activate (self) :
+ def activate (self):
print "activating Artist Tab"
self.button.set_active(True)
self.active = True
self.reload ()
- def deactivate (self) :
+ def deactivate (self):
print "deactivating Artist Tab"
self.button.set_active(False)
self.active = False
- def reload (self) :
+ def reload (self):
entry = self.sp.get_playing_entry ()
- if entry is None :
+ if entry is None:
print "Nothing playing"
return None
artist = self.db.entry_get (entry, rhythmdb.PROP_ARTIST)
- if self.active and self.artist != artist :
+ if self.active and self.artist != artist:
self.datasource.fetch_artist_data (artist)
self.view.loading (artist)
- else :
+ else:
self.view.load_view()
self.artist = artist
-class ArtistView (gobject.GObject) :
+class ArtistView (gobject.GObject):
- def __init__ (self, shell, plugin, webview, ds) :
+ def __init__ (self, shell, plugin, webview, ds):
gobject.GObject.__init__ (self)
self.webview = webview
self.ds = ds
@@ -99,10 +99,10 @@ class ArtistView (gobject.GObject) :
self.load_tmpl ()
self.connect_signals ()
- def load_view (self) :
+ def load_view (self):
self.webview.load_string (self.file, 'text/html', 'utf-8', self.basepath)
- def loading (self, current_artist) :
+ def loading (self, current_artist):
self.loading_file = self.loading_template.render (
artist = current_artist,
info = "Bio",
@@ -110,20 +110,20 @@ class ArtistView (gobject.GObject) :
basepath = self.basepath)
self.webview.load_string (self.loading_file, 'text/html', 'utf-8', self.basepath)
- def load_tmpl (self) :
+ def load_tmpl (self):
self.path = self.plugin.find_file('tmpl/artist-tmpl.html')
self.loading_path = self.plugin.find_file ('tmpl/loading.html')
self.template = Template (filename = self.path, module_directory = '/tmp/context/')
self.loading_template = Template (filename = self.loading_path, module_directory = '/tmp/context')
self.styles = self.basepath + '/tmpl/main.css'
- def connect_signals (self) :
+ def connect_signals (self):
self.air_id = self.ds.connect ('artist-info-ready', self.artist_info_ready)
- def artist_info_ready (self, ds) :
+ def artist_info_ready (self, ds):
# Can only be called after the artist-info-ready signal has fired.
# If called any other time, the behavior is undefined
- try :
+ try:
info = ds.get_artist_info ()
small, med, big = info['images']
summary, full_bio = info['bio']
@@ -133,11 +133,11 @@ class ArtistView (gobject.GObject) :
shortbio = summary,
stylesheet = self.styles )
self.load_view ()
- except Exception, e :
+ except Exception, e:
print "Problem in info ready: %s" % e
-class ArtistDataSource (gobject.GObject) :
+class ArtistDataSource (gobject.GObject):
__gsignals__ = {
'artist-info-ready' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
@@ -146,7 +146,7 @@ class ArtistDataSource (gobject.GObject) :
'artist-top-albums-ready' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
}
- def __init__ (self) :
+ def __init__ (self):
gobject.GObject.__init__ (self)
self.api_key = '27151108bfce62e12c1f6341437e0e83'
self.url_prefix = 'http://ws.audioscrobbler.com/2.0/?method='
@@ -182,25 +182,25 @@ class ArtistDataSource (gobject.GObject) :
},
}
- def extract (self, data, position) :
+ def extract (self, data, position):
"""
Safely extract the data from an xml node. Returns data
at position or None if position does not exist
"""
- try :
+ try:
return data[position].firstChild.data
- except Exception, e :
+ except Exception, e:
return None
- def fetch_top_tracks (self, artist) :
+ def fetch_top_tracks (self, artist):
artist = artist.replace (" ", "+")
url = '%sartist.%s&artist=%s&api_key=%s' % (self.url_prefix,
self.artist['top_tracks']['function'], artist, self.api_key)
ld = rb.Loader()
ld.get_url (url, self.fetch_artist_data_cb, self.artist['top_tracks'])
- def fetch_artist_data (self, artist) :
+ def fetch_artist_data (self, artist):
"""
Initiate the fetching of all artist data. Fetches artist info, similar
artists, artist top albums and top tracks. Downloads XML files from last.fm
@@ -209,27 +209,27 @@ class ArtistDataSource (gobject.GObject) :
"""
self.current_artist = artist
artist = artist.replace(" ", "+")
- for key, value in self.artist.items() :
+ for key, value in self.artist.items():
url = '%sartist.%s&artist=%s&api_key=%s' % (self.url_prefix,
value['function'], artist, self.api_key)
ld = rb.Loader()
ld.get_url (url, self.fetch_artist_data_cb, value)
- def fetch_artist_data_cb (self, data, category) :
- if data is None :
+ def fetch_artist_data_cb (self, data, category):
+ if data is None:
print "no data fetched for artist %s" % category['function']
return
category['data'] = dom.parseString (data)
category['parsed'] = False
self.emit (category['signal'])
- def get_current_artist (self) :
+ def get_current_artist (self):
return self.current_artist
- def get_top_albums (self) :
- if not self.artist['top_albums']['parsed'] :
+ def get_top_albums (self):
+ if not self.artist['top_albums']['parsed']:
albums = []
- for album in self.artist['top_albums']['data'].getElementsByTagName ('album') :
+ for album in self.artist['top_albums']['data'].getElementsByTagName ('album'):
album_name = self.extract(album.getElementsByTagName ('name'), 0)
imgs = album.getElementsByTagName ('image')
images = self.extract(imgs, 0), self.extract(imgs, 1), self.extract(imgs,2)
@@ -239,17 +239,17 @@ class ArtistDataSource (gobject.GObject) :
return self.artist['top_albums']['data']
- def get_similar_artists (self) :
+ def get_similar_artists (self):
"""
Returns a list of similar artists
"""
data = self.artist['similar']['data']
- if data is None :
+ if data is None:
return None
- if not self.artist['similar']['parsed'] :
+ if not self.artist['similar']['parsed']:
lst = []
- for node in data.getElementsByTagName ('artist') :
+ for node in data.getElementsByTagName ('artist'):
artist = self.extract(node.getElementsByTagName('name'), 0)
similar = self.extract(node.getElementsByTagName('match') ,0)
image = self.extract(node.getElementsByTagName('image'), 0)
@@ -260,37 +260,37 @@ class ArtistDataSource (gobject.GObject) :
return data
- def get_artist_images (self) :
+ def get_artist_images (self):
"""
Returns tuple of image url's for small, medium, and large images.
"""
data = self.artist['info']['data']
- if data is None :
+ if data is None:
return None
images = data.getElementsByTagName ('image')
return self.extract(images,0), self.extract(images,1), self.extract(images,2)
- def get_artist_bio (self) :
+ def get_artist_bio (self):
"""
Returns tuple of summary and full bio
"""
data = self.artist['info']['data']
- if data is None :
+ if data is None:
return None
- if not self.artist['info']['parsed'] :
+ if not self.artist['info']['parsed']:
content = self.extract(data.getElementsByTagName ('content'), 0)
summary = self.extract(data.getElementsByTagName ('summary'), 0)
return summary, content
return self.artist['info']['data']['bio']
- def get_artist_info (self) :
+ def get_artist_info (self):
"""
Returns the dictionary { 'images', 'bio' }
"""
- if not self.artist['info']['parsed'] :
+ if not self.artist['info']['parsed']:
images = self.get_artist_images()
bio = self.get_artist_bio()
self.artist['info']['data'] = { 'images' : images,
@@ -299,17 +299,17 @@ class ArtistDataSource (gobject.GObject) :
return self.artist['info']['data']
- def get_top_tracks (self) :
+ def get_top_tracks (self):
"""
Returns a list of the top track titles
"""
data = self.artist['top_tracks']['data']
- if data is None :
+ if data is None:
return None
- if not self.artist['top_tracks']['parsed'] :
+ if not self.artist['top_tracks']['parsed']:
tracks = []
- for track in data.getElementsByTagName ('track') :
+ for track in data.getElementsByTagName ('track'):
name = self.extract(track.getElementsByTagName('name'), 0)
tracks.append (name)
self.artist['top_tracks']['data'] = tracks
diff --git a/plugins/context/context/ContextView.py b/plugins/context/context/ContextView.py
index dec3738..58011be 100644
--- a/plugins/context/context/ContextView.py
+++ b/plugins/context/context/ContextView.py
@@ -41,11 +41,11 @@ context_ui = """
</ui>
"""
-class ContextView (gobject.GObject) :
+class ContextView (gobject.GObject):
- def __init__ (self, shell, plugin) :
+ def __init__ (self, shell, plugin):
gobject.GObject.__init__ (self)
- self.shell = shell
+ self.shell = shell
self.sp = shell.get_player ()
self.db = shell.get_property ('db')
self.plugin = plugin
@@ -56,7 +56,7 @@ class ContextView (gobject.GObject) :
self.current_song = None
self.visible = True
- self.init_gui ()
+ self.init_gui ()
self.init_tabs()
self.connect_signals ()
@@ -78,7 +78,7 @@ class ContextView (gobject.GObject) :
self.ui_id = uim.add_ui_from_string(context_ui)
uim.ensure_update()
- def deactivate (self, shell) :
+ def deactivate (self, shell):
self.shell = None
self.disconnect_signals ()
self.player_cb_ids = None
@@ -93,41 +93,41 @@ class ContextView (gobject.GObject) :
uim.remove_ui (self.ui_id)
uim.remove_action_group (self.action_group)
- def connect_signals(self) :
+ def connect_signals(self):
self.player_cb_ids = ( self.sp.connect ('playing-changed', self.playing_changed_cb),
self.sp.connect ('playing-song-changed', self.playing_changed_cb))
self.ds_cb_id = self.ds['artist'].connect ('artist-top-tracks-ready', self.load_top_five)
self.tab_cb_ids = []
# Listen for switch-tab signal from each tab
- for key, value in self.tab.items() :
+ for key, value in self.tab.items():
self.tab_cb_ids.append((key, self.tab[key].connect ('switch-tab', self.change_tab)))
- def disconnect_signals (self) :
- for id in self.player_cb_ids :
+ def disconnect_signals (self):
+ for id in self.player_cb_ids:
self.sp.disconnect (id)
self.ds['artist'].disconnect (self.ds_cb_id)
- for key, id in self.tab_cb_ids :
+ for key, id in self.tab_cb_ids:
self.tab[key].disconnect (id)
- def toggle_visibility (self, action) :
- if not self.visible :
+ def toggle_visibility (self, action):
+ if not self.visible:
self.shell.add_widget (self.vbox, rb.SHELL_UI_LOCATION_RIGHT_SIDEBAR, expand=True)
self.visible = True
- else :
+ else:
self.shell.remove_widget (self.vbox, rb.SHELL_UI_LOCATION_RIGHT_SIDEBAR)
self.visible = False
- def change_tab (self, tab, newtab) :
+ def change_tab (self, tab, newtab):
print "swaping tab from %s to %s" % (self.current, newtab)
- if (self.current != newtab) :
+ if (self.current != newtab):
self.tab[self.current].deactivate()
self.tab[newtab].activate()
self.current = newtab
- def init_tabs (self) :
+ def init_tabs (self):
self.tab = {}
self.ds = {}
self.view = {}
@@ -142,34 +142,35 @@ class ContextView (gobject.GObject) :
self.view['lyrics'] = lt.LyricsView (self.shell, self.plugin, self.webview, self.ds['lyrics'])
self.tab['lyrics'] = lt.LyricsTab (self.shell, self.buttons, self.ds['lyrics'], self.view['lyrics'])
- def load_top_five (self, ds) :
+ def load_top_five (self, ds):
top_tracks = ds.get_top_tracks ()
## populate liststore
- if top_tracks is None :
+ if top_tracks is None:
self.top_five = ['','','','','']
- for i in range (0, 5) :
+ for i in range (0, 5):
self.top_five_list.append(["%d. " % (i+1), ""])
- else :
+ else:
num_tracks = len(top_tracks)
- for i in range (0, 5) :
+ for i in range (0, 5):
if i >= num_tracks : track = ""
else : track = top_tracks[i]
self.top_five_list[(i,)] = ("%d. " % (i+1), track)
- def playing_changed_cb (self, playing, user_data) :
+ def playing_changed_cb (self, playing, user_data):
playing_entry = self.sp.get_playing_entry ()
- if playing_entry is None : return
+ if playing_entry is None:
+ return
playing_artist = self.db.entry_get (playing_entry, rhythmdb.PROP_ARTIST)
- if self.current_artist != playing_artist :
+ if self.current_artist != playing_artist:
self.current_artist = playing_artist.replace ('&', '&')
self.label.set_markup(_('Top songs by <i>%s</i>' % self.current_artist))
self.ds['artist'].fetch_top_tracks (self.current_artist)
self.tab[self.current].reload()
- def init_gui(self) :
+ def init_gui(self):
self.vbox = gtk.VBox()
self.frame = gtk.Frame()
self.label = gtk.Label(_('Nothing Playing'))
diff --git a/plugins/context/tmpl/album-tmpl.html b/plugins/context/tmpl/album-tmpl.html
index 05bcbc0..5e9e33f 100644
--- a/plugins/context/tmpl/album-tmpl.html
+++ b/plugins/context/tmpl/album-tmpl.html
@@ -2,15 +2,18 @@
<html> <head> <meta http-equiv="content-type" content="text-html; charset=utf-8">
<%!
import re
- def cleanup(text) :
+ def cleanup(text):
return re.sub(r'\([^\)]*\)', '', text)
- def sec2hms(time) :
+ def sec2hms(time):
hr = time / 3600
- if hr > 0 : time %= 3600
+ if hr > 0:
+ time %= 3600
mn = time / 60
sec = time % 60
- if hr > 0 : return "%d:%02d:%02d" % (hr,mn,sec)
- else : return "%d:%02d" %(mn,sec)
+ if hr > 0:
+ return "%d:%02d:%02d" % (hr,mn,sec)
+ else:
+ return "%d:%02d" %(mn,sec)
%>
<link rel="stylesheet" href="${stylesheet}" type="text/css" />
<script language="javascript">
@@ -29,25 +32,29 @@
</script>
</head>
<body>
+%if error is None:
<%
num_albums = min(8, len(list))
%>
-%if error is None :
<h1>Top albums by <em>${artist}</em></h1>
%for i, entry in enumerate(list) :
- <%if 'tracklist' not in entry or len(entry['tracklist']) == 0 : continue %>
- <%if i == num_albums : break %>
+ <%
+ if 'tracklist' not in entry or len(entry['tracklist']) == 0:
+ continue
+ if i == num_albums:
+ break
+ %>
<div id="album${entry['id']}" class="album">
<img width="64" src="${entry['images'][1]}" alt="${entry['images']}"/>
<h2>${entry['title']}</h2>
- %if 'duration' in entry :
+ %if 'duration' in entry:
<%
album_time = sec2hms(entry['duration'])
tracks = len(entry['tracklist'])
%>
<p class="duration">${album_time} (${tracks} tracks)</p>
%endif
- %if 'tracklist' in entry :
+ %if 'tracklist' in entry:
<% btn_name = "btn_%s" % entry['id'] %>
<button id="btn_${entry['id']}"onclick="toggle_vis(${entry['id']})">
Show all tracks
@@ -62,12 +69,12 @@
<tr><td>${num}</td><td>${title}</td><td>${time}</td></tr>
%endfor
</table>
- %else :
+ %else:
<p>Tracklist not available</p>
%endif
</div>
%endfor
-%else :
+%else:
<h1>Last.fm Error:</h1>
<p class="error">${error}</p>
%endif
diff --git a/plugins/context/tmpl/artist-tmpl.html b/plugins/context/tmpl/artist-tmpl.html
index 53147cb..1249078 100644
--- a/plugins/context/tmpl/artist-tmpl.html
+++ b/plugins/context/tmpl/artist-tmpl.html
@@ -3,8 +3,8 @@
import re
remove_links = re.compile ('</?a[^>]*> ',re.VERBOSE)
- def cleanup(text) :
- if text is None :
+ def cleanup(text):
+ if text is None:
return "No information available"
text = remove_links.sub ('', text)
text = text.replace('\n', '</p><p>')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]