diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2017-06-08 03:34:08 +0300 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2017-06-08 03:34:08 +0300 |
commit | 1e9ba4fda8486136991152d7af2bfe65c0e52c69 (patch) | |
tree | 83a0998170e68271a1fad8e90748ab238cc9ea9d /pomu/source/manager.py | |
parent | Fix multiple issues with packages and repositories (diff) | |
download | pomu-1e9ba4fda8486136991152d7af2bfe65c0e52c69.tar.gz pomu-1e9ba4fda8486136991152d7af2bfe65c0e52c69.tar.bz2 pomu-1e9ba4fda8486136991152d7af2bfe65c0e52c69.zip |
Hook up sources, repo and dispatcher
Implement initial package recording, uninstalling
Diffstat (limited to 'pomu/source/manager.py')
-rw-r--r-- | pomu/source/manager.py | 19 |
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) |