summaryrefslogtreecommitdiff
path: root/portato/backend
diff options
context:
space:
mode:
authornecoro <>2007-08-27 07:30:38 +0000
committernecoro <>2007-08-27 07:30:38 +0000
commit8c066e79b03ad4e20a9f7c4ae36a9e247b79a8eb (patch)
treecbc6522de7532adc6a85ff6e816e186b077f2cc4 /portato/backend
parentc16b547f2c2bc23bef3a93b1987715c00c521718 (diff)
downloadportato-8c066e79b03ad4e20a9f7c4ae36a9e247b79a8eb.tar.gz
portato-8c066e79b03ad4e20a9f7c4ae36a9e247b79a8eb.tar.bz2
portato-8c066e79b03ad4e20a9f7c4ae36a9e247b79a8eb.zip
Change to absolute_imports; Warning: definitly broken
Diffstat (limited to '')
-rw-r--r--portato/backend/__init__.py20
-rw-r--r--portato/backend/flags.py29
-rw-r--r--portato/backend/package.py7
-rw-r--r--portato/backend/portage/__init__.py6
-rw-r--r--portato/backend/portage/package.py10
-rw-r--r--portato/backend/portage/settings.py2
-rw-r--r--portato/backend/portage/system.py18
7 files changed, 58 insertions, 34 deletions
diff --git a/portato/backend/__init__.py b/portato/backend/__init__.py
index d1d61e8..92b77a8 100644
--- a/portato/backend/__init__.py
+++ b/portato/backend/__init__.py
@@ -10,12 +10,21 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from exceptions import *
-from system_interface import SystemInterface
+from __future__ import absolute_import
+
+from .system_interface import SystemInterface
+from .exceptions import BlockedException, PackageNotFoundException, DependencyCalcError, InvalidSystemError
SYSTEM = "portage" # the name of the current system
_sys = None # the SystemInterface-instance
+class _Package (object):
+ """Wrapping class from which L{portato.backend.Package} inherits. This is used by the flags module to check
+ whether an object is a package. It cannot use the normal Package class as this results in cyclic dependencies."""
+
+ def __init__ (self):
+ raise TypeError, "Calling __init__ on portato.backend._Package objects is not allowed."
+
class SystemWrapper (SystemInterface):
"""This is a wrapper to the different system interfaces, allowing the direct import via C{from portato.backend import system}.
With this wrapper a change of the system is propagated to all imports."""
@@ -42,7 +51,7 @@ def load_system ():
global _sys
if SYSTEM == "portage":
- from portato.backend.portage import PortageSystem
+ from .portage import PortageSystem
_sys = PortageSystem ()
else:
raise InvalidSystemError, SYSTEM
@@ -50,6 +59,9 @@ def load_system ():
system = SystemWrapper()
# import package before loading the system as some systems may depend on it being in the namespace
-from package import Package
+from .package import Package
+
+def is_package(what):
+ return isinstance(what, Package)
load_system()
diff --git a/portato/backend/flags.py b/portato/backend/flags.py
index 99ff56f..1e1325e 100644
--- a/portato/backend/flags.py
+++ b/portato/backend/flags.py
@@ -10,14 +10,15 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
+from __future__ import absolute_import
+
import os
import os.path
from subprocess import Popen, PIPE # needed for grep
from gettext import lgettext as _
-from portato.helper import *
-from portato.backend import system
-import package
+from . import system, _Package
+from ..helper import debug, error, unique_array
CONFIG = {
"usefile" : "portato",
@@ -93,7 +94,7 @@ def grep (pkg, path):
@returns: occurences of pkg in the format: "file:line-no:complete_line_found"
@rtype: string"""
- if not isinstance(pkg, package.Package):
+ if not isinstance(pkg, _Package):
pkg = system.new_package(pkg) # assume it is a cpv or a gentoolkit.Package
if os.path.exists(path):
@@ -201,7 +202,7 @@ def set_use_flag (pkg, flag):
global useFlags, newUseFlags
- if not isinstance(pkg, package.Package):
+ if not isinstance(pkg, _Package):
pkg = system.new_package(pkg) # assume cpv or gentoolkit.Package
cpv = pkg.get_cpv()
@@ -265,7 +266,7 @@ def remove_new_use_flags (cpv):
@param cpv: the package for which to remove the flags
@type cpv: string (cpv) or L{backend.Package}-object"""
- if isinstance(cpv, package.Package):
+ if isinstance(cpv, _Package):
cpv = cpv.get_cpv()
try:
@@ -281,7 +282,7 @@ def get_new_use_flags (cpv):
@returns: list of flags
@rtype: string[]"""
- if isinstance(cpv, package.Package):
+ if isinstance(cpv, _Package):
cpv = cpv.get_cpv()
list2return = []
@@ -398,7 +399,7 @@ def set_masked (pkg, masked = True):
global new_masked, newunmasked
- if not isinstance(pkg, package.Package):
+ if not isinstance(pkg, _Package):
pkg = system.new_package(pkg)
cpv = pkg.get_cpv()
@@ -457,7 +458,7 @@ def set_masked (pkg, masked = True):
debug("new_(un)masked: %s",str(link_neq))
def remove_new_masked (cpv):
- if isinstance(cpv, package.Package):
+ if isinstance(cpv, _Package):
cpv = cpv.get_cpv()
try:
@@ -471,7 +472,7 @@ def remove_new_masked (cpv):
pass
def new_masking_status (cpv):
- if isinstance(cpv, package.Package):
+ if isinstance(cpv, _Package):
cpv = cpv.get_cpv()
def get(list):
@@ -499,7 +500,7 @@ def new_masking_status (cpv):
def is_locally_masked (pkg, changes = True):
- if not isinstance(pkg, package.Package):
+ if not isinstance(pkg, _Package):
pkg = system.new_package(pkg) # assume it is a cpv or a gentoolkit.Package
if changes:
@@ -594,7 +595,7 @@ newTesting = {}
arch = ""
def remove_new_testing (cpv):
- if isinstance(cpv, package.Package):
+ if isinstance(cpv, _Package):
cpv = cpv.get_cpv()
try:
@@ -603,7 +604,7 @@ def remove_new_testing (cpv):
pass
def new_testing_status (cpv):
- if isinstance(cpv, package.Package):
+ if isinstance(cpv, _Package):
cpv = cpv.get_cpv()
if cpv in newTesting:
@@ -621,7 +622,7 @@ def set_testing (pkg, enable):
@type enable: boolean"""
global arch, newTesting
- if not isinstance(pkg, package.Package):
+ if not isinstance(pkg, _Package):
pkg = system.new_package(pkg)
arch = pkg.get_global_settings("ARCH")
diff --git a/portato/backend/package.py b/portato/backend/package.py
index 343dc51..a7f41d7 100644
--- a/portato/backend/package.py
+++ b/portato/backend/package.py
@@ -10,10 +10,11 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from portato.backend import system
-import flags
+from __future__ import absolute_import
-class Package (object):
+from . import _Package, system, flags
+
+class Package (_Package):
"""This is a class abstracting a normal package which can be installed."""
def __init__ (self, cpv):
diff --git a/portato/backend/portage/__init__.py b/portato/backend/portage/__init__.py
index e21278c..6ccbf7f 100644
--- a/portato/backend/portage/__init__.py
+++ b/portato/backend/portage/__init__.py
@@ -10,5 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from system import PortageSystem
-from package import PortagePackage
+from __future__ import absolute_import
+
+from .system import PortageSystem
+from .package import PortagePackage
diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py
index 2a2d81a..eea0ec8 100644
--- a/portato/backend/portage/package.py
+++ b/portato/backend/portage/package.py
@@ -10,9 +10,13 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from portato.helper import *
-from portato.backend.exceptions import *
-from portato.backend import flags, Package, system
+from __future__ import absolute_import
+
+from ..package import Package
+from .. import flags
+from .. import system
+from ..exceptions import BlockedException, PackageNotFoundException
+from ...helper import debug, unique_array
import portage, portage_dep
from portage_util import unique_array
diff --git a/portato/backend/portage/settings.py b/portato/backend/portage/settings.py
index 5d3aef0..4e7a347 100644
--- a/portato/backend/portage/settings.py
+++ b/portato/backend/portage/settings.py
@@ -10,6 +10,8 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
+from __future__ import absolute_import
+
import os
import portage
from threading import Lock
diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py
index f6b2a3b..eeccb9c 100644
--- a/portato/backend/portage/system.py
+++ b/portato/backend/portage/system.py
@@ -10,15 +10,17 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
+from __future__ import absolute_import
+
import re, os
import types
from gettext import lgettext as _
import portage
-import package
-from settings import PortageSettings
-from portato.helper import *
-from portato.backend.system_interface import SystemInterface
+from .package import PortagePackage
+from .settings import PortageSettings
+from ..system_interface import SystemInterface
+from ...helper import debug, unique_array
class PortageSystem (SystemInterface):
"""This class provides access to the portage-system."""
@@ -32,7 +34,7 @@ class PortageSystem (SystemInterface):
portage.WORLD_FILE = self.settings.settings["ROOT"]+portage.WORLD_FILE
def new_package (self, cpv):
- return package.PortagePackage(cpv)
+ return PortagePackage(cpv)
def get_config_path (self):
return portage.USER_CONFIG_PATH
@@ -115,13 +117,13 @@ class PortageSystem (SystemInterface):
@returns: converted list
@rtype: PortagePackage[]"""
- return [package.PortagePackage(x) for x in list_of_packages]
+ return [PortagePackage(x) for x in list_of_packages]
def get_global_settings (self, key):
return self.settings.settings[key]
def find_best (self, list):
- return package.PortagePackage(portage.best(list))
+ return PortagePackage(portage.best(list))
def find_best_match (self, search_key, only_installed = False):
t = None
@@ -263,7 +265,7 @@ class PortageSystem (SystemInterface):
return portage.catpkgsplit(cpv)
def sort_package_list(self, pkglist):
- pkglist.sort(package.PortagePackage.compare_version)
+ pkglist.sort(PortagePackage.compare_version)
return pkglist
def reload_settings (self):