From 5a3573b15d4abb8febd3619ca3d3d48818b1eed9 Mon Sep 17 00:00:00 2001 From: Artem Glebov Date: Thu, 14 Mar 2013 08:26:20 +0300 Subject: [PATCH] Moved the invariant code out of the loop in updateTorrents() --- resources/lib/gui.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/lib/gui.py b/resources/lib/gui.py index 9d00e7f..79df672 100644 --- a/resources/lib/gui.py +++ b/resources/lib/gui.py @@ -19,6 +19,10 @@ KEY_MENU_ID = 92 EXIT_SCRIPT = ( 6, 10, 247, 275, 61467, 216, 257, 61448, ) CANCEL_DIALOG = EXIT_SCRIPT + ( 216, 257, 61448, ) +STATUS_ICONS = {'stopped': 'pause.png', + 'seeding': 'ok.png', + 'downloading': 'down.png'} + class TransmissionGUI(xbmcgui.WindowXMLDialog): def __init__(self, strXMLname, strFallbackPath, strDefaultName, bforeFallback=0): self.list = {} @@ -67,7 +71,7 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog): self.repeater.start() def updateTorrents(self): list = self.getControl(120) - torrents = self.transmission.info() + self.torrents = self.transmission.info() for i, torrent in torrents.iteritems(): statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \ {'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \ @@ -81,13 +85,9 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog): else: # Update existing list item l = self.list[i] - self.torrents = torrents - statusicons = {'stopped': 'pause.png', - 'seeding': 'ok.png', - 'downloading': 'down.png'} l.setLabel(torrent.name) l.setLabel2(statusline) - l.setProperty('TorrentStatusIcon', statusicons.get(torrent.status, 'pending.png')) + l.setProperty('TorrentStatusIcon', STATUS_ICONS.get(torrent.status, 'pending.png')) l.setProperty('TorrentID', str(i)) l.setProperty('TorrentProgress', "%.2f" % torrent.progress) l.setInfo('torrent', torrent.fields)