From b1ee44e5e2e89d4969a6324674c7f122881aa4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 25 Jun 2008 20:26:45 +0200 Subject: Added 2.2 settings --- portato/backend/portage/setting_22.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 portato/backend/portage/setting_22.py diff --git a/portato/backend/portage/setting_22.py b/portato/backend/portage/setting_22.py new file mode 100644 index 0000000..4e68d7c --- /dev/null +++ b/portato/backend/portage/setting_22.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# +# File: portato/backend/portage/settings_22.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2008 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann + +from __future__ import absolute_import + +import portage +from .settings import PortageSettings + +class PortageSettings_22 (PortageSettings): + """Enhances the normal PortageSettings in ways, that it adds the setsconfig.""" + + def __init__ (self): + PortageSettings.__init__(self) + + def load (self): + PortageSettings.load(self) + + self.setsconfig = portage.sets.load_default_config(self.settings, self.trees[self.settings["ROOT"]]) -- cgit v1.2.3 From d5c4405e9e37c7793033fe190c9507eb5e39dcc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 25 Jun 2008 21:09:17 +0200 Subject: Added Package_22 and System_22 --- portato/backend/portage/package.py | 7 ++++++- portato/backend/portage/package_22.py | 22 ++++++++++++++++++++++ portato/backend/portage/system.py | 8 ++++---- portato/backend/portage/system_22.py | 31 +++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 portato/backend/portage/package_22.py create mode 100644 portato/backend/portage/system_22.py diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index db9866a..78125ee 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -18,7 +18,12 @@ from .. import system from ..exceptions import BlockedException, PackageNotFoundException, DependencyCalcError from ...helper import debug, error, unique_array -import portage, portage_dep +import portage + +try: + import portage.dep as portage_dep +except ImportError: + import portage_dep import os.path diff --git a/portato/backend/portage/package_22.py b/portato/backend/portage/package_22.py new file mode 100644 index 0000000..4fe03d9 --- /dev/null +++ b/portato/backend/portage/package_22.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# +# File: portato/backend/portage/package_22.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2008 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann + +from __future__ import absolute_import, with_statement + +from .package import PortagePackage + +class PortagePackage_22 (PortagePackage): + """ + The 2.2 specialization of the portage package. + Currently this is identical to the normal one. + """ + pass diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index 0d81945..db6b6ea 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -142,7 +142,7 @@ class PortageSystem (SystemInterface): """ if not only_cpv: - return [PortagePackage(x) for x in list_of_packages] + return [self.new_package(x) for x in list_of_packages] else: return list_of_packages @@ -154,7 +154,7 @@ class PortageSystem (SystemInterface): if only_cpv: return portage.best(list) else: - return PortagePackage(portage.best(list)) + return self.new_package(portage.best(list)) def find_best_match (self, search_key, masked = False, only_installed = False, only_cpv = False): t = [] @@ -287,7 +287,7 @@ class PortageSystem (SystemInterface): unresolved = [] for x in list: cpv = x.strip() - if len(cpv) and check(cpv): + if cpv and check(cpv): pkg = self.find_best_match(cpv, only_cpv = only_cpv) if pkg: resolved.append(pkg) @@ -304,7 +304,7 @@ class PortageSystem (SystemInterface): return portage.catpkgsplit(cpv) def sort_package_list(self, pkglist): - pkglist.sort(PortagePackage.compare_version) + pkglist.sort(PortagePackage.compare_version) # XXX: waaah ... direct package naming... =/ return pkglist def reload_settings (self): diff --git a/portato/backend/portage/system_22.py b/portato/backend/portage/system_22.py new file mode 100644 index 0000000..a4ea4a0 --- /dev/null +++ b/portato/backend/portage/system_22.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# +# File: portato/backend/portage/system_22.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2008 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann + +from __future__ import absolute_import, with_statement + +from .package_22 import PortagePackage_22 +from .settings_22 import PortageSettings_22 +from .system import PortageSystem + +class PortageSystem_22 (PortageSystem): + + def __init__ (self): + self.settings = PortageSettings_22() + portage.WORLD_FILE = os.path.join(self.settings.settings["ROOT"],portage.WORLD_FILE) + + self.use_descs = {} + self.local_use_descs = defaultdict(dict) + + self._version = tuple([x.split("_")[0] for x in portage.VERSION.split(".")]) + + def new_package (self, cpv): + return PortagePackage_22(cpv) -- cgit v1.2.3 From 9f820103c30e89376a0484c614d2bbc068998e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 25 Jun 2008 21:26:05 +0200 Subject: Now load 22 versions when running the correct portage --- portato/backend/portage/__init__.py | 12 ++++++++++-- portato/backend/portage/setting_22.py | 27 --------------------------- portato/backend/portage/settings_22.py | 27 +++++++++++++++++++++++++++ portato/backend/portage/system.py | 5 ++--- portato/backend/portage/system_22.py | 7 +++++-- 5 files changed, 44 insertions(+), 34 deletions(-) delete mode 100644 portato/backend/portage/setting_22.py create mode 100644 portato/backend/portage/settings_22.py diff --git a/portato/backend/portage/__init__.py b/portato/backend/portage/__init__.py index 6ccbf7f..be6cce6 100644 --- a/portato/backend/portage/__init__.py +++ b/portato/backend/portage/__init__.py @@ -12,5 +12,13 @@ from __future__ import absolute_import -from .system import PortageSystem -from .package import PortagePackage +from portage import VERSION as PV + +VERSION = tuple(map(int, (x.split("_")[0] for x in PV.split(".")))) + +if VERSION >= (2, 2): + from .system_22 import PortageSystem_22 as PortageSystem + from .package_22 import PortagePackage_22 as PortagePackage +else: + from .system import PortageSystem + from .package import PortagePackage diff --git a/portato/backend/portage/setting_22.py b/portato/backend/portage/setting_22.py deleted file mode 100644 index 4e68d7c..0000000 --- a/portato/backend/portage/setting_22.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -# -# File: portato/backend/portage/settings_22.py -# This file is part of the Portato-Project, a graphical portage-frontend. -# -# Copyright (C) 2008 René 'Necoro' Neumann -# This is free software. You may redistribute copies of it under the terms of -# the GNU General Public License version 2. -# There is NO WARRANTY, to the extent permitted by law. -# -# Written by René 'Necoro' Neumann - -from __future__ import absolute_import - -import portage -from .settings import PortageSettings - -class PortageSettings_22 (PortageSettings): - """Enhances the normal PortageSettings in ways, that it adds the setsconfig.""" - - def __init__ (self): - PortageSettings.__init__(self) - - def load (self): - PortageSettings.load(self) - - self.setsconfig = portage.sets.load_default_config(self.settings, self.trees[self.settings["ROOT"]]) diff --git a/portato/backend/portage/settings_22.py b/portato/backend/portage/settings_22.py new file mode 100644 index 0000000..a43d69e --- /dev/null +++ b/portato/backend/portage/settings_22.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# +# File: portato/backend/portage/settings_22.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2008 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann + +from __future__ import absolute_import + +import portage.sets +from .settings import PortageSettings + +class PortageSettings_22 (PortageSettings): + """Enhances the normal PortageSettings in ways, that it adds the setsconfig.""" + + def __init__ (self): + PortageSettings.__init__(self) + + def load (self): + PortageSettings.load(self) + + self.setsconfig = portage.sets.load_default_config(self.settings, self.trees[self.settings["ROOT"]]) diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index db6b6ea..feaf4df 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -16,6 +16,7 @@ import re, os, os.path import portage from collections import defaultdict +from . import VERSION from .package import PortagePackage from .settings import PortageSettings from ..system_interface import SystemInterface @@ -36,8 +37,6 @@ class PortageSystem (SystemInterface): self.use_descs = {} self.local_use_descs = defaultdict(dict) - self._version = tuple([x.split("_")[0] for x in portage.VERSION.split(".")]) - def get_version (self): return "Portage %s" % portage.VERSION @@ -166,7 +165,7 @@ class PortageSystem (SystemInterface): t = self.find_packages(search_key, pkgSet = pkgSet, masked = masked, with_version = True, only_cpv = True) - if self._version >= (2,1,5): + if VERSION >= (2,1,5): t += [pkg.get_cpv() for pkg in self.find_packages(search_key, "installed") if not (pkg.is_testing(True) or pkg.is_masked())] else: t = self.find_packages(search_key, "installed", only_cpv=True) diff --git a/portato/backend/portage/system_22.py b/portato/backend/portage/system_22.py index a4ea4a0..be27186 100644 --- a/portato/backend/portage/system_22.py +++ b/portato/backend/portage/system_22.py @@ -12,6 +12,11 @@ from __future__ import absolute_import, with_statement +import os +import portage + +from collections import defaultdict + from .package_22 import PortagePackage_22 from .settings_22 import PortageSettings_22 from .system import PortageSystem @@ -25,7 +30,5 @@ class PortageSystem_22 (PortageSystem): self.use_descs = {} self.local_use_descs = defaultdict(dict) - self._version = tuple([x.split("_")[0] for x in portage.VERSION.split(".")]) - def new_package (self, cpv): return PortagePackage_22(cpv) -- cgit v1.2.3