Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Cameron <quozl@laptop.org>2010-07-27 02:51:17 (GMT)
committer James Cameron <quozl@laptop.org>2010-10-12 04:56:26 (GMT)
commit2bbe3b252a4043cb3a0ddda8ef4ba7099a695a81 (patch)
treeb3c94b5240f7f2f5ac907d7797ad93e1c1fb4369
parent210482b0ff4b51d3be6b8c6b3bd792f5f424c19f (diff)
restore sugar-launch by bundle id substring, fixes #897sucrose-0.84
sugar-launch uses GetBundlePath which calls bundleregistry.get_bundle(). In this patch, the get_bundle() method is changed to retain as much of the original API as possible, yet in the situation where it might return None it will now return a bundle if there is only one bundle that matches the search string. http://bugs.sugarlabs.org/ticket/897 http://dev.laptop.org/ticket/9189 Patch tested on Sugar 0.84.16 on OLPC XO-1.5 build os206. Test case: import jarabe.model.bundleregistry registry = jarabe.model.bundleregistry.BundleRegistry() tests = ['org.laptop.Terminal', 'Terminal', 'terminal', 'e', 'asdqweas'] for x in tests: y = registry.get_bundle(x) if y is None: z = 'None' else: z = y.get_bundle_id() print x, z Output before patch: org.laptop.Terminal org.laptop.Terminal Terminal None terminal None e None asdqweas None Output after patch: org.laptop.Terminal org.laptop.Terminal Terminal org.laptop.Terminal terminal org.laptop.Terminal e None asdqweas None
-rw-r--r--src/jarabe/model/bundleregistry.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index 1b6570e..af410a8 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -156,12 +156,22 @@ class BundleRegistry(gobject.GObject):
self._write_favorites_file()
def get_bundle(self, bundle_id):
- """Returns an bundle given his service name"""
+ """Returns a bundle given service name or substring,
+ returns None if there is either no match, or more than one
+ match by substring."""
+ result = []
+ key = bundle_id.lower()
+
for bundle in self._bundles:
- if bundle.get_bundle_id() == bundle_id:
+ name = bundle.get_bundle_id()
+ if name == bundle_id:
return bundle
+ if key in name.lower():
+ result.append(bundle)
+ if len(result) == 1:
+ return result[0]
return None
-
+
def __iter__(self):
return self._bundles.__iter__()