From dfc1b5cf0430dd178c8a6bbda2b14fd035c92088 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 10 Aug 2008 19:46:11 +0100 Subject: [PATCH] Allow file:///path feed URIs. This is equivalent to just using /path. Reported by Matt Lawrence. --- zeroinstall/gtkui/addbox.py | 5 +++-- zeroinstall/injector/model.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/zeroinstall/gtkui/addbox.py b/zeroinstall/gtkui/addbox.py index ac32afe..0ebb54c 100644 --- a/zeroinstall/gtkui/addbox.py +++ b/zeroinstall/gtkui/addbox.py @@ -7,6 +7,7 @@ import gtk, gobject import gtk.glade from zeroinstall import SafeException +from zeroinstall.injector import model from zeroinstall.injector.namespaces import XMLNS_IFACE from zeroinstall.injector.iface_cache import iface_cache @@ -64,7 +65,7 @@ class AddBox: nb = widgets.get_widget('notebook1') def update_details_page(): - iface = iface_cache.get_interface(uri.get_text()) + iface = iface_cache.get_interface(model.canonical_iface_uri(uri.get_text())) about.set_text('%s - %s' % (iface.get_name(), iface.summary)) icon_path = iface_cache.get_icon_path(iface) from zeroinstall.gtkui import icon @@ -87,7 +88,7 @@ class AddBox: def finish(): import xdgutils - iface = iface_cache.get_interface(uri.get_text()) + iface = iface_cache.get_interface(model.canonical_iface_uri(uri.get_text())) try: icon_path = iface_cache.get_icon_path(iface) diff --git a/zeroinstall/injector/model.py b/zeroinstall/injector/model.py index 1e61e8d..ab4069c 100644 --- a/zeroinstall/injector/model.py +++ b/zeroinstall/injector/model.py @@ -828,12 +828,15 @@ def _pretty_escape(uri): def canonical_iface_uri(uri): """If uri is a relative path, convert to an absolute one. + A "file:///foo" URI is converted to "/foo". Otherwise, return it unmodified. @rtype: str @raise SafeException: if uri isn't valid """ if uri.startswith('http:'): return uri + elif uri.startswith('file:///'): + return uri[7:] else: iface_uri = os.path.realpath(uri) if os.path.isfile(iface_uri): -- 2.11.4.GIT