aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMykyta Holubakha <hilobakho@gmail.com>2017-06-28 23:47:13 +0300
committerMykyta Holubakha <hilobakho@gmail.com>2017-06-28 23:47:13 +0300
commit64513feb88fe10a72cace2b2e7dbd5a07f8210c5 (patch)
treef3c2fba1ed9a2a95697bb2e7c8b1890967bf4fae
parentMajor updates and refactorings (diff)
downloadpomu-64513feb88fe10a72cace2b2e7dbd5a07f8210c5.tar.gz
pomu-64513feb88fe10a72cace2b2e7dbd5a07f8210c5.tar.bz2
pomu-64513feb88fe10a72cace2b2e7dbd5a07f8210c5.zip
Resolve circular imports
Convert dispatcher to selectable repos Move suffixes to util.pkg module
-rw-r--r--pomu/cli.py6
-rw-r--r--pomu/repo/repo.py2
-rw-r--r--pomu/source/manager.py11
-rw-r--r--pomu/util/cache.py1
-rw-r--r--pomu/util/pkg.py5
-rw-r--r--pomu/util/portage.py3
6 files changed, 15 insertions, 13 deletions
diff --git a/pomu/cli.py b/pomu/cli.py
index 65dfa15..9a0b9bf 100644
--- a/pomu/cli.py
+++ b/pomu/cli.py
@@ -74,7 +74,7 @@ def status():
@needs_repo
def install(package):
"""Install a package"""
- res = dispatcher.install_package(package).expect()
+ res = dispatcher.install_package(pomu_active_repo(), package).expect()
print(res)
@main.command()
@@ -84,11 +84,11 @@ def install(package):
@needs_repo
def uninstall(uri, package):
"""Uninstall a package"""
+ repo = pomu_active_repo()
if uri:
- res = dispatcher.uninstall_package(package).expect()
+ res = dispatcher.uninstall_package(repo, package).expect()
print(res)
else:
- repo = pomu_active_repo()
res = repo.remove_package(package).expect()
return res
diff --git a/pomu/repo/repo.py b/pomu/repo/repo.py
index df891e1..8bbc7fb 100644
--- a/pomu/repo/repo.py
+++ b/pomu/repo/repo.py
@@ -5,7 +5,6 @@ from git import Repo
import portage
from pomu.package import Package
-from pomu.source import dispatcher
from pomu.util.cache import cached
from pomu.util.fs import remove_file, strip_prefix
from pomu.util.result import Result
@@ -93,6 +92,7 @@ class Repository():
def _get_package(self, category, name, slot='0'):
"""Get an existing package (by category, name and slot), reading the manifest"""
+ from pomu.source import dispatcher
if slot == '0':
pkgdir = path.join(self.pomu_dir, category, name)
else:
diff --git a/pomu/source/manager.py b/pomu/source/manager.py
index 47c4953..b91bdd0 100644
--- a/pomu/source/manager.py
+++ b/pomu/source/manager.py
@@ -29,7 +29,6 @@ Example:
#import bisect
import inspect
-from pomu.repo.repo import pomu_active_repo
from pomu.util.result import Result
class PackageDispatcher():
@@ -95,12 +94,12 @@ class PackageDispatcher():
return Result.Ok(source.fetch_package(res.ok()))
return Result.Err('No handler found for package ' + uri)
- def install_package(self, uri):
- """Install a package specified by the descriptor"""
+ def install_package(self, repo, uri):
+ """Install a package specified by the descriptor into the repository"""
pkg = self.get_package(uri).unwrap()
- return pomu_active_repo().merge(pkg)
+ return repo.merge(pkg)
- def uninstall_package(self, uri):
+ def uninstall_package(self, repo, uri):
"""Uninstall a package specified by the descriptor"""
pkg = self.get_package(uri).unwrap()
- return pomu_active_repo().unmerge(pkg)
+ return repo.unmerge(pkg)
diff --git a/pomu/util/cache.py b/pomu/util/cache.py
index 93502c5..3419a4b 100644
--- a/pomu/util/cache.py
+++ b/pomu/util/cache.py
@@ -7,6 +7,7 @@ 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()
diff --git a/pomu/util/pkg.py b/pomu/util/pkg.py
index 26fdb39..7ff3a7c 100644
--- a/pomu/util/pkg.py
+++ b/pomu/util/pkg.py
@@ -4,9 +4,12 @@ A set of utility function to manipulate package descriptions
import re
-from pomu.util.portage import suffixes
+from portage.versions import suffix_value
+
from pomu.util.str import pivot
+suffixes = [x[0] for x in sorted(suffix_value.items(), key=lambda x:x[1])]
+
def ver_str(vernum, suff, rev):
"""Gets the string representation of the version (specified by number, suffix and rev)"""
return vernum + (suff if suff else '') + (rev if rev else '')
diff --git a/pomu/util/portage.py b/pomu/util/portage.py
index 32d8e5d..2cc93a9 100644
--- a/pomu/util/portage.py
+++ b/pomu/util/portage.py
@@ -6,12 +6,11 @@ import os
from os import path
-from portage.versions import best, suffix_value
+from portage.versions import suffix_value
from pomu.repo.repo import portage_repos, portage_repo_path
from pomu.util.pkg import cpv_split, ver_str
-suffixes = [x[0] for x in sorted(suffix_value.items(), key=lambda x:x[1])]
misc_dirs = ['profiles', 'licenses', 'eclass', 'metadata', 'distfiles', 'packages', 'scripts', '.git']
def best_ver(repo, category, name, ver=None):