diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2017-06-30 03:47:13 +0300 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2017-06-30 03:47:13 +0300 |
commit | e34c5f770cc3bc48db7a4d62583e6ac738a48575 (patch) | |
tree | f3c5c6f8509cb0350c889b0398c09e112c24571e /pomu | |
parent | Added README (diff) | |
download | pomu-e34c5f770cc3bc48db7a4d62583e6ac738a48575.tar.gz pomu-e34c5f770cc3bc48db7a4d62583e6ac738a48575.tar.bz2 pomu-e34c5f770cc3bc48db7a4d62583e6ac738a48575.zip |
Fix unit tests
Diffstat (limited to 'pomu')
-rw-r--r-- | pomu/package.py | 9 | ||||
-rw-r--r-- | pomu/repo/repo.py | 2 | ||||
-rw-r--r-- | pomu/source/manager.py | 4 | ||||
-rw-r--r-- | pomu/util/cache.py | 5 | ||||
-rw-r--r-- | pomu/util/portage.py | 2 |
5 files changed, 17 insertions, 5 deletions
diff --git a/pomu/package.py b/pomu/package.py index d59bd4f..55ec994 100644 --- a/pomu/package.py +++ b/pomu/package.py @@ -48,11 +48,18 @@ class Package(): else: raise ValueError('You should specify either d_path, files or filemap') + @property + def files(self): + res = [] + for k in self.filemap: + res.append(path.split(k)) + return res + def strip_root(self, d_path): """Strip the root component of d_path""" # the path should be either relative, or a child of root if d_path.startswith('/'): - if path.commonprefix(d_path, self.root) != self.root: + if path.commonprefix([d_path, self.root]) != self.root: raise ValueError('Path should be a subdirectory of root') return strip_prefix(strip_prefix(d_path, self.root), '/') return d_path diff --git a/pomu/repo/repo.py b/pomu/repo/repo.py index 8bbc7fb..11a5c2c 100644 --- a/pomu/repo/repo.py +++ b/pomu/repo/repo.py @@ -156,5 +156,5 @@ def pomu_active_repo(no_portage=None, repo_path=None): else: repo = pomu_active_portage_repo() if repo: - return Result.Ok(Repository(repo)) + return Result.Ok(Repository(portage_repo_path(repo), repo)) return Result.Err('pomu is not initialized') diff --git a/pomu/source/manager.py b/pomu/source/manager.py index b91bdd0..600a987 100644 --- a/pomu/source/manager.py +++ b/pomu/source/manager.py @@ -83,8 +83,8 @@ class PackageDispatcher(): """Get a source which accepts the package""" for priority, source, handler in self.handlers: if handler(uri).is_ok(): - return source - return None + return Result.Ok(source) + return Result.Err('No handler found for package ' + uri) def get_package(self, uri): """Fetch a package specified by the descriptor""" diff --git a/pomu/util/cache.py b/pomu/util/cache.py index 3419a4b..1c92a4e 100644 --- a/pomu/util/cache.py +++ b/pomu/util/cache.py @@ -8,7 +8,12 @@ class cached(): def __init__(self, fun): self.fun = fun self.__name__ = fun.__name__ + def __call__(self, *args): if not hasattr(self, 'retval'): self.retval = self.fun(*args).unwrap() return self.retval + + def _drop(self): + if hasattr(self, 'retval'): + del self.retval diff --git a/pomu/util/portage.py b/pomu/util/portage.py index 2cc93a9..3491dfa 100644 --- a/pomu/util/portage.py +++ b/pomu/util/portage.py @@ -6,7 +6,7 @@ import os from os import path -from portage.versions import suffix_value +from portage.versions import best from pomu.repo.repo import portage_repos, portage_repo_path from pomu.util.pkg import cpv_split, ver_str |