diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2015-08-29 21:48:39 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2015-08-29 21:48:39 +0100 |
commit | 6b977589fb8820f76fe3a89093b4831bf6092106 (patch) | |
tree | d31ebcb352ce7870b80270a1b29b4ff525f296a9 /debian/lib/python/debian_linux/debian.py | |
parent | 32fff0de75a42990e771b57814ae3e7797453e4f (diff) | |
download | kernel_replicant_linux-6b977589fb8820f76fe3a89093b4831bf6092106.tar.gz kernel_replicant_linux-6b977589fb8820f76fe3a89093b4831bf6092106.tar.bz2 kernel_replicant_linux-6b977589fb8820f76fe3a89093b4831bf6092106.zip |
debian/bin,debian/control,debian/lib/python: Use Python 3
Diffstat (limited to 'debian/lib/python/debian_linux/debian.py')
-rw-r--r-- | debian/lib/python/debian_linux/debian.py | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/debian/lib/python/debian_linux/debian.py b/debian/lib/python/debian_linux/debian.py index 936a9ab94e60..00db2c316d08 100644 --- a/debian/lib/python/debian_linux/debian.py +++ b/debian/lib/python/debian_linux/debian.py @@ -1,8 +1,6 @@ import collections import os.path import re -import six -import six.moves from . import utils @@ -36,10 +34,7 @@ class Changelog(list): def __init__(self, dir='', version=None): if version is None: version = Version - if six.PY3: - f = open(os.path.join(dir, "debian/changelog"), encoding="UTF-8") - else: - f = open(os.path.join(dir, "debian/changelog")) + f = open(os.path.join(dir, "debian/changelog"), encoding="UTF-8") while True: line = f.readline() if not line: @@ -88,7 +83,6 @@ $ def __str__(self): return self.complete - __unicode__ = __str__ @property def complete(self): @@ -164,7 +158,7 @@ $ self.linux_version = d['version'] if d['modifier'] is not None: assert not d['update'] - self.linux_upstream = u'-'.join((d['version'], d['modifier'])) + self.linux_upstream = '-'.join((d['version'], d['modifier'])) else: self.linux_upstream = d['version'] self.linux_upstream_full = self.linux_upstream + d['update'] @@ -193,8 +187,7 @@ class PackageArchitecture(collections.MutableSet): return self._data.__len__() def __str__(self): - return u' '.join(sorted(self)) - __unicode__ = __str__ + return ' '.join(sorted(self)) def add(self, value): self._data.add(value) @@ -203,7 +196,7 @@ class PackageArchitecture(collections.MutableSet): self._data.discard(value) def extend(self, value): - if isinstance(value, six.string_types): + if isinstance(value, str): for i in re.split('\s', value.strip()): self.add(i) else: @@ -223,13 +216,12 @@ class PackageDescription(object): def __str__(self): wrap = utils.TextWrapper(width=74, fix_sentence_endings=True).wrap - short = u', '.join(self.short) + short = ', '.join(self.short) long_pars = [] for i in self.long: long_pars.append(wrap(i)) - long = u'\n .\n '.join([u'\n '.join(i) for i in long_pars]) - return short + u'\n ' + long - __unicode__ = __str__ + long = '\n .\n '.join(['\n '.join(i) for i in long_pars]) + return short + '\n ' + long def append(self, str): str = str.strip() @@ -255,8 +247,7 @@ class PackageRelation(list): self.extend(value, override_arches) def __str__(self): - return u', '.join(six.text_type(i) for i in self) - __unicode__ = __str__ + return ', '.join(str(i) for i in self) def _search_value(self, value): for i in self: @@ -265,7 +256,7 @@ class PackageRelation(list): return None def append(self, value, override_arches=None): - if isinstance(value, six.string_types): + if isinstance(value, str): value = PackageRelationGroup(value, override_arches) elif not isinstance(value, PackageRelationGroup): raise ValueError(u"got %s" % type(value)) @@ -276,8 +267,8 @@ class PackageRelation(list): super(PackageRelation, self).append(value) def extend(self, value, override_arches=None): - if isinstance(value, six.string_types): - value = (j.strip() for j in re.split(u',', value.strip())) + if isinstance(value, str): + value = (j.strip() for j in re.split(',', value.strip())) for i in value: self.append(i, override_arches) @@ -288,31 +279,30 @@ class PackageRelationGroup(list): self.extend(value, override_arches) def __str__(self): - return u' | '.join(six.text_type(i) for i in self) - __unicode__ = __str__ + return ' | '.join(str(i) for i in self) def _search_value(self, value): - for i, j in six.moves.zip(self, value): + for i, j in zip(self, value): if i.name != j.name or i.version != j.version: return None return self def _update_arches(self, value): - for i, j in six.moves.zip(self, value): + for i, j in zip(self, value): if i.arches: for arch in j.arches: if arch not in i.arches: i.arches.append(arch) def append(self, value, override_arches=None): - if isinstance(value, six.string_types): + if isinstance(value, str): value = PackageRelationEntry(value, override_arches) elif not isinstance(value, PackageRelationEntry): raise ValueError super(PackageRelationGroup, self).append(value) def extend(self, value, override_arches=None): - if isinstance(value, six.string_types): + if isinstance(value, str): value = (j.strip() for j in re.split('\|', value.strip())) for i in value: self.append(i, override_arches) @@ -332,12 +322,12 @@ class PackageRelationEntry(object): OP_GT = 6 operators = { - u'<<': OP_LT, - u'<=': OP_LE, - u'=': OP_EQ, - u'!=': OP_NE, - u'>=': OP_GE, - u'>>': OP_GT, + '<<': OP_LT, + '<=': OP_LE, + '=': OP_EQ, + '!=': OP_NE, + '>=': OP_GE, + '>>': OP_GT, } operators_neg = { @@ -361,10 +351,9 @@ class PackageRelationEntry(object): def __str__(self): return self.operators_text[self._op] - __unicode__ = __str__ def __init__(self, value=None, override_arches=None): - if not isinstance(value, six.string_types): + if not isinstance(value, str): raise ValueError self.parse(value) @@ -375,11 +364,10 @@ class PackageRelationEntry(object): def __str__(self): ret = [self.name] if self.operator is not None and self.version is not None: - ret.extend((u' (', six.text_type(self.operator), u' ', self.version, u')')) + ret.extend((' (', str(self.operator), ' ', self.version, ')')) if self.arches: - ret.extend((u' [', u' '.join(self.arches), u']')) - return u''.join(ret) - __unicode__ = __str__ + ret.extend((' [', ' '.join(self.arches), ']')) + return ''.join(ret) def parse(self, value): match = self._re.match(value) @@ -400,14 +388,14 @@ class PackageRelationEntry(object): class Package(dict): _fields = collections.OrderedDict(( - ('Package', six.text_type), - ('Source', six.text_type), + ('Package', str), + ('Source', str), ('Architecture', PackageArchitecture), - ('Section', six.text_type), - ('Priority', six.text_type), - ('Maintainer', six.text_type), - ('Uploaders', six.text_type), - ('Standards-Version', six.text_type), + ('Section', str), + ('Priority', str), + ('Maintainer', str), + ('Uploaders', str), + ('Standards-Version', str), ('Build-Depends', PackageRelation), ('Build-Depends-Indep', PackageRelation), ('Provides', PackageRelation), |