Remove dependency on six

Signed-off-by: Julien Cristau <jcristau@debian.org>
master
Julien Cristau 9 years ago committed by Niels Thykier
parent 354f6a6bc9
commit 6c344589ee

@ -193,7 +193,7 @@ from functools import reduce, partial
from itertools import chain, product from itertools import chain, product
from operator import attrgetter from operator import attrgetter
from six.moves import filter as ifilter, intern, urllib_parse as urllib from urllib.parse import quote
from installability.builder import InstallabilityTesterBuilder from installability.builder import InstallabilityTesterBuilder
from excuse import Excuse from excuse import Excuse
@ -388,7 +388,7 @@ class Britney(object):
arches += [x for x in allarches if x not in arches and x not in self.options.break_arches.split()] arches += [x for x in allarches if x not in arches and x not in self.options.break_arches.split()]
arches += [x for x in allarches if x not in arches and x not in self.options.new_arches.split()] arches += [x for x in allarches if x not in arches and x not in self.options.new_arches.split()]
arches += [x for x in allarches if x not in arches] arches += [x for x in allarches if x not in arches]
self.options.architectures = [intern(arch) for arch in arches] self.options.architectures = [sys.intern(arch) for arch in arches]
self.options.smooth_updates = self.options.smooth_updates.split() self.options.smooth_updates = self.options.smooth_updates.split()
def __log(self, msg, type="I"): def __log(self, msg, type="I"):
@ -447,7 +447,7 @@ class Britney(object):
# the package name extracted from the field and is therefore # the package name extracted from the field and is therefore
# not interned. # not interned.
pdata = binaries[dep_dist][arch][0][p] pdata = binaries[dep_dist][arch][0][p]
pt = (intern(p), pdata[VERSION], arch) pt = (sys.intern(p), pdata[VERSION], arch)
if dep: if dep:
sat.add(pt) sat.add(pt)
elif t != pt: elif t != pt:
@ -494,7 +494,7 @@ class Britney(object):
# Data reading/writing methods # Data reading/writing methods
# ---------------------------- # ----------------------------
def read_sources(self, basedir, intern=intern): def read_sources(self, basedir, intern=sys.intern):
"""Read the list of source packages from the specified directory """Read the list of source packages from the specified directory
The source packages are read from the `Sources' file within the The source packages are read from the `Sources' file within the
@ -533,7 +533,7 @@ class Britney(object):
] ]
return sources return sources
def read_binaries(self, basedir, distribution, arch, intern=intern): def read_binaries(self, basedir, distribution, arch, intern=sys.intern):
"""Read the list of binary packages from the specified directory """Read the list of binary packages from the specified directory
The binary packages are read from the `Packages_${arch}' files The binary packages are read from the `Packages_${arch}' files
@ -1081,7 +1081,7 @@ class Britney(object):
anyworthdoing = False anyworthdoing = False
# for every binary package produced by this source in unstable for this architecture # for every binary package produced by this source in unstable for this architecture
for pkg in sorted(ifilter(lambda x: x.endswith("/" + arch), source_u[BINARIES]), key=lambda x: x.split("/")[0]): for pkg in sorted(filter(lambda x: x.endswith("/" + arch), source_u[BINARIES]), key=lambda x: x.split("/")[0]):
pkg_name = pkg.split("/")[0] pkg_name = pkg.split("/")[0]
# retrieve the testing (if present) and unstable corresponding binary packages # retrieve the testing (if present) and unstable corresponding binary packages
@ -1343,7 +1343,7 @@ class Britney(object):
base = 'testing' base = 'testing'
else: else:
base = 'stable' base = 'stable'
text = "Not yet built on <a href=\"http://buildd.debian.org/status/logs.php?arch=%s&pkg=%s&ver=%s&suite=%s\" target=\"_blank\">%s</a> (relative to testing)" % (urllib.quote(arch), urllib.quote(src), urllib.quote(source_u[VERSION]), base, arch) text = "Not yet built on <a href=\"http://buildd.debian.org/status/logs.php?arch=%s&pkg=%s&ver=%s&suite=%s\" target=\"_blank\">%s</a> (relative to testing)" % (quote(arch), quote(src), quote(source_u[VERSION]), base, arch)
if arch in self.options.fucked_arches.split(): if arch in self.options.fucked_arches.split():
text = text + " (but %s isn't keeping up, so never mind)" % (arch) text = text + " (but %s isn't keeping up, so never mind)" % (arch)
@ -1396,15 +1396,15 @@ class Britney(object):
if oodtxt: oodtxt = oodtxt + "; " if oodtxt: oodtxt = oodtxt + "; "
oodtxt = oodtxt + "%s (from <a href=\"http://buildd.debian.org/status/logs.php?" \ oodtxt = oodtxt + "%s (from <a href=\"http://buildd.debian.org/status/logs.php?" \
"arch=%s&pkg=%s&ver=%s\" target=\"_blank\">%s</a>)" % \ "arch=%s&pkg=%s&ver=%s\" target=\"_blank\">%s</a>)" % \
(", ".join(sorted(oodbins[v])), urllib.quote(arch), urllib.quote(src), urllib.quote(v), v) (", ".join(sorted(oodbins[v])), quote(arch), quote(src), quote(v), v)
if uptodatebins: if uptodatebins:
text = "old binaries left on <a href=\"http://buildd.debian.org/status/logs.php?" \ text = "old binaries left on <a href=\"http://buildd.debian.org/status/logs.php?" \
"arch=%s&pkg=%s&ver=%s\" target=\"_blank\">%s</a>: %s" % \ "arch=%s&pkg=%s&ver=%s\" target=\"_blank\">%s</a>: %s" % \
(urllib.quote(arch), urllib.quote(src), urllib.quote(source_u[VERSION]), arch, oodtxt) (quote(arch), quote(src), quote(source_u[VERSION]), arch, oodtxt)
else: else:
text = "missing build on <a href=\"http://buildd.debian.org/status/logs.php?" \ text = "missing build on <a href=\"http://buildd.debian.org/status/logs.php?" \
"arch=%s&pkg=%s&ver=%s\" target=\"_blank\">%s</a>: %s" % \ "arch=%s&pkg=%s&ver=%s\" target=\"_blank\">%s</a>: %s" % \
(urllib.quote(arch), urllib.quote(src), urllib.quote(source_u[VERSION]), arch, oodtxt) (quote(arch), quote(src), quote(source_u[VERSION]), arch, oodtxt)
if arch in self.options.fucked_arches.split(): if arch in self.options.fucked_arches.split():
text = text + " (but %s isn't keeping up, so nevermind)" % (arch) text = text + " (but %s isn't keeping up, so nevermind)" % (arch)
@ -1454,15 +1454,15 @@ class Britney(object):
if len(new_bugs) > 0: if len(new_bugs) > 0:
excuse.addhtml("%s (%s) <a href=\"http://bugs.debian.org/cgi-bin/pkgreport.cgi?" \ excuse.addhtml("%s (%s) <a href=\"http://bugs.debian.org/cgi-bin/pkgreport.cgi?" \
"which=pkg&data=%s&sev-inc=critical&sev-inc=grave&sev-inc=serious\" " \ "which=pkg&data=%s&sev-inc=critical&sev-inc=grave&sev-inc=serious\" " \
"target=\"_blank\">has new bugs</a>!" % (pkg, ", ".join(pkgs[pkg]), urllib.quote(pkg))) "target=\"_blank\">has new bugs</a>!" % (pkg, ", ".join(pkgs[pkg]), quote(pkg)))
excuse.addhtml("Updating %s introduces new bugs: %s" % (pkg, ", ".join( excuse.addhtml("Updating %s introduces new bugs: %s" % (pkg, ", ".join(
["<a href=\"http://bugs.debian.org/%s\">#%s</a>" % (urllib.quote(a), a) for a in new_bugs]))) ["<a href=\"http://bugs.debian.org/%s\">#%s</a>" % (quote(a), a) for a in new_bugs])))
update_candidate = False update_candidate = False
excuse.addreason("buggy") excuse.addreason("buggy")
if len(old_bugs) > 0: if len(old_bugs) > 0:
excuse.addhtml("Updating %s fixes old bugs: %s" % (pkg, ", ".join( excuse.addhtml("Updating %s fixes old bugs: %s" % (pkg, ", ".join(
["<a href=\"http://bugs.debian.org/%s\">#%s</a>" % (urllib.quote(a), a) for a in old_bugs]))) ["<a href=\"http://bugs.debian.org/%s\">#%s</a>" % (quote(a), a) for a in old_bugs])))
if len(old_bugs) > len(new_bugs) and len(new_bugs) > 0: if len(old_bugs) > len(new_bugs) and len(new_bugs) > 0:
excuse.addhtml("%s introduces new bugs, so still ignored (even " excuse.addhtml("%s introduces new bugs, so still ignored (even "
"though it fixes more than it introduces, whine at debian-release)" % pkg) "though it fixes more than it introduces, whine at debian-release)" % pkg)

