simplifications in plugin update code

svn: r16590
This commit is contained in:
Gerald Britton
2011-02-08 21:27:23 +00:00
parent fc9001632d
commit 38143d7ac4

View File

@@ -386,9 +386,8 @@ class ViewManager(CLIManager):
version_str_to_tup(plugin.version, 3)): version_str_to_tup(plugin.version, 3)):
LOG.debug(" Downloading '%s'..." % plugin_dict["z"]) LOG.debug(" Downloading '%s'..." % plugin_dict["z"])
if "update" in whattypes: if "update" in whattypes:
if ((not config.get('behavior.do-not-show-previously-seen-updates')) or if (not config.get('behavior.do-not-show-previously-seen-updates') or
(config.get('behavior.do-not-show-previously-seen-updates') and plugin_dict["i"] not in config.get('behavior.previously-seen-updates')):
plugin_dict["i"] not in config.get('behavior.previously-seen-updates'))):
addon_update_list.append(("Updated", addon_update_list.append(("Updated",
"%s/download/%s" % "%s/download/%s" %
(ADDONS_URL, (ADDONS_URL,
@@ -399,9 +398,8 @@ class ViewManager(CLIManager):
else: else:
LOG.debug(" '%s' is not installed" % plugin_dict["n"]) LOG.debug(" '%s' is not installed" % plugin_dict["n"])
if "new" in whattypes: if "new" in whattypes:
if ((not config.get('behavior.do-not-show-previously-seen-updates')) or if (not config.get('behavior.do-not-show-previously-seen-updates') or
(config.get('behavior.do-not-show-previously-seen-updates') and plugin_dict["i"] not in config.get('behavior.previously-seen-updates')):
plugin_dict["i"] not in config.get('behavior.previously-seen-updates'))):
addon_update_list.append(("New", addon_update_list.append(("New",
"%s/download/%s" % "%s/download/%s" %
(ADDONS_URL, (ADDONS_URL,
@@ -507,12 +505,15 @@ class ViewManager(CLIManager):
from QuestionDialog import OkDialog from QuestionDialog import OkDialog
from gui.widgets.progressdialog import LongOpStatus from gui.widgets.progressdialog import LongOpStatus
self.update_dialog.hide() self.update_dialog.hide()
iter = self.list.model.get_iter_first() model = self.list.model
iter = model.get_iter_first()
length = 0 length = 0
while iter: while iter:
iter = self.list.model.iter_next(iter) iter = model.iter_next(iter)
if iter: if iter:
length += self.list.model.iter_n_children(iter) length += model.iter_n_children(iter)
longop = LongOpStatus( longop = LongOpStatus(
_("Downloading and installing selected addons..."), _("Downloading and installing selected addons..."),
length, 1, # total, increment-by length, 1, # total, increment-by
@@ -524,16 +525,12 @@ class ViewManager(CLIManager):
if not config.get('behavior.do-not-show-previously-seen-updates'): if not config.get('behavior.do-not-show-previously-seen-updates'):
# reset list # reset list
config.get('behavior.previously-seen-updates')[:] = [] config.get('behavior.previously-seen-updates')[:] = []
iter = self.list.model.get_iter_first()
iter = model.get_iter_first()
while iter: while iter:
for rowcnt in range(self.list.model.iter_n_children(iter)): for rowcnt in range(model.iter_n_children(iter)):
child = self.list.model.iter_nth_child(iter, rowcnt) child = model.iter_nth_child(iter, rowcnt)
row = [self.list.model.get_value(child, 0), row = [model.get_value(child, n) for n in range(6)]
self.list.model.get_value(child, 1),
self.list.model.get_value(child, 2),
self.list.model.get_value(child, 3),
self.list.model.get_value(child, 4),
self.list.model.get_value(child, 5),]
if longop.should_cancel(): if longop.should_cancel():
break break
elif row[0]: # toggle on elif row[0]: # toggle on
@@ -544,7 +541,8 @@ class ViewManager(CLIManager):
config.get('behavior.previously-seen-updates').append(row[5]) config.get('behavior.previously-seen-updates').append(row[5])
longop.heartbeat() longop.heartbeat()
pm._get_dlg()._process_events() pm._get_dlg()._process_events()
iter = self.list.model.iter_next(iter) iter = model.iter_next(iter)
if not longop.was_cancelled(): if not longop.was_cancelled():
longop.end() longop.end()
if count: if count: