summaryrefslogtreecommitdiff
path: root/portato/backend
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/backend/__init__.py6
-rw-r--r--portato/backend/flags.py77
-rw-r--r--portato/backend/package.py2
-rw-r--r--portato/backend/portage/__init__.py2
-rw-r--r--portato/backend/portage/package.py10
-rw-r--r--portato/backend/portage/package_22.py2
-rw-r--r--portato/backend/portage/sets.py8
-rw-r--r--portato/backend/portage/settings.py2
-rw-r--r--portato/backend/portage/settings_22.py2
-rw-r--r--portato/backend/portage/system.py8
-rw-r--r--portato/backend/portage/system_22.py4
11 files changed, 56 insertions, 67 deletions
diff --git a/portato/backend/__init__.py b/portato/backend/__init__.py
index 5f32818..5fb716e 100644
--- a/portato/backend/__init__.py
+++ b/portato/backend/__init__.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import
+
from ..helper import debug
from .system_interface import SystemInterface
@@ -21,7 +21,7 @@ class _Package (object):
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."
+ raise TypeError("Calling __init__ on portato.backend._Package objects is not allowed.")
def is_package(what):
return isinstance(what, _Package)
@@ -65,6 +65,6 @@ class SystemWrapper (SystemInterface):
from .portage import PortageSystem
cls.__wrapped_sys = PortageSystem ()
else:
- raise InvalidSystemError, cls.__system
+ raise InvalidSystemError(cls.__system)
system = SystemWrapper()
diff --git a/portato/backend/flags.py b/portato/backend/flags.py
index 810b607..45826c3 100644
--- a/portato/backend/flags.py
+++ b/portato/backend/flags.py
@@ -10,8 +10,6 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import, with_statement
-
import os
import itertools as itt
from subprocess import Popen, PIPE # needed for grep
@@ -134,7 +132,7 @@ def set_config (cfg):
for i in CONFIG.keys():
if not i in cfg:
- raise KeyError, "Missing keyword in config: "+i
+ raise KeyError("Missing keyword in config: "+i)
for i in CONFIG:
CONFIG[i] = cfg[i]
@@ -583,31 +581,29 @@ def write_masked ():
list = system.split_cpv(cpv)
msg += "%s/%s\n" % (list[0],list[1])
if not file in file_cache:
- f = open(file, "a")
- f.write(msg)
- f.close()
+ with open(file, "a") as f:
+ f.write(msg)
else:
file_cache[file].append(msg)
# change a line
else:
if not file in file_cache:
# read file
- f = open(file, "r")
- lines = []
- i = 1
- while i < line: # stop at the given line
- lines.append(f.readline())
- i = i+1
- # delete
- l = f.readline()
- l = "#"+l[:-1]+" # removed by portato\n"
- lines.append(l)
+ with open(file, "r") as f:
+ lines = []
+ i = 1
+ while i < line: # stop at the given line
+ lines.append(f.readline())
+ i = i+1
+ # delete
+ l = f.readline()
+ l = "#"+l[:-1]+" # removed by portato\n"
+ lines.append(l)
- # read the rest
- lines.extend(f.readlines())
+ # read the rest
+ lines.extend(f.readlines())
- file_cache[file] = lines
- f.close()
+ file_cache[file] = lines
else: # in cache
l = file_cache[file][line-1]
# delete:
@@ -719,31 +715,29 @@ def write_testing ():
list = system.split_cpv(cpv)
msg += "%s/%s ~%s\n" % (list[0],list[1],arch)
if not file in file_cache:
- f = open(file, "a")
- f.write(msg)
- f.close()
+ with open(file, "a") as f:
+ f.write(msg)
else:
file_cache[file].append(msg)
# change a line
else:
if not file in file_cache:
# read file
- f = open(file, "r")
- lines = []
- i = 1
- while i < line: # stop at the given line
- lines.append(f.readline())
- i = i+1
- # delete
- l = f.readline()
- l = "#"+l[:-1]+" # removed by portato\n"
- lines.append(l)
-
- # read the rest
- lines.extend(f.readlines())
-
- file_cache[file] = lines
- f.close()
+ with open(file, "r") as f:
+ lines = []
+ i = 1
+ while i < line: # stop at the given line
+ lines.append(f.readline())
+ i = i+1
+ # delete
+ l = f.readline()
+ l = "#"+l[:-1]+" # removed by portato\n"
+ lines.append(l)
+
+ # read the rest
+ lines.extend(f.readlines())
+
+ file_cache[file] = lines
else: # in cache
l = file_cache[file][line-1]
# delete:
@@ -752,9 +746,8 @@ def write_testing ():
# write to disk
for file in file_cache.keys():
- f = open(file, "w")
- f.writelines(file_cache[file])
- f.close()
+ with open(file, "w") as f:
+ f.writelines(file_cache[file])
# reset
newTesting = {}
system.reload_settings()
diff --git a/portato/backend/package.py b/portato/backend/package.py
index f86ee13..7fddb21 100644
--- a/portato/backend/package.py
+++ b/portato/backend/package.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import
+from future_builtins import map, filter, zip
from ..helper import debug, paren_reduce
from ..dependency import DependencyTree
diff --git a/portato/backend/portage/__init__.py b/portato/backend/portage/__init__.py
index e559f9e..6a68bbc 100644
--- a/portato/backend/portage/__init__.py
+++ b/portato/backend/portage/__init__.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import
+from future_builtins import map, filter, zip
from ...helper import debug
from portage import VERSION as PV
diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py
index 59ebe1e..5f01cad 100644
--- a/portato/backend/portage/package.py
+++ b/portato/backend/portage/package.py
@@ -10,8 +10,6 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import, with_statement
-
from ..package import Package
from .. import flags
from .. import system
@@ -184,7 +182,7 @@ class PortagePackage (Package):
return []
if deps[0] == 0: # error
- raise DependencyCalcError, deps[1]
+ raise DependencyCalcError(deps[1])
deps = deps[1]
@@ -206,7 +204,7 @@ class PortagePackage (Package):
return []
if deps[0] == 0: # error
- raise DependencyCalcError, deps[1]
+ raise DependencyCalcError(deps[1])
deps = deps[1]
@@ -234,7 +232,7 @@ class PortagePackage (Package):
else:
dep_pkgs.append(dep)
elif blocked:
- raise BlockedException, (self.get_cpv(), blocked[0].get_cpv())
+ raise BlockedException((self.get_cpv(), blocked[0].get_cpv()))
continue # finished with the blocking one -> next
@@ -242,7 +240,7 @@ class PortagePackage (Package):
if not pkg: # try to find masked ones
pkgs = system.find_packages(dep, masked = True)
if not pkgs:
- raise PackageNotFoundException, dep
+ raise PackageNotFoundException(dep)
pkgs = system.sort_package_list(pkgs)
pkgs.reverse()
diff --git a/portato/backend/portage/package_22.py b/portato/backend/portage/package_22.py
index 23e8ed5..61d7364 100644
--- a/portato/backend/portage/package_22.py
+++ b/portato/backend/portage/package_22.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import, with_statement
+
from .package import PortagePackage
diff --git a/portato/backend/portage/sets.py b/portato/backend/portage/sets.py
index c1971b7..7bedf60 100644
--- a/portato/backend/portage/sets.py
+++ b/portato/backend/portage/sets.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import, with_statement
+from future_builtins import map, filter, zip
import re
import itertools as itt
@@ -33,7 +33,7 @@ class Set(object):
try:
t = self.get_pkgs(key, is_regexp, masked, with_version, only_cpv)
# catch the "ambigous package" Exception
- except ValueError, e:
+ except ValueError as e:
if isinstance(e[0], list):
t = set()
for cp in e[0]:
@@ -97,7 +97,7 @@ class InstalledSet (Set):
t = system.settings.vartree.dbapi.cp_all()
if key:
- t = filter(lambda x: re.search(key, x, re.I), t)
+ t = [x for x in t if re.search(key, x, re.I)]
else:
t = system.settings.vartree.dbapi.match(key)
@@ -116,7 +116,7 @@ class TreeSet (Set):
t = system.settings.porttree.dbapi.cp_all()
if key:
- t = filter(lambda x: re.search(key, x, re.I), t)
+ t = [x for x in t if re.search(key, x, re.I)]
return set(t)
diff --git a/portato/backend/portage/settings.py b/portato/backend/portage/settings.py
index 2f3b780..0c857ac 100644
--- a/portato/backend/portage/settings.py
+++ b/portato/backend/portage/settings.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import
+
import os
import portage
diff --git a/portato/backend/portage/settings_22.py b/portato/backend/portage/settings_22.py
index ba4f1e8..253ecaa 100644
--- a/portato/backend/portage/settings_22.py
+++ b/portato/backend/portage/settings_22.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import
+
import portage.sets
from .settings import PortageSettings
diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py
index b882237..7e70f3b 100644
--- a/portato/backend/portage/system.py
+++ b/portato/backend/portage/system.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import, with_statement
+from future_builtins import map, filter, zip
import re, os
import portage
@@ -212,7 +212,7 @@ class PortageSystem (SystemInterface):
result = self._get_set(pkgSet).find(key, masked, with_version, only_cpv)
if (not only_cpv) and with_version:
- result = map(self.new_package, result)
+ result = list(map(self.new_package, result))
else:
result = list(result)
@@ -220,7 +220,7 @@ class PortageSystem (SystemInterface):
def list_categories (self, name = None):
categories = self.settings.global_settings.categories
- return filter(self.find_lambda(name), categories)
+ return list(filter(self.find_lambda(name), categories))
def split_cpv (self, cpv):
cpv = portage.dep_getcpv(cpv)
@@ -292,7 +292,7 @@ class PortageSystem (SystemInterface):
def update_world (self, sets = ("world", "system"), newuse = False, deep = False):
packages = set()
- map(packages.add, itt.chain(*[self.find_packages(pkgSet = s, with_version = False) for s in sets]))
+ list(map(packages.add, itt.chain(*[self.find_packages(pkgSet = s, with_version = False) for s in sets])))
states = [(["RDEPEND", "PDEPEND"], True)]
if self.with_bdeps():
diff --git a/portato/backend/portage/system_22.py b/portato/backend/portage/system_22.py
index c3bfa5f..882232f 100644
--- a/portato/backend/portage/system_22.py
+++ b/portato/backend/portage/system_22.py
@@ -10,8 +10,6 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import, with_statement
-
import os
import portage
@@ -46,7 +44,7 @@ class PortageSystem_22 (PortageSystem):
def get_sets (self, description = False):
if description:
- return ((name, set.description) for name, set in self.settings.setsconfig.getSets().iteritems())
+ return ((name, set.description) for name, set in self.settings.setsconfig.getSets().items())
else:
return tuple(self.settings.setsconfig.getSets())