@ -24,16 +24,12 @@
import apt_pkg import apt_pkg
from functools import partial from functools import partial
from datetime import datetime from datetime import datetime
from itertools import chain, repeat from itertools import chain, repeat, filterfalse
import os import os
import re import re
import time import time
import yaml import yaml
from six.moves import (filter as ifilter,
filterfalse as ifilterfalse,
zip as izip)
from migrationitem import MigrationItem, UnversionnedMigrationItem from migrationitem import MigrationItem, UnversionnedMigrationItem
from consts import (VERSION, BINARIES, PROVIDES, DEPENDS, CONFLICTS, from consts import (VERSION, BINARIES, PROVIDES, DEPENDS, CONFLICTS,
@ -75,8 +71,8 @@ def ifilter_except(container, iterable=None):
iterators that are not known on beforehand. iterators that are not known on beforehand.
""" """
if iterable is not None: if iterable is not None:
return ifilterfalse(container.__contains__, iterable) return filterfalse(container.__contains__, iterable)
return partial(ifilterfalse, container.__contains__) return partial(filterfalse, container.__contains__)
def ifilter_only(container, iterable=None): def ifilter_only(container, iterable=None):
@ -88,8 +84,8 @@ def ifilter_only(container, iterable=None):
iterators that are not known on beforehand. iterators that are not known on beforehand.
""" """
if iterable is not None: if iterable is not None:
return ifilter(container.__contains__, iterable) return filter(container.__contains__, iterable)
return partial(ifilter, container.__contains__) return partial(filter, container.__contains__)
# iter_except is from the "itertools" recipe # iter_except is from the "itertools" recipe
@ -301,7 +297,7 @@ def compute_reverse_tree(packages_s, pkg, arch,
# generate the next iteration, which is the reverse-dependencies of # generate the next iteration, which is the reverse-dependencies of
# the current iteration # the current iteration
rev_deps = set(revfilt(flatten( binaries[x][RDEPENDS] for x in binfilt(rev_deps) ))) rev_deps = set(revfilt(flatten( binaries[x][RDEPENDS] for x in binfilt(rev_deps) )))
return izip(seen, repeat(arch)) return zip(seen, repeat(arch))
def write_nuninst(filename, nuninst): def write_nuninst(filename, nuninst):

@ -15,7 +15,6 @@
# GNU General Public License for more details. # GNU General Public License for more details.
import re import re
import six
class Excuse(object): class Excuse(object):
"""Excuse class """Excuse class
@ -181,13 +180,6 @@ class Excuse(object):
(self.name, self.ver[0], self.ver[1])) (self.name, self.ver[0], self.ver[1]))
if self.maint: if self.maint:
maint = self.maint maint = self.maint
# ugly hack to work around strange encoding in pyyaml
# should go away with pyyaml in python 3
if isinstance(maint, six.binary_type):
try:
maint.decode('ascii')
except UnicodeDecodeError:
maint = six.string_type(self.maint,'utf-8')
res.append("Maintainer: %s" % maint) res.append("Maintainer: %s" % maint)
if self.section and self.section.find("/") > -1: if self.section and self.section.find("/") > -1:
res.append("Section: %s" % (self.section)) res.append("Section: %s" % (self.section))

@ -13,8 +13,7 @@
# GNU General Public License for more details. # GNU General Public License for more details.
from functools import partial from functools import partial
from itertools import filterfalse
from six.moves import filter as ifilter, filterfalse as ifilterfalse
from britney_util import iter_except from britney_util import iter_except
@ -85,7 +84,7 @@ class InstallabilityTester(object):
eqv_table = self._eqv_table eqv_table = self._eqv_table
testing = self._testing testing = self._testing
tcopy = [x for x in testing] tcopy = [x for x in testing]
for t in ifilterfalse(cache_inst.__contains__, tcopy): for t in filterfalse(cache_inst.__contains__, tcopy):
if t in cbroken: if t in cbroken:
continue continue
res = check_inst(t) res = check_inst(t)
@ -300,7 +299,7 @@ class InstallabilityTester(object):
# We already satisfied/chosen at least one of the litterals # We already satisfied/chosen at least one of the litterals
# in the choice, so the choice is gone # in the choice, so the choice is gone
for choice in ifilter(musts.isdisjoint, choices): for choice in filter(musts.isdisjoint, choices):
# cbroken is needed here because (in theory) it could # cbroken is needed here because (in theory) it could
# have changed since the choice was discovered and it # have changed since the choice was discovered and it
# is smaller than testing (so presumably faster) # is smaller than testing (so presumably faster)
@ -308,7 +307,7 @@ class InstallabilityTester(object):
if len(remain) > 1 and not remain.isdisjoint(safe_set): if len(remain) > 1 and not remain.isdisjoint(safe_set):
first = None first = None
for r in ifilter(safe_set.__contains__, remain): for r in filter(safe_set.__contains__, remain):
# don't bother giving extra arguments to _check_inst. "safe" packages are # don't bother giving extra arguments to _check_inst. "safe" packages are
# usually trivial to satisfy on their own and will not involve conflicts # usually trivial to satisfy on their own and will not involve conflicts
# (so never will not help) # (so never will not help)
@ -432,7 +431,7 @@ class InstallabilityTester(object):
returns True, then t is installable. returns True, then t is installable.
""" """
# Local variables for faster access... # Local variables for faster access...
not_satisfied = partial(ifilter, musts.isdisjoint) not_satisfied = partial(filter, musts.isdisjoint)
# While we have guaranteed dependencies (in check), examine all # While we have guaranteed dependencies (in check), examine all
# of them. # of them.
@ -520,7 +519,7 @@ class InstallabilityTester(object):
start = set(ess_base) start = set(ess_base)
ess_never = set() ess_never = set()
ess_choices = set() ess_choices = set()
not_satisified = partial(ifilter, start.isdisjoint) not_satisified = partial(filter, start.isdisjoint)
while ess_base: while ess_base:
self._check_loop(universe, testing, eqv_table, self._check_loop(universe, testing, eqv_table,

Loading…
Cancel
Save