summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-06-12 10:14:10 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-06-12 10:14:10 +0200
commit2d2ba80ac8aafbfc4f5a2a2ae6490ad994d57d9d (patch)
treee124ac55d34834c03aba5585dd8d566c33667f38
parent6d4ac7f78db22a03f0b4f295fdd7dacd22b7cc48 (diff)
parent1cc440e8426cdd297f73f7322356744d190f58fe (diff)
downloadpython-apt-2d2ba80ac8aafbfc4f5a2a2ae6490ad994d57d9d.tar.gz
merged from lp:~mvo/python-apt/mvo
-rw-r--r--aptsources/distinfo.py18
-rw-r--r--aptsources/distro.py6
-rw-r--r--aptsources/sourceslist.py4
-rw-r--r--debian/changelog19
-rwxr-xr-xpre-build.sh3
-rw-r--r--setup.py4
-rw-r--r--tests/test_utils.py10
-rwxr-xr-xutils/get_ubuntu_mirrors_from_lp.py11
8 files changed, 55 insertions, 20 deletions
diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py
index ddaeb218..e0ee915d 100644
--- a/aptsources/distinfo.py
+++ b/aptsources/distinfo.py
@@ -21,6 +21,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
+from __future__ import print_function
+
import errno
import logging
import os
@@ -51,7 +53,7 @@ class Template(object):
def has_component(self, comp):
''' Check if the distribution provides the given component '''
- return comp in map(lambda c: c.name, self.components)
+ return comp in (c.name for c in self.components)
def is_mirror(self, url):
''' Check if a given url of a repository is a valid mirror '''
@@ -107,7 +109,7 @@ class Mirror(object):
self.repositories.append(Repository(proto, dir))
def get_repositories_for_proto(self, proto):
- return filter(lambda r: r.proto == proto, self.repositories)
+ return [r for r in self.repositories if r.proto == proto]
def has_repository(self, proto, dir):
if dir is None:
@@ -118,7 +120,7 @@ class Mirror(object):
return False
def get_repo_urls(self):
- return map(lambda r: r.get_url(self.hostname), self.repositories)
+ return [r.get_url(self.hostname) for r in self.repositories]
def get_location(self):
return self.location
@@ -230,11 +232,11 @@ class DistInfo(object):
mirror_set = {}
try:
with open(value) as value_f:
- mirror_data = filter(match_mirror_line.match,
- [x.strip() for x in
- value_f])
+ mirror_data = list(filter(
+ match_mirror_line.match,
+ [x.strip() for x in value_f]))
except Exception:
- print "WARNING: Failed to read mirror file"
+ print("WARNING: Failed to read mirror file")
mirror_data = []
for line in mirror_data:
if line.startswith("#LOC:"):
@@ -298,7 +300,7 @@ if __name__ == "__main__":
logging.info("BaseURI: %s" % template.base_uri)
logging.info("MatchURI: %s" % template.match_uri)
if template.mirror_set != {}:
- logging.info("Mirrors: %s" % template.mirror_set.keys())
+ logging.info("Mirrors: %s" % list(template.mirror_set.keys()))
for comp in template.components:
logging.info(" %s -%s -%s" % (comp.name,
comp.description,
diff --git a/aptsources/distro.py b/aptsources/distro.py
index 27d7f859..ca87a919 100644
--- a/aptsources/distro.py
+++ b/aptsources/distro.py
@@ -327,12 +327,14 @@ class Distribution(object):
if s.type == self.binary_type:
if s.dist not in comps_per_dist:
comps_per_dist[s.dist] = set()
- map(comps_per_dist[s.dist].add, s.comps)
+ for c in s.comps:
+ comps_per_dist[s.dist].add(c)
for s in self.source_code_sources:
if s.type == self.source_type:
if s.dist not in comps_per_sdist:
comps_per_sdist[s.dist] = set()
- map(comps_per_sdist[s.dist].add, s.comps)
+ for c in s.comps:
+ comps_per_sdist[s.dist].add(c)
# check if there is a main source at all
if len(self.main_sources) < 1:
diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py
index 03377258..61b75f75 100644
--- a/aptsources/sourceslist.py
+++ b/aptsources/sourceslist.py
@@ -23,6 +23,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
+from __future__ import absolute_import
+
import glob
import logging
import os.path
@@ -31,7 +33,7 @@ import shutil
import time
import apt_pkg
-from distinfo import DistInfo
+from .distinfo import DistInfo
from apt.deprecation import function_deprecated_by
#from apt_pkg import gettext as _
diff --git a/debian/changelog b/debian/changelog
index b40aae0e..41683a27 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,12 @@ python-apt (0.8.5) UNRELEASED; urgency=low
[ Evan Dandrea ]
* Don't leak file descriptors.
+
+ [ Steve Langasek ]
+ * utils/get_ubuntu_mirrors_from_lp.py: move this script to python3
+ * pre-build.sh: call dpkg-checkbuilddeps with the list of our
+ source-build-dependencies; this may save someone else an hour down the
+ line scratching their head over gratuitous test-suite failures...
-- Michael Vogt <mvo@debian.org> Tue, 17 Apr 2012 14:09:24 +0200
@@ -51,6 +57,19 @@ python-apt (0.8.4~exp1) experimental; urgency=low
-- Michael Vogt <mvo@debian.org> Tue, 24 Jan 2012 14:02:46 +0100
+python-apt (0.8.3ubuntu9) UNRELEASED; urgency=low
+
+ [ Steve Langasek ]
+ * Don't leak file descriptors.
+
+ [ Colin Watson ]
+ * aptsources/*.py, setup.py: Make aptsources modules work directly in
+ either Python 2 or 3, and exclude the "future" 2to3 fixer so that 2to3
+ doesn't need to modify them. This makes life a little easier for the
+ strange tricks update-manager plays with its dist-upgrader tarball.
+
+ -- Evan Dandrea <ev@ubuntu.com> Mon, 11 Jun 2012 17:00:37 +0100
+
python-apt (0.8.3) unstable; urgency=low
[ Alexey Feldgendler ]
diff --git a/pre-build.sh b/pre-build.sh
index 026a491e..08c0bef6 100755
--- a/pre-build.sh
+++ b/pre-build.sh
@@ -1,4 +1,7 @@
#!/bin/sh
+set -e
+
+dpkg-checkbuilddeps -d 'python-debian, python3-feedparser'
echo "updating Ubuntu mirror list from launchpad"
if [ -n "$https_proxy" ]; then
diff --git a/setup.py b/setup.py
index eff78379..8af5c2a6 100644
--- a/setup.py
+++ b/setup.py
@@ -25,7 +25,11 @@ except ImportError:
if sys.version_info[0] == 3:
from distutils.command.build_py import build_py_2to3
+ from lib2to3.refactor import get_fixers_from_package
cmdclass['build_py'] = build_py_2to3
+ cmdclass['build_py'].fixer_names = sorted(
+ set(get_fixers_from_package("lib2to3.fixes")) -
+ set(["lib2to3.fixes.fix_future"]))
# The apt_pkg module.
files = ['apt_pkgmodule.cc', 'acquire.cc', 'cache.cc', 'cdrom.cc',
diff --git a/tests/test_utils.py b/tests/test_utils.py
index dc54c1ba..2676bb98 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -6,11 +6,13 @@
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
+import datetime
+import os
import sys
+import unittest
+
import apt_pkg
import apt.utils
-import datetime
-import unittest
from apt.utils import (
get_maintenance_end_date,
@@ -20,7 +22,9 @@ from apt.utils import (
class TestUtils(unittest.TestCase):
def test_get_release_date_from_release_file(self):
- t = get_release_date_from_release_file("./tests/data/misc/foo_Release")
+ path = os.path.join(os.path.dirname(__file__),
+ "data", "misc", "foo_Release")
+ t = get_release_date_from_release_file(path)
self.assertEqual(str(datetime.datetime.utcfromtimestamp(t)),
"2012-04-25 22:49:23")
diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py
index ed0ee936..7c4d3831 100755
--- a/utils/get_ubuntu_mirrors_from_lp.py
+++ b/utils/get_ubuntu_mirrors_from_lp.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# get_ubuntu_lp_mirrors.py
#
@@ -40,9 +40,8 @@ for entry in d.entries:
countries[countrycode].add(link.href)
-keys = countries.keys()
-keys.sort()
-print "mirror://mirrors.ubuntu.com/mirrors.txt"
+keys = sorted(countries)
+print("mirror://mirrors.ubuntu.com/mirrors.txt")
for country in keys:
- print "#LOC:%s" % country
- print "\n".join(sorted(countries[country]))
+ print("#LOC:%s" % country)
+ print("\n".join(sorted(countries[country])))