aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pomu/source/manager.py')
-rw-r--r--pomu/source/manager.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/pomu/source/manager.py b/pomu/source/manager.py
index 93c05c0..2847547 100644
--- a/pomu/source/manager.py
+++ b/pomu/source/manager.py
@@ -29,6 +29,8 @@ Example:
#import bisect
import inspect
+from pomu.util.result import Result
+
class PackageDispatcher():
def __init__(self):
self.handlers = []
@@ -66,3 +68,20 @@ class PackageDispatcher():
if handler(uri).is_ok():
return source
return None
+
+ def get_package(self, uri):
+ for priority, source, handler in self.handlers:
+ res = handler(uri)
+ if res.is_ok():
+ return source.fetch_package(res.ok())
+ return Result.Err('No handler found for package ' + uri)
+
+ def install_package(self, uri):
+ pkg = self.get_package(uri).unwrap()
+ #TODO: write a helper function which expects pomu_active_repo
+ #alternatively, test for it before any command which requires a repo
+ return pomu_active_repo().unwrap().merge(pkg)
+
+ def uninstall_package(self, uri):
+ pkg = self.get_package(uri).unwrap()
+ return pomu_active_repo().unwrap().unmerge(pkg)