From c978c864066fda7417da6aceea7887006cb11512 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 17 Jun 2012 08:42:34 +0100 Subject: [PATCH] Allow passing requirements to "0install select APP" Shows the selections that would result from the new requirements, and displays a message about using "0install update" to save them. --- zeroinstall/cmd/select.py | 9 +++++++++ zeroinstall/injector/requirements.py | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/zeroinstall/cmd/select.py b/zeroinstall/cmd/select.py index e5603cb..1433f39 100644 --- a/zeroinstall/cmd/select.py +++ b/zeroinstall/cmd/select.py @@ -153,8 +153,15 @@ def handle(config, options, args): app = config.app_mgr.lookup_app(args[0], missing_ok = True) if app is not None: sels = app.get_selections() + + r = app.get_requirements() + do_select = r.parse_update_options(options) + iface_uri = sels.interface else: iface_uri = model.canonical_iface_uri(args[0]) + do_select = True + + if do_select: sels = get_selections(config, options, iface_uri, select_only = True, download_only = False, test_callback = None) if not sels: @@ -164,6 +171,8 @@ def handle(config, options, args): show_xml(sels) else: show_human(sels, config.stores) + if app is not None and do_select: + print(_("(use '0install update' to save the new parameters)")) def show_xml(sels): doc = sels.toDOM() diff --git a/zeroinstall/injector/requirements.py b/zeroinstall/injector/requirements.py index 4f97447..3015a0c 100644 --- a/zeroinstall/injector/requirements.py +++ b/zeroinstall/injector/requirements.py @@ -49,16 +49,21 @@ class Requirements(object): def parse_update_options(self, options): """Update the settings based on the options (used for "0install update APP"). + @return: whether any settings were changed + @rtype: bool @since: 1.9""" + changed = False for key in ['not_before', 'before', 'message', 'cpu', 'os', 'command']: value = getattr(options, key) if value is not None: + changed = changed or value != getattr(self, key) setattr(self, key, value) if options.source and not self.source: # (partly because it doesn't make much sense, and partly because you # can't undo it, as there's no --not-source option) from zeroinstall import SafeException raise SafeException("Can't update from binary to source type!") + return changed def get_as_options(self): gui_args = [] -- 2.11.4.GIT