From 1e5da010ab8cb514b495eb7c1d3afce6baec7f4d Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Fri, 28 Oct 2022 12:42:00 +0900 Subject: [PATCH] port code from python2.x to python3.x Change-Id: I798c72d07e44839cc5d1e25ec75fca0bd8068567 Signed-off-by: biao716.wang --- debian/control | 21 ++++---- debian/git-buildpackage-bb.install | 4 +- debian/git-buildpackage-common.docs | 1 - debian/not-installed | 7 +++ debian/rules | 6 +-- examples/zeitgeist-git.py | 10 ++-- gbp/bb/__init__.py | 6 +-- gbp/config.py | 6 +-- gbp/deb/changelog.py | 8 +-- gbp/deb/control.py | 2 +- gbp/deb/source.py | 2 +- gbp/git/args.py | 2 +- gbp/git/modifier.py | 4 +- gbp/git/repository.py | 10 ++-- gbp/git/vfs.py | 4 +- gbp/log.py | 4 +- gbp/patch_series.py | 2 +- gbp/pkg/__init__.py | 9 ++-- gbp/rpm/__init__.py | 30 +++++------ gbp/rpm/linkedlist.py | 14 ++--- gbp/rpm/policy.py | 2 +- gbp/scripts/buildpackage.py | 8 +-- gbp/scripts/buildpackage_bb.py | 12 ++--- gbp/scripts/buildpackage_rpm.py | 10 ++-- gbp/scripts/clone.py | 4 +- gbp/scripts/clone_bb.py | 4 +- gbp/scripts/common/import_orig.py | 4 +- gbp/scripts/common/pq.py | 10 ++-- gbp/scripts/config.py | 4 +- gbp/scripts/create_remote_repo.py | 26 ++++----- gbp/scripts/dch.py | 14 ++--- gbp/scripts/import_bb.py | 6 +-- gbp/scripts/import_dsc.py | 6 +-- gbp/scripts/import_dscs.py | 6 +-- gbp/scripts/import_orig.py | 4 +- gbp/scripts/import_orig_rpm.py | 6 +-- gbp/scripts/import_srpm.py | 14 ++--- gbp/scripts/pq.py | 6 +-- gbp/scripts/pq_bb.py | 6 +-- gbp/scripts/pq_rpm.py | 14 ++--- gbp/scripts/pull.py | 4 +- gbp/scripts/rpm_ch.py | 12 ++--- gbp/scripts/submit_bb.py | 8 +-- gbp/scripts/supercommand.py | 14 ++--- gbp/tristate.py | 4 +- packaging/PKGBUILD | 10 ++-- packaging/git-buildpackage.spec | 81 ++++++++++++++-------------- setup.py | 6 +-- tests/02_test_upstream_source_tar_unpack.py | 8 +-- tests/03_test_dch_guess_version.py | 2 +- tests/09_test_write_tree.py | 2 +- tests/14_test_gbp_import_dscs.py | 2 +- tests/15_test_DebianSource.py | 2 +- tests/17_test_dch_guess_documented_commit.py | 2 +- tests/19_test_gbp_scripts_config.py | 2 +- tests/component/__init__.py | 2 +- tests/component/rpm/__init__.py | 2 +- tests/component/rpm/test_import_orig_rpm.py | 4 +- tests/component/rpm/test_import_srpm.py | 10 ++-- tests/test_GitRepository.py | 4 +- tests/test_import_orig.py | 6 +-- tests/test_rpm.py | 2 +- 62 files changed, 257 insertions(+), 250 deletions(-) create mode 100644 debian/not-installed diff --git a/debian/control b/debian/control index 34cc097..5d13d2f 100755 --- a/debian/control +++ b/debian/control @@ -4,20 +4,21 @@ Priority: optional Maintainer: Guido Günther Build-Depends: bash-completion, + dh-python, debhelper (>= 9~), docbook-utils, gtk-doc-tools, openjade, perl, - python (>> 2.6.6-3~), + python3, python-epydoc | pydoctor | python-pydoctor, - python-nose, - python-pkg-resources, - python-setuptools, + python3-nose, + python3-pkg-resources, + python3-setuptools, sgml2x, librpm-tizen, # For rpm (epydoc) - python-rpm + python3-rpm Standards-Version: 3.9.4 Vcs-Git: git://honk.sigxcpu.org/git/git-buildpackage.git Vcs-Browser: https://honk.sigxcpu.org/gitweb/?p=git-buildpackage.git @@ -27,12 +28,12 @@ X-Python-Version: >= 2.6 Package: git-buildpackage-common Architecture: all -Depends: ${python:Depends}, +Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, git (>= 1:1.7.9.1-1~), man-db, - python-pkg-resources, + python3-pkg-resources, #unittest need zipmerge Recommends: pristine-tar (>= 0.5) @@ -42,7 +43,7 @@ Description: Suite to help with packaging in Git repositories Package: git-buildpackage Architecture: all -Depends: ${python:Depends}, +Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, devscripts, @@ -62,7 +63,7 @@ Description: Suite to help with Debian packages in Git repositories Package: git-buildpackage-rpm Architecture: all -Depends: ${python:Depends}, +Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, python-rpm, @@ -80,7 +81,7 @@ Description: Suite to help with rpm packages in Git repositories Package: git-buildpackage-bb Architecture: all -Depends: ${python:Depends}, +Depends: ${python3:Depends}, ${misc:Depends}, git-buildpackage-common (= ${binary:Version}), git-buildpackage-rpm (= ${binary:Version}), diff --git a/debian/git-buildpackage-bb.install b/debian/git-buildpackage-bb.install index 39b39af..c76b64b 100644 --- a/debian/git-buildpackage-bb.install +++ b/debian/git-buildpackage-bb.install @@ -1,2 +1,2 @@ -usr/lib/python2.?/dist-packages/gbp/bb/ -usr/lib/python2.?/dist-packages/gbp/scripts/*bb*.py* +usr/lib/python*/dist-packages/gbp/bb/ +usr/lib/python*/dist-packages/gbp/scripts/*bb*.py* diff --git a/debian/git-buildpackage-common.docs b/debian/git-buildpackage-common.docs index ce06068..7fdec51 100644 --- a/debian/git-buildpackage-common.docs +++ b/debian/git-buildpackage-common.docs @@ -1,3 +1,2 @@ README docs/manual-html/ -build/apidocs/ diff --git a/debian/not-installed b/debian/not-installed new file mode 100644 index 0000000..e5804d0 --- /dev/null +++ b/debian/not-installed @@ -0,0 +1,7 @@ +debian/tmp/usr/lib/python3.*/dist-packages/gbp/deb/__pycache__ +debian/tmp/usr/lib/python3.*/dist-packages/gbp/git/__pycache__ +debian/tmp/usr/lib/python3.*/dist-packages/gbp/pkg/__pycache__ +debian/tmp/usr/lib/python3.*/dist-packages/gbp/__pycache__ +debian/tmp/usr/lib/python3.*/dist-packages/gbp/rpm/__pycache__ +debian/tmp/usr/lib/python3.*/dist-packages/gbp/scripts/common/__pycache__ +debian/tmp/usr/lib/python3.*/dist-packages/gbp/scripts/__pycache__ diff --git a/debian/rules b/debian/rules index 434e58c..91265d4 100755 --- a/debian/rules +++ b/debian/rules @@ -18,7 +18,7 @@ ZSH_COMPDIR = /usr/share/zsh/vendor-completions/ PYCHECKER_ARGS=-boptparse --no-override --no-shadowbuiltin %: - dh $@ --with python2 + dh $@ --with python3 --buildsystem=pybuild override_dh_auto_test: ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) @@ -28,7 +28,7 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) export GIT_COMMITTER_NAME=$$GIT_AUTHOR_NAME; \ export GIT_COMMITTER_EMAIL=$$GIT_AUTHOR_EMAIL; \ PYTHONPATH=. \ - python setup.py nosetests + python3 setup.py nosetests else @echo "Checks disabled via DEB_BUILD_OPTIONS" @@ -38,7 +38,7 @@ override_dh_auto_build: dh_auto_build make -C docs #generate apidocs - sh gen_apidocs.sh + #sh gen_apidocs.sh override_dh_auto_install: dh_auto_install dh_bash-completion diff --git a/examples/zeitgeist-git.py b/examples/zeitgeist-git.py index 4edd946..92f72d8 100755 --- a/examples/zeitgeist-git.py +++ b/examples/zeitgeist-git.py @@ -48,7 +48,7 @@ else: try: CLIENT = ZeitgeistClient() except RuntimeError as e: - print "Unable to connect to Zeitgeist, won't send events. Reason: '%s'" %e + print("Unable to connect to Zeitgeist, won't send events. Reason: '%s'" %e) def get_repo(): @@ -64,10 +64,10 @@ def get_repo(): else: sep = ':' try: - repo = unicode(uri.rsplit(sep, 1)[1]) + repo = str(uri.rsplit(sep, 1)[1]) except IndexError: # no known separator repo = uri - repo = repo.rsplit(u'.git', 1)[0] + repo = repo.rsplit('.git', 1)[0] return repo, uri @@ -78,11 +78,11 @@ def main(argv): # * branch # * log summary (git log -1 --format=%s HEAD) curdir = os.path.abspath(os.curdir).decode(sys.getfilesystemencoding()) - uri = u"file://%s" % curdir + uri = "file://%s" % curdir repo, origin = get_repo() if not repo: - repo = unicode(curdir.rsplit('/', 1)[1]) + repo = str(curdir.rsplit('/', 1)[1]) origin = uri subject = Subject.new_for_values( diff --git a/gbp/bb/__init__.py b/gbp/bb/__init__.py index d6f205b..60204b7 100644 --- a/gbp/bb/__init__.py +++ b/gbp/bb/__init__.py @@ -42,8 +42,8 @@ def import_bb(): try: return __import__('bb') except ImportError: - print "ERROR: Unable to find bitbake/lib, try initializing build " \ - "environment with the 'oe-init-build-env' script\n" + print("ERROR: Unable to find bitbake/lib, try initializing build " \ + "environment with the 'oe-init-build-env' script\n") # Return None instead of raising (ImportError) so that building of # this package succeeds in Debian. Otherwise dpkg-buildpackage fails # because of an import error in epydoc. @@ -257,7 +257,7 @@ class BBFile(object): if match and match.group('name') == var: if not self.was_set: self.was_set = True - print "Setting value %s = %s" % (var, val) + print("Setting value %s = %s" % (var, val)) return ['%s = "%s"\n' % (var, val)] else: return [] diff --git a/gbp/config.py b/gbp/config.py index 267400c..0f0bdc6 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -17,7 +17,7 @@ """handles command line and config file option parsing for the gbp commands""" from optparse import OptionParser, OptionGroup, Option, OptionValueError -from ConfigParser import SafeConfigParser, NoSectionError +from configparser import SafeConfigParser, NoSectionError from copy import copy import os.path import tempfile @@ -427,11 +427,11 @@ class GbpOptionParser(OptionParser): if parser.has_section(cmd): # Don't use items() until we got rid of the compat sections # since this pulls in the defaults again - self.config.update(dict(parser._sections[cmd].items())) + self.config.update(dict(list(parser._sections[cmd].items()))) for section in self.sections: if parser.has_section(section): - self.config.update(dict(parser._sections[section].items())) + self.config.update(dict(list(parser._sections[section].items()))) else: raise NoSectionError("Mandatory section [%s] does not exist." % section) diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py index 356f74d..9b3c03b 100644 --- a/gbp/deb/changelog.py +++ b/gbp/deb/changelog.py @@ -166,7 +166,7 @@ class ChangeLog(object): @return: C{True} if the version has an epoch, C{False} otherwise @rtype: C{bool} """ - return self._cp.has_key('Epoch') + return 'Epoch' in self._cp @property def author(self): @@ -264,11 +264,11 @@ class ChangeLog(object): new_cl = open("debian/changelog.bak", "w") for line in old_cl: if line == " * [[[insert-git-dch-commit-message-here]]]\n": - print >> new_cl, " * " + msg[0] + print(" * " + msg[0], file=new_cl) for line in msg[1:]: - print >> new_cl, " " + line + print(" " + line, file=new_cl) else: - print >> new_cl, line, + print(line, end=' ', file=new_cl) os.rename("debian/changelog.bak", "debian/changelog") def add_entry(self, msg, author=None, email=None, dch_options=[]): diff --git a/gbp/deb/control.py b/gbp/deb/control.py index a4cef2f..4ac12cc 100644 --- a/gbp/deb/control.py +++ b/gbp/deb/control.py @@ -50,7 +50,7 @@ class Control(object): with open(filename) as f: control = email.message_from_file(f) - if not control.items(): + if not list(control.items()): raise ParseControlError("Empty or invalid control file or contents") self._control = control diff --git a/gbp/deb/source.py b/gbp/deb/source.py index c740361..938e5a1 100644 --- a/gbp/deb/source.py +++ b/gbp/deb/source.py @@ -51,7 +51,7 @@ class DebianSource(object): """ self._changelog = None - if isinstance(vfs, basestring): + if isinstance(vfs, str): self._vfs = FileVfs(vfs) else: self._vfs = vfs diff --git a/gbp/git/args.py b/gbp/git/args.py index f9fc64d..5a40553 100644 --- a/gbp/git/args.py +++ b/gbp/git/args.py @@ -55,7 +55,7 @@ class GitArgs(object): Add arguments to argument list """ for arg in args: - if isinstance(arg, basestring): + if isinstance(arg, str): self._args.append(arg) elif isinstance(arg, collections.Iterable): for i in iter(arg): diff --git a/gbp/git/modifier.py b/gbp/git/modifier.py index 2452e0b..5f5b599 100644 --- a/gbp/git/modifier.py +++ b/gbp/git/modifier.py @@ -59,7 +59,7 @@ class GitModifier(object): self._date = None tz = GitTz(0) - if isinstance(date, basestring): + if isinstance(date, str): timestamp, offset = date.split() offset_h = int(offset[:-2]) offset_m = int(offset[-2:]) @@ -153,7 +153,7 @@ class GitModifier(object): def items(self): items = [] - for key in self.keys(): + for key in list(self.keys()): val = self.__getitem__(key) if val: items.append((key, val)) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 6d971c2..4266167 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -39,7 +39,7 @@ class GitRemote(object): def __init__(self, name, fetch_url, push_urls): self._name = name self._fetch_url = fetch_url - if isinstance(push_urls, basestring): + if isinstance(push_urls, str): self._push_urls = [push_urls] else: self._push_urls = [url for url in push_urls] @@ -1392,7 +1392,7 @@ class GitRepository(object): @param verbose: be verbose @type verbose: C{bool} """ - if isinstance(paths, basestring): + if isinstance(paths, str): paths = [ paths ] args = [] if verbose else ['--quiet'] @@ -1594,10 +1594,10 @@ class GitRepository(object): @type committer: C{dict} with keys 'name' and 'email' """ extra_env = {} - for key, val in author.items(): + for key, val in list(author.items()): if val: extra_env['GIT_AUTHOR_%s' % key.upper()] = val - for key, val in committer.items(): + for key, val in list(committer.items()): if val: extra_env['GIT_COMMITTER_%s' % key.upper()] = val @@ -1644,7 +1644,7 @@ class GitRepository(object): args.add(until) args.add_cond(options, options) args.add("--") - if isinstance(paths, basestring): + if isinstance(paths, str): paths = [ paths ] args.add_cond(paths, paths) diff --git a/gbp/git/vfs.py b/gbp/git/vfs.py index 5d5e132..6f10442 100644 --- a/gbp/git/vfs.py +++ b/gbp/git/vfs.py @@ -16,7 +16,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Make blobs in a git repository accessible as file like objects""" -import StringIO +import io from gbp.git.repository import GitRepositoryError class GitVfs(object): @@ -29,7 +29,7 @@ class GitVfs(object): """ def __init__(self, content): self._iter = iter - self._data = StringIO.StringIO(content) + self._data = io.StringIO(content) def readline(self): return self._data.readline() diff --git a/gbp/log.py b/gbp/log.py index 7b9a4aa..15479b1 100644 --- a/gbp/log.py +++ b/gbp/log.py @@ -26,8 +26,8 @@ import gbp.tristate # Initialize default logger LOGGER = logging.getLogger(__name__) -COLORS = dict([('none', 0)] + zip(['black', 'red', 'green', 'yellow', 'blue', - 'magenta', 'cyan', 'white'], range(30, 38))) +COLORS = dict([('none', 0)] + list(zip(['black', 'red', 'green', 'yellow', 'blue', + 'magenta', 'cyan', 'white'], list(range(30, 38))))) DEFAULT_COLOR_SCHEME = {DEBUG: COLORS['green'], INFO: COLORS['green'], WARNING: COLORS['red'], diff --git a/gbp/patch_series.py b/gbp/patch_series.py index 6ca24f2..f608f20 100644 --- a/gbp/patch_series.py +++ b/gbp/patch_series.py @@ -130,7 +130,7 @@ class Patch(object): if self.info == None: self._read_info() - if self.info.has_key(key): + if key in self.info: return self.info[key] else: return get_val() if get_val else None diff --git a/gbp/pkg/__init__.py b/gbp/pkg/__init__.py index 8162286..320973d 100644 --- a/gbp/pkg/__init__.py +++ b/gbp/pkg/__init__.py @@ -86,7 +86,7 @@ def parse_archive_filename(filename): base_name = ".".join(split[:-1]) (archive_fmt, compression) = (split[-1], None) else: - for (c, o) in compressor_opts.iteritems(): + for (c, o) in compressor_opts.items(): if o[1] == split[-1]: base_name = ".".join(split[:-1]) compression = c @@ -187,14 +187,13 @@ class PkgPolicy(object): version_chars = r'[a-zA-Z\d\.\~\-\:\+]' basename = parse_archive_filename(os.path.basename(filename))[0] - version_filters = map ( lambda x: x % version_chars, - ( # Debian upstream tarball: package_'.orig.tar.gz' + version_filters = [x % version_chars for x in ( # Debian upstream tarball: package_'.orig.tar.gz' r'^(?P[a-z\d\.\+\-]+)_(?P%s+)\.orig', # Debian native: 'package_.tar.gz' r'^(?P[a-z\d\.\+\-]+)_(?P%s+)', # Upstream 'package-.tar.gz' # or directory 'package-': - r'^(?P[a-zA-Z\d\.\+\-]+)(-)(?P[0-9]%s*)')) + r'^(?P[a-zA-Z\d\.\+\-]+)(-)(?P[0-9]%s*)')] if extra_regex: version_filters = extra_regex + version_filters @@ -509,7 +508,7 @@ class UpstreamSource(object): @staticmethod def known_compressions(): - return [ args[1][-1] for args in compressor_opts.items() ] + return [ args[1][-1] for args in list(compressor_opts.items()) ] def guess_version(self, extra_regex=r''): return self._pkg_policy.guess_upstream_src_version(self.path, diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py index 0fe2b4d..0a376e1 100644 --- a/gbp/rpm/__init__.py +++ b/gbp/rpm/__init__.py @@ -17,7 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """provides some rpm source package related helpers""" -import commands +import subprocess import sys import os import re @@ -243,7 +243,7 @@ class SpecFile(object): def sources(self): """Get all source tags as a dict""" sources = {} - for src in self._sources().values(): + for src in list(self._sources().values()): sources[src['num']] = src['linevalue'] return sources @@ -303,7 +303,7 @@ class SpecFile(object): tagvalue = None # We don't support "multivalue" tags like "Provides:" or "SourceX:" # Rpm python doesn't support many of these, thus the explicit list - if type(tagvalue) is int or type(tagvalue) is long: + if type(tagvalue) is int or type(tagvalue) is int: tagvalue = str(tagvalue) elif type(tagvalue) is list or tagname in self._listtags: tagvalue = None @@ -480,7 +480,7 @@ class SpecFile(object): indent_re = re.compile(r'^([a-z]+([0-9]+)?\s*:\s*)', flags=re.I) match = indent_re.match(str(insertafter)) if not match: - match = indent_re.match(str(insertafter.next)) + match = indent_re.match(str(insertafter.__next__)) indent = 12 if not match else len(match.group(1)) text = '%-*s%s\n' % (indent, '%s:' % tagname, value) if key in self._tags: @@ -574,11 +574,11 @@ class SpecFile(object): "which to update" % name) line = self._special_directives[name][0]['line'] gbp.log.debug("Removing content of %s section" % name) - while line.next: - match = self.directive_re.match(str(line.next)) + while line.__next__: + match = self.directive_re.match(str(line.__next__)) if match and match.group('name') in self.section_identifiers: break - self._content.delete(line.next) + self._content.delete(line.__next__) else: gbp.log.debug("Adding %s section to the end of spec file" % name) line = self._content.append('%%%s\n' % name) @@ -598,8 +598,8 @@ class SpecFile(object): text = '' if 'changelog' in self._special_directives: line = self._special_directives['changelog'][0]['line'] - while line.next: - line = line.next + while line.__next__: + line = line.__next__ match = self.directive_re.match(str(line)) if match and match.group('name') in self.section_identifiers: break @@ -613,7 +613,7 @@ class SpecFile(object): macro_prev = None ignored = self.ignorepatches # Remove 'Patch:̈́' tags - for tag in self._patches().values(): + for tag in list(self._patches().values()): if not tag['num'] in ignored: tag_prev = self._delete_tag('patch', tag['num']) # Remove a preceding comment if it seems to originate from GBP @@ -626,7 +626,7 @@ class SpecFile(object): if not macro['id'] in ignored: macro_prev = self._delete_special_macro('patch', macro['id']) # Remove surrounding if-else - macro_next = macro_prev.next + macro_next = macro_prev.__next__ if (str(macro_prev).startswith('%if') and str(macro_next).startswith('%endif')): self._content.delete(macro_next) @@ -694,7 +694,7 @@ class SpecFile(object): macro_line = self._content.insert_after(macro_line, comment_text) macro_line = self._set_special_macro('patch', patchnum, '-p1', macro_line) - for cmd, args in cmds.iteritems(): + for cmd, args in cmds.items(): if cmd in ('if', 'ifarch'): self._content.insert_before(macro_line, '%%%s %s\n' % (cmd, args)) @@ -779,7 +779,7 @@ class SpecFile(object): """ orig = None sources = self.sources() - for num, filename in sorted(sources.iteritems()): + for num, filename in sorted(sources.items()): src = {'num': num, 'filename': os.path.basename(filename), 'uri': filename} src['filename_base'], src['archive_fmt'], src['compression'] = \ @@ -803,9 +803,9 @@ def parse_srpm(srpmfile): """parse srpm by creating a SrcRpmFile object""" try: srcrpm = SrcRpmFile(srpmfile) - except IOError, err: + except IOError as err: raise GbpError("Error reading src.rpm file: %s" % err) - except librpm.error, err: + except librpm.error as err: raise GbpError("RPM error while reading src.rpm: %s" % err) return srcrpm diff --git a/gbp/rpm/linkedlist.py b/gbp/rpm/linkedlist.py index 74d897b..0840fef 100644 --- a/gbp/rpm/linkedlist.py +++ b/gbp/rpm/linkedlist.py @@ -63,8 +63,8 @@ class LinkedListNode(object): def delete(self): """Delete node""" if self.prev: - self.prev.next = self.next - if self.next: + self.prev.next = self.__next__ + if self.__next__: self.next.prev = self.prev self._data = None @@ -75,10 +75,10 @@ class LinkedListIterator(collections.Iterator): def __init__(self, obj): self._next = obj.first - def next(self): + def __next__(self): ret = self._next if ret: - self._next = ret.next + self._next = ret.__next__ else: raise StopIteration return ret @@ -171,8 +171,8 @@ class LinkedList(collections.Iterable): >>> [str(data) for data in list] ['foo', 'baz', 'bar'] """ - new = LinkedListNode(data, prev_node=node, next_node=node.next) - if node.next: + new = LinkedListNode(data, prev_node=node, next_node=node.__next__) + if node.__next__: node.next.prev = new else: self._last = new @@ -205,7 +205,7 @@ class LinkedList(collections.Iterable): """ ret = node.prev if node is self._first: - ret = self._first = self._first.next + ret = self._first = self._first.__next__ if node is self._last: self._last = self._last.prev node.delete() diff --git a/gbp/rpm/policy.py b/gbp/rpm/policy.py index 9362554..82e877d 100644 --- a/gbp/rpm/policy.py +++ b/gbp/rpm/policy.py @@ -264,7 +264,7 @@ class RpmPkgPolicy(PkgPolicy): text.extend([" " + line for line in body if line.strip()]) # Add bts tags and ids in the end - for tag, ids in bts_tags.iteritems(): + for tag, ids in bts_tags.items(): bts_msg = " (%s: %s)" % (tag, ', '.join(ids)) if len(text[-1]) + len(bts_msg) >= cls.max_entry_line_length: text.append(" ") diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 43dc261..5ed1628 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -17,7 +17,7 @@ # """Build a debian package out of a GIT repository""" -import ConfigParser +import configparser import errno import os, os.path import sys @@ -296,7 +296,7 @@ def guess_comp_type(repo, comp_type, cp, tarball_dir): if comp_type != 'auto': comp_type = compressor_aliases.get(comp_type, comp_type) - if not compressor_opts.has_key(comp_type): + if comp_type not in compressor_opts: gbp.log.warn("Unknown compression type - guessing.") comp_type = 'auto' @@ -305,7 +305,7 @@ def guess_comp_type(repo, comp_type, cp, tarball_dir): if not tarball_dir: tarball_dir = '..' detected = None - for comp in compressor_opts.keys(): + for comp in list(compressor_opts.keys()): if du.DebianPkgPolicy.has_orig(du.orig_file(cp, comp), tarball_dir): if detected is not None: raise GbpError("Multiple orig tarballs found.") @@ -384,7 +384,7 @@ def changes_file_suffix(dpkg_args): def build_parser(name, prefix=None): try: parser = GbpOptionParserDebian(command=os.path.basename(name), prefix=prefix) - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None diff --git a/gbp/scripts/buildpackage_bb.py b/gbp/scripts/buildpackage_bb.py index 340724c..5dd4eda 100644 --- a/gbp/scripts/buildpackage_bb.py +++ b/gbp/scripts/buildpackage_bb.py @@ -17,7 +17,7 @@ # """Build an RPM package out of a Git repo with Bitbake meta data""" -import ConfigParser +import configparser import os, os.path import sys import shutil @@ -46,7 +46,7 @@ def guess_export_params(repo, options): """Get commit and tree from where to export packaging and patches""" tree = None branch = None - if options.export in wc_names.keys() + [index_name, 'HEAD']: + if options.export in list(wc_names.keys()) + [index_name, 'HEAD']: branch = get_current_branch(repo) elif options.export in repo.get_local_branches(): branch = options.export @@ -112,8 +112,8 @@ def guess_export_dir(options, tinfoil, repo, treeish): gbp.log.debug("Found matching recipe filename: %s" % name) return os.path.dirname(name) else: - for name, appends in tinfoil.cooker.collection.appendlist.iteritems(): - print name, appends + for name, appends in tinfoil.cooker.collection.appendlist.items(): + print(name, appends) if name.rsplit('_', 1)[0] == pkg_name: gbp.log.debug("Found %s from appends" % name) for append_name in appends: @@ -212,7 +212,7 @@ def build_parser(name, prefix=None, git_treeish=None): try: parser = GbpOptionParserBB(command=os.path.basename(name), prefix=prefix, git_treeish=git_treeish) - except ConfigParser.ParsingError, err: + except configparser.ParsingError as err: gbp.log.err(err) return None @@ -507,7 +507,7 @@ def main(argv): if len(err.__str__()): gbp.log.err(err) retval = 2 - except GbpError, err: + except GbpError as err: if len(err.__str__()): gbp.log.err(err) retval = 1 diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index 7708dfc..537f96d 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -18,7 +18,7 @@ # """run commands to build an RPM package out of a git repository""" -import ConfigParser +import configparser import errno import os, os.path import sys @@ -207,7 +207,7 @@ def guess_export_params(repo, options): """Get commit and tree from where to export packaging and patches""" tree = None branch = None - if options.export in wc_names.keys() + [index_name, 'HEAD']: + if options.export in list(wc_names.keys()) + [index_name, 'HEAD']: branch = get_current_branch(repo) elif options.export in repo.get_local_branches(): branch = options.export @@ -390,7 +390,7 @@ def parse_args(argv, prefix, git_treeish=None): try: parser = GbpOptionParserRpm(command=os.path.basename(argv[0]), prefix=prefix, git_treeish=git_treeish) - except ConfigParser.ParsingError, err: + except configparser.ParsingError as err: gbp.log.err(err) return None, None, None @@ -544,7 +544,7 @@ def main(argv): # Create base temporary directory for this run options.tmp_dir = tempfile.mkdtemp(dir=options.tmp_dir, prefix='buildpackage-rpm_') - except GbpError, err: + except GbpError as err: gbp.log.err(err) return 1 @@ -697,7 +697,7 @@ def main(argv): if len(err.__str__()): gbp.log.err(err) retval = 2 - except GbpError, err: + except GbpError as err: if len(err.__str__()): gbp.log.err(err) retval = 1 diff --git a/gbp/scripts/clone.py b/gbp/scripts/clone.py index 2810a31..cdc7317 100755 --- a/gbp/scripts/clone.py +++ b/gbp/scripts/clone.py @@ -19,7 +19,7 @@ # """Clone a GIT repository and set it up for gbp""" -import ConfigParser +import configparser import sys import os, os.path from gbp.config import (GbpOptionParser, GbpOptionGroup) @@ -36,7 +36,7 @@ def build_parser(name): try: parser = GbpOptionParser(command=os.path.basename(name), prefix='', usage='%prog [options] repository - clone a remote repository') - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None diff --git a/gbp/scripts/clone_bb.py b/gbp/scripts/clone_bb.py index 7cc6b9a..817baa5 100755 --- a/gbp/scripts/clone_bb.py +++ b/gbp/scripts/clone_bb.py @@ -20,7 +20,7 @@ # """Clone a package Git repository from a bitbake-based distro""" -import ConfigParser +import configparser import re import sys import os, os.path @@ -57,7 +57,7 @@ def build_parser(name): parser = GbpOptionParser(command=os.path.basename(name), prefix='', usage='%prog [options] repository - clone a ' 'remote per-package repository') - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None diff --git a/gbp/scripts/common/import_orig.py b/gbp/scripts/common/import_orig.py index 1624442..30df610 100644 --- a/gbp/scripts/common/import_orig.py +++ b/gbp/scripts/common/import_orig.py @@ -47,7 +47,7 @@ def ask_package_name(default, name_validator_func, err_msg): @param default: The default package name to suggest to the user. """ while True: - sourcepackage = raw_input("What will be the source package name? [%s] " % default) + sourcepackage = input("What will be the source package name? [%s] " % default) if not sourcepackage: # No input, use the default. sourcepackage = default # Valid package name, return it. @@ -66,7 +66,7 @@ def ask_package_version(default, ver_validator_func, err_msg): @param default: The default package version to suggest to the user. """ while True: - version = raw_input("What is the upstream version? [%s] " % default) + version = input("What is the upstream version? [%s] " % default) if not version: # No input, use the default. version = default # Valid version, return it. diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py index a91ec8e..60157b2 100644 --- a/gbp/scripts/common/pq.py +++ b/gbp/scripts/common/pq.py @@ -180,7 +180,7 @@ def patch_path_filter(file_status, exclude_regex=None): """ if exclude_regex: include_paths = [] - for file_list in file_status.values(): + for file_list in list(file_status.values()): for fname in file_list: if not re.match(exclude_regex, fname): include_paths.append(fname) @@ -208,13 +208,13 @@ def write_patch_file(filename, commit_info, diff): # Git compat: put name in quotes if special characters found if re.search("[,.@()\[\]\\\:;]", name): name = '"%s"' % name - from_header = Header(unicode(name, 'utf-8'), charset, 77, 'from') - from_header.append(unicode('<%s>' % email)) + from_header = Header(str(name, 'utf-8'), charset, 77, 'from') + from_header.append(str('<%s>' % email)) msg['From'] = from_header date = commit_info['author'].datetime datestr = date.strftime('%a, %-d %b %Y %H:%M:%S %z') - msg['Date'] = Header(unicode(datestr, 'utf-8'), charset, 77, 'date') - msg['Subject'] = Header(unicode(commit_info['subject'], 'utf-8'), + msg['Date'] = Header(str(datestr, 'utf-8'), charset, 77, 'date') + msg['Subject'] = Header(str(commit_info['subject'], 'utf-8'), charset, 77, 'subject') # Write message body if commit_info['body']: diff --git a/gbp/scripts/config.py b/gbp/scripts/config.py index 07c731c..c914e7d 100755 --- a/gbp/scripts/config.py +++ b/gbp/scripts/config.py @@ -17,7 +17,7 @@ # """Query and display config file values""" -import ConfigParser +import configparser import sys import os, os.path from gbp.config import (GbpOptionParser, GbpOptionGroup) @@ -30,7 +30,7 @@ def build_parser(name): try: parser = GbpOptionParser(command=os.path.basename(name), prefix='', usage='%prog [options] command[.optionname] - display configuration settings') - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None diff --git a/gbp/scripts/create_remote_repo.py b/gbp/scripts/create_remote_repo.py index a9832a1..3b5aa76 100755 --- a/gbp/scripts/create_remote_repo.py +++ b/gbp/scripts/create_remote_repo.py @@ -18,10 +18,10 @@ # Based on the aa-create-git-repo and dom-new-git-repo shell scripts """Create a remote GIT repository based on the current one""" -import ConfigParser +import configparser import sys import os, os.path -import urlparse +import urllib.parse import subprocess import tty, termios import re @@ -51,22 +51,22 @@ def print_config(remote, branches): merge = refs/heads/bar """ - print """[remote "%(name)s"] + print("""[remote "%(name)s"] url = %(url)s - fetch = +refs/heads/*:refs/remotes/%(name)s/*""" % remote + fetch = +refs/heads/*:refs/remotes/%(name)s/*""" % remote) for branch in branches: - print " push = %s" % branch + print(" push = %s" % branch) for branch in branches: - print """[branch "%s"] + print("""[branch "%s"] remote = %s - merge = refs/heads/%s""" % (branch, remote['name'], branch) + merge = refs/heads/%s""" % (branch, remote['name'], branch)) def sort_dict(d): """Return a sorted list of (key, value) tuples""" s = [] - for key in sorted(d.iterkeys()): + for key in sorted(d.keys()): s.append((key, d[key])) return s @@ -103,7 +103,7 @@ def parse_url(remote_url, name, pkg, template_dir=None): ... GbpError: URL contains invalid ~username expansion. """ - frags = urlparse.urlparse(remote_url) + frags = urllib.parse.urlparse(remote_url) if frags.scheme in ['ssh', 'git+ssh', '']: scheme = frags.scheme else: @@ -232,7 +232,7 @@ def build_parser(name, sections=[]): usage='%prog [options] - ' 'create a remote repository', sections=sections) - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None @@ -306,7 +306,7 @@ def main(argv): try: options, args = parse_args(argv) except Exception as e: - print >>sys.stderr, "%s" % e + print("%s" % e, file=sys.stderr) return 1 gbp.log.setup(options.color, options.verbose, options.color_scheme) @@ -350,11 +350,11 @@ def main(argv): remote_script = build_remote_script(remote, branches[0]) if options.verbose: - print remote_script + print(remote_script) cmd = build_cmd(remote) if options.verbose: - print cmd + print(cmd) proc = subprocess.Popen(cmd, stdin=subprocess.PIPE) proc.communicate(remote_script) diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index b8a86a7..90d448c 100755 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -17,7 +17,7 @@ # """Generate Debian changelog entries from GIT commit messages""" -import ConfigParser +import configparser import os.path import re import sys @@ -137,8 +137,8 @@ def mangle_changelog(changelog, cp, snapshot=''): cw = open(tmpfile, 'w') cr = open(changelog, 'r') - print >>cw, ("%(Source)s (%(MangledVersion)s) " - "%(Distribution)s; urgency=%(urgency)s\n" % cp) + print(("%(Source)s (%(MangledVersion)s) " + "%(Distribution)s; urgency=%(urgency)s\n" % cp), file=cw) cr.readline() # skip version and empty line cr.readline() @@ -148,10 +148,10 @@ def mangle_changelog(changelog, cp, snapshot=''): line = '' if snapshot: - print >>cw, " ** SNAPSHOT build @%s **\n" % snapshot + print(" ** SNAPSHOT build @%s **\n" % snapshot, file=cw) if line: - print >>cw, line.rstrip() + print(line.rstrip(), file=cw) shutil.copyfileobj(cr, cw) cw.close() cr.close() @@ -242,7 +242,7 @@ def has_snapshot_banner(cp): def get_customizations(customization_file): if customization_file: - execfile(customization_file, + exec(compile(open(customization_file, "rb").read(), customization_file, 'exec'), user_customizations, user_customizations) @@ -295,7 +295,7 @@ def build_parser(name): try: parser = GbpOptionParserDebian(command=os.path.basename(name), usage='%prog [options] paths') - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None diff --git a/gbp/scripts/import_bb.py b/gbp/scripts/import_bb.py index 5d24977..0741799 100755 --- a/gbp/scripts/import_bb.py +++ b/gbp/scripts/import_bb.py @@ -16,7 +16,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Import an RPM package in Bitbake format""" -import ConfigParser +import configparser import sys import os import shutil @@ -57,7 +57,7 @@ def build_parser(name): prefix='', usage='%prog [options] /path/to/package' '.src.rpm') - except ConfigParser.ParsingError, err: + except configparser.ParsingError as err: gbp.log.err(err) return None @@ -256,7 +256,7 @@ def import_upstream_archive(repo, pkg_data, fetch_data, dirs, options): def import_upstream_git(repo, fetch_data, options): """Import upstream sources from Git""" # Fetch from local cached repo - for branch in fetch_data.branches.values(): + for branch in list(fetch_data.branches.values()): repo.fetch(repo=fetch_data.localpath, refspec=branch) commit = fetch_data.revision diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py index 41eae8c..08addab 100755 --- a/gbp/scripts/import_dsc.py +++ b/gbp/scripts/import_dsc.py @@ -16,7 +16,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Import a Debian source package into a GIT repository""" -import ConfigParser +import configparser import sys import re import os @@ -209,7 +209,7 @@ def build_parser(name): try: parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='', usage='%prog [options] /path/to/package.dsc') - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None @@ -416,7 +416,7 @@ def main(argv): os.chdir(dirs['top']) for d in [ 'tmp', 'download' ]: - if dirs.has_key(d): + if d in dirs: gbpc.RemoveTree(dirs[d])() if not ret and not skipped: diff --git a/gbp/scripts/import_dscs.py b/gbp/scripts/import_dscs.py index 5409ca1..c37cea8 100644 --- a/gbp/scripts/import_dscs.py +++ b/gbp/scripts/import_dscs.py @@ -79,13 +79,13 @@ def set_gbp_conf_files(): gbp.log.debug("Setting GBP_CONF_FILES to '%s'" % gbp_conf_files) def print_help(): - print """Usage: gbp import-dscs [options] [gbp-import-dsc options] /path/to/dsc1 [/path/to/dsc2] ... + print("""Usage: gbp import-dscs [options] [gbp-import-dsc options] /path/to/dsc1 [/path/to/dsc2] ... gbp import-dscs --debsnap [options] [gbp-import-dsc options] package Options: --ignore-repo-config: ignore gbp.conf in git repo -""" +""") def main(argv): @@ -159,7 +159,7 @@ def main(argv): gbp.log.err(err) ret = 1 finally: - if dirs.has_key('tmp'): + if 'tmp' in dirs: gbpc.RemoveTree(dirs['tmp'])() os.chdir(dirs['top']) diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 56b1d9d..532b3e4 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -17,7 +17,7 @@ # """Import a new upstream version into a GIT repository""" -import ConfigParser +import configparser import os import sys import gbp.tmpfile as tempfile @@ -146,7 +146,7 @@ def build_parser(name): try: parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='', usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan') - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None diff --git a/gbp/scripts/import_orig_rpm.py b/gbp/scripts/import_orig_rpm.py index 4b318a2..ced92fc 100755 --- a/gbp/scripts/import_orig_rpm.py +++ b/gbp/scripts/import_orig_rpm.py @@ -18,7 +18,7 @@ # """Import a new upstream version into a git repository""" -import ConfigParser +import configparser import os import sys import gbp.tmpfile as tempfile @@ -152,7 +152,7 @@ def parse_args(argv): parser = GbpOptionParserRpm(command=os.path.basename(argv[0]), prefix='', usage='%prog [options] /path/to/upstream-version.tar.gz') - except ConfigParser.ParsingError, err: + except configparser.ParsingError as err: gbp.log.err(err) return None, None @@ -331,7 +331,7 @@ def main(argv): repo.force_head(current_branch, hard=True) except (GitRepositoryError, gbpc.CommandExecFailed): raise GbpError("Import of %s failed" % source.path) - except GbpError, err: + except GbpError as err: if len(err.__str__()): gbp.log.err(err) ret = 1 diff --git a/gbp/scripts/import_srpm.py b/gbp/scripts/import_srpm.py index b573f2b..0712288 100755 --- a/gbp/scripts/import_srpm.py +++ b/gbp/scripts/import_srpm.py @@ -17,7 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Import an RPM source package into a GIT repository""" -import ConfigParser +import configparser import sys import re import os @@ -25,7 +25,7 @@ import glob import time import shutil import errno -import urllib2 +import urllib.request, urllib.error, urllib.parse import gbp.tmpfile as tempfile import gbp.command_wrappers as gbpc @@ -68,13 +68,13 @@ def download_file(target_dir, url): """Download a remote file""" gbp.log.info("Downloading '%s'..." % url) try: - urlobj = urllib2.urlopen(url) + urlobj = urllib.request.urlopen(url) local_fn = os.path.join(target_dir, os.path.basename(url)) with open(local_fn, "wb") as local_file: local_file.write(urlobj.read()) - except urllib2.HTTPError as err: + except urllib.error.HTTPError as err: raise GbpError("Download failed: %s" % err) - except urllib2.URLError as err: + except urllib.error.URLError as err: raise GbpError("Download failed: %s" % err.reason) return local_fn @@ -176,7 +176,7 @@ def parse_args(argv): prefix='', usage='%prog [options] /path/to/package' '.src.rpm') - except ConfigParser.ParsingError, err: + except configparser.ParsingError as err: gbp.log.err(err) return None, None @@ -337,7 +337,7 @@ def main(argv): # Need to copy files to the packaging directory given by caller files = [os.path.basename(patch.path) \ for patch in spec.patchseries(unapplied=True, ignored=True)] - for filename in spec.sources().values(): + for filename in list(spec.sources().values()): files.append(os.path.basename(filename)) files.append(os.path.join(spec.specdir, spec.specfile)) # Don't copy orig source archive, though diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index f15753c..029e718 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -17,7 +17,7 @@ # """Manage Debian patches on a patch queue branch""" -import ConfigParser +import configparser import errno import os import shutil @@ -119,7 +119,7 @@ def format_series_diff(added, removed, options): bugs, dummy = extract_bts_cmds(patch.long_desc.split('\n'), options) if bugs: msg += '\n' - for k, v in bugs.items(): + for k, v in list(bugs.items()): msg += '\n%s: %s' % (k, ', '.join(v)) else: msg = "Rediff patches\n\n" @@ -326,7 +326,7 @@ def build_parser(name): " drop drop (delete) the patch queue associated to the current branch.\n" " apply apply a patch\n" " switch switch to patch-queue branch and vice versa") - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None diff --git a/gbp/scripts/pq_bb.py b/gbp/scripts/pq_bb.py index 23e9e89..e1dbae1 100755 --- a/gbp/scripts/pq_bb.py +++ b/gbp/scripts/pq_bb.py @@ -18,7 +18,7 @@ # """manage patches in a patch queue""" -import ConfigParser +import configparser import errno import os import shutil @@ -289,7 +289,7 @@ def build_parser(name): try: parser = GbpOptionParserBB(command=os.path.basename(name), prefix='', usage=USAGE_STRING) - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None @@ -411,7 +411,7 @@ def main(argv): except GitRepositoryError as err: gbp.log.err("Git command failed: %s" % err) retval = 1 - except GbpError, err: + except GbpError as err: if len(err.__str__()): gbp.log.err(err) retval = 1 diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py index 32ffade..011c416 100755 --- a/gbp/scripts/pq_rpm.py +++ b/gbp/scripts/pq_rpm.py @@ -18,7 +18,7 @@ # """manage patches in a patch queue""" -import ConfigParser +import configparser import errno import os import shutil @@ -147,7 +147,7 @@ def generate_patches(repo, start, squash, end, outdir, options): "into one monolithic diff" % (start_sha1, merge_sha1)) patches.append(patch_fn) start = merge_sha1 - print start + print(start) # Generate patches for commit in reversed(repo.get_commits(start, end_commit)): @@ -348,14 +348,14 @@ def import_extra_files(repo, commitish, files, patch_ignore=True): if found: gbp.log.info("Importing additional file(s) from branch '%s' into '%s'" % (commitish, repo.get_branch())) - for fname, content in found.iteritems(): + for fname, content in found.items(): dirname = os.path.dirname(fname) if dirname and not os.path.exists(dirname): os.makedirs(dirname) with open(fname, 'w') as fobj: fobj.write(content) - files = found.keys() + files = list(found.keys()) gbp.log.debug('Adding/commiting %s' % files) repo.add_files(files, force=True) commit_msg = ("Auto-import file(s) from branch '%s':\n %s\n" % @@ -363,7 +363,7 @@ def import_extra_files(repo, commitish, files, patch_ignore=True): if patch_ignore: commit_msg += "\nGbp: Ignore\nGbp-Rpm: Ignore" repo.commit_files(files, msg=commit_msg) - return found.keys() + return list(found.keys()) def import_spec_patches(repo, options): """ @@ -618,7 +618,7 @@ def main(argv): try: parser = GbpOptionParserRpm(command=os.path.basename(argv[0]), prefix='', usage=USAGE_STRING) - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err('Invalid config file: %s' % err) return 1 @@ -727,7 +727,7 @@ def main(argv): except GitRepositoryError as err: gbp.log.err("Git command failed: %s" % err) retval = 1 - except GbpError, err: + except GbpError as err: if len(err.__str__()): gbp.log.err(err) retval = 1 diff --git a/gbp/scripts/pull.py b/gbp/scripts/pull.py index 166955a..4725a8e 100755 --- a/gbp/scripts/pull.py +++ b/gbp/scripts/pull.py @@ -19,7 +19,7 @@ # """Pull remote changes and fast forward debian, upstream and pristine-tar branch""" -import ConfigParser +import configparser import sys import os, os.path from gbp.command_wrappers import (Command, CommandExecFailed) @@ -100,7 +100,7 @@ def build_parser(name): try: parser = GbpOptionParser(command=os.path.basename(name), prefix='', usage='%prog [options] - safely update a repository from remote') - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None diff --git a/gbp/scripts/rpm_ch.py b/gbp/scripts/rpm_ch.py index 3305837..e5fddb4 100755 --- a/gbp/scripts/rpm_ch.py +++ b/gbp/scripts/rpm_ch.py @@ -18,7 +18,7 @@ # """Generate RPM changelog entries from git commit messages""" -import ConfigParser +import configparser from datetime import datetime import os.path import pwd @@ -92,7 +92,7 @@ def load_customizations(customization_file): return customizations = {} try: - execfile(customization_file, customizations, customizations) + exec(compile(open(customization_file, "rb").read(), customization_file, 'exec'), customizations, customizations) except Exception as err: raise GbpError("Failed to load customization file: %s" % err) @@ -134,7 +134,7 @@ def check_repo_state(repo, options): if options.commit: unstaged = [] status = repo.status() - for group, files in status.iteritems(): + for group, files in status.items(): if group != '??' and group[1] != ' ': unstaged.extend(files) if unstaged: @@ -340,7 +340,7 @@ def update_changelog(changelog, entries, repo, spec, options): revision = options.changelog_revision % rev_str_fields except KeyError as err: raise GbpError("Unable to construct revision field: unknown key " - "%s, only %s are accepted" % (err, rev_str_fields.keys())) + "%s, only %s are accepted" % (err, list(rev_str_fields.keys()))) # Add a new changelog section if new release or an empty changelog if options.release or not changelog.sections: @@ -366,7 +366,7 @@ def create_commit_message(spec, options): return options.commit_msg % fields except KeyError as err: raise GbpError("Unknown key %s in commit-msg string, " - "only %s are accepted" % (err, fields.keys())) + "only %s are accepted" % (err, list(fields.keys()))) def commit_changelog(repo, changelog, message, author, committer, edit): """Commit changelog and create a packaging/release tag""" @@ -380,7 +380,7 @@ def parse_args(argv): try: parser = GbpOptionParserRpm(command=os.path.basename(argv[0]), prefix='', usage='%prog [options] paths') - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.error('invalid config file: %s' % err) return None, None diff --git a/gbp/scripts/submit_bb.py b/gbp/scripts/submit_bb.py index b3a9b85..95d29a0 100755 --- a/gbp/scripts/submit_bb.py +++ b/gbp/scripts/submit_bb.py @@ -17,7 +17,7 @@ # """Create and push submit tag""" -import ConfigParser +import configparser import os import sys from datetime import datetime @@ -38,11 +38,11 @@ def guess_remote(repo, options): raise GbpError("Local repo has no remotes configured. Please add one " "or use --remote to define the remote where to push.") elif len(remotes) == 1: - return remotes.keys()[0] + return list(remotes.keys())[0] else: raise GbpError("Local repo has multiple remotes (%s). Don't know which " "one to choose. Use --remote to define where to push." % - ', '.join(remotes.keys())) + ', '.join(list(remotes.keys()))) def build_parser(name): @@ -51,7 +51,7 @@ def build_parser(name): try: parser = GbpOptionParserBB(command=os.path.basename(name), prefix='', usage=usage_str) - except ConfigParser.ParsingError as err: + except configparser.ParsingError as err: gbp.log.err(err) return None diff --git a/gbp/scripts/supercommand.py b/gbp/scripts/supercommand.py index 493554f..a47c4db 100644 --- a/gbp/scripts/supercommand.py +++ b/gbp/scripts/supercommand.py @@ -34,7 +34,7 @@ def sanitize(cmd): return cmd.replace('-', '_') def usage(): - print """ + print(""" Usage: gbp [] @@ -46,14 +46,14 @@ The most commonly used commands are: import-dscs - import multiple Debian source packages Use '--list-cmds' to list all available commands. -""" +""") def version(prog): try: from gbp.version import gbp_version except ImportError: gbp_version = '[Unknown version]' - print("%s %s" % (os.path.basename(prog), gbp_version)) + print(("%s %s" % (os.path.basename(prog), gbp_version))) def import_command(cmd): @@ -90,7 +90,7 @@ def list_available_commands(): path = os.path.dirname(mod.__file__) maxlen = 0 - print("Available commands in %s\n" % path) + print(("Available commands in %s\n" % path)) cmds = sorted(get_available_commands(path)) for cmd in cmds: if len(cmd[0]) > maxlen: @@ -98,7 +98,7 @@ def list_available_commands(): for cmd in cmds: mod = import_command(cmd[0]) doc = mod.__doc__ - print(" %s - %s" % (cmd[0].rjust(maxlen), doc)) + print((" %s - %s" % (cmd[0].rjust(maxlen), doc))) print('') @@ -127,10 +127,10 @@ def supercommand(argv=None): try: module = import_command(cmd) except ImportError as e: - print >>sys.stderr, "'%s' is not a valid command." % cmd + print("'%s' is not a valid command." % cmd, file=sys.stderr) usage() if '--verbose' in args: - print >>sys.stderr, e + print(e, file=sys.stderr) return 2 return module.main(args) diff --git a/gbp/tristate.py b/gbp/tristate.py index 0a800ec..81cb75c 100644 --- a/gbp/tristate.py +++ b/gbp/tristate.py @@ -36,7 +36,7 @@ class Tristate(object): self._state = self.AUTO else: self._state = self.OFF - elif type(val) in [ type(t) for t in ("", u"") ]: + elif type(val) in [ type(t) for t in ("", "") ]: if val.lower() in [ 'on', 'true' ]: self._state = self.ON elif val.lower() in [ 'auto' ]: @@ -66,7 +66,7 @@ class Tristate(object): else: return 'off' - def __nonzero__(self): + def __bool__(self): """ >>> Tristate('on').__nonzero__() True diff --git a/packaging/PKGBUILD b/packaging/PKGBUILD index 60ffa9f..b26bbb7 100755 --- a/packaging/PKGBUILD +++ b/packaging/PKGBUILD @@ -8,7 +8,7 @@ url="https://honk.sigxcpu.org/piki/projects/git-buildpackage/" license=('GPLv2') conflicts=('git-buildpackage') provides=('git-buildpackage') -makedepends=('python2-distribute' 'gtk-doc' 'docbook-sgml' 'docbook-utils') +makedepends=('python3-distribute' 'gtk-doc' 'docbook-sgml' 'docbook-utils') source=(git-buildpackage_${pkgver}.tar.gz) sha256sums=(SKIP) @@ -24,7 +24,7 @@ prepare() build() { cd $srcdir/$pkgbase-$pkgver WITHOUT_NOSETESTS=1 \ - python2 setup.py build + python3 setup.py build # Prepare apidocs epydoc -n git-buildpackage --no-sourcecode -o docs/apidocs/ \ @@ -36,12 +36,12 @@ build() { package_git-buildpackage-common() { depends=('man-db' - 'python2' + 'python3' 'git') optdepends=('pristine-tar: regenerate pristine tarballs') cd $srcdir/$pkgbase-$pkgver WITHOUT_NOSETESTS=1 \ - python2 setup.py install \ + python3 setup.py install \ --root="$pkgdir" \ --prefix=/usr \ -O1 @@ -56,7 +56,7 @@ package_git-buildpackage-rpm() { provides=("tizen-gbp-rpm=20160302") cd $srcdir/$pkgbase-$pkgver WITHOUT_NOSETESTS=1 \ - python2 setup.py install \ + python3 setup.py install \ --root="$pkgdir" \ --prefix=/usr \ -O1 diff --git a/packaging/git-buildpackage.spec b/packaging/git-buildpackage.spec index 880e862..ef9ca93 100755 --- a/packaging/git-buildpackage.spec +++ b/packaging/git-buildpackage.spec @@ -1,3 +1,4 @@ +%{!?python3_sitelib: %define python3_sitelib %(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')} # Add --without docs rpmbuild option, i.e. docs are enabled by default %bcond_without docs @@ -32,22 +33,22 @@ Source0: %{name}_%{version}.tar.gz %endif %if 0%{?fedora} || 0%{?centos_ver} || 0%{?tizen_version:1} -%define python_pkg_name python +%define python_pkg_name python3 %else -%define python_pkg_name python-base +%define python_pkg_name python3 %endif %if 0%{?tizen_version:1} -%define rpm_python_pkg_name python-rpm +%define rpm_python_pkg_name python3-rpm %else -%define rpm_python_pkg_name rpm-python +%define rpm_python_pkg_name rpm-python3 %endif Requires: %{name}-common = %{version}-%{release} Requires: %{dpkg_pkg_name} Requires: %{devscripts_pkg_name} -BuildRequires: python -BuildRequires: python-setuptools +BuildRequires: python3 +BuildRequires: python3-setuptools %if %{with docs} BuildRequires: docbook-utils @@ -59,8 +60,8 @@ BuildRequires: perl-podlators %endif %if 0%{?do_unittests} -BuildRequires: python-coverage -BuildRequires: python-nose +BuildRequires: python3-coverage +BuildRequires: python3-nose BuildRequires: git-core BuildRequires: %{man_pkg_name} BuildRequires: %{dpkg_pkg_name} @@ -150,7 +151,7 @@ Debian and the RPM tool set. %build -WITHOUT_NOSETESTS=1 %{__python} ./setup.py build +WITHOUT_NOSETESTS=1 python3 ./setup.py build %if %{with docs} # Prepare apidocs @@ -167,14 +168,14 @@ HAVE_SGML2X=0 make -C docs/ GIT_CEILING_DIRECTORIES=%{_builddir} \ GIT_AUTHOR_EMAIL=rpmbuild@example.com GIT_AUTHOR_NAME=rpmbuild \ GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL \ - %{__python} setup.py nosetests + python3 setup.py nosetests %endif %install rm -rf %{buildroot} -WITHOUT_NOSETESTS=1 %{__python} ./setup.py install --root=%{buildroot} --prefix=/usr -rm -rf %{buildroot}%{python_sitelib}/*info +WITHOUT_NOSETESTS=1 python3 ./setup.py install --root=%{buildroot} --prefix=/usr +rm -rf %{buildroot}%{python3_sitelib}/*info %if %{with docs} # Install man pages @@ -197,14 +198,14 @@ cat > files.list << EOF %{_bindir}/git-import-orig %{_bindir}/git-pbuilder %{_bindir}/gbp-create-remote-repo -%{python_sitelib}/gbp/deb -%{python_sitelib}/gbp/scripts/pq.py* -%{python_sitelib}/gbp/scripts/buildpackage.py* -%{python_sitelib}/gbp/scripts/dch.py* -%{python_sitelib}/gbp/scripts/import_dsc.py* -%{python_sitelib}/gbp/scripts/import_dscs.py* -%{python_sitelib}/gbp/scripts/import_orig.py* -%{python_sitelib}/gbp/scripts/create_remote_repo.py* +%{python3_sitelib}/gbp/deb +%{python3_sitelib}/gbp/scripts/pq.py* +%{python3_sitelib}/gbp/scripts/buildpackage.py* +%{python3_sitelib}/gbp/scripts/dch.py* +%{python3_sitelib}/gbp/scripts/import_dsc.py* +%{python3_sitelib}/gbp/scripts/import_dscs.py* +%{python3_sitelib}/gbp/scripts/import_orig.py* +%{python3_sitelib}/gbp/scripts/create_remote_repo.py* EOF %if %{with docs} @@ -237,20 +238,20 @@ done %{_bindir}/gbp %{_bindir}/gbp-clone %{_bindir}/gbp-pull -%dir %{python_sitelib}/gbp -%dir %{python_sitelib}/gbp/git -%dir %{python_sitelib}/gbp/pkg -%dir %{python_sitelib}/gbp/scripts -%dir %{python_sitelib}/gbp/scripts/common -%{python_sitelib}/gbp/*.py* -%{python_sitelib}/gbp/scripts/__init__.py* -%{python_sitelib}/gbp/scripts/clone.py* -%{python_sitelib}/gbp/scripts/config.py* -%{python_sitelib}/gbp/scripts/pull.py* -%{python_sitelib}/gbp/scripts/supercommand.py* -%{python_sitelib}/gbp/scripts/common/*.py* -%{python_sitelib}/gbp/git/*.py* -%{python_sitelib}/gbp/pkg/*.py* +%dir %{python3_sitelib}/gbp +%dir %{python3_sitelib}/gbp/git +%dir %{python3_sitelib}/gbp/pkg +%dir %{python3_sitelib}/gbp/scripts +%dir %{python3_sitelib}/gbp/scripts/common +%{python3_sitelib}/gbp/*.py* +%{python3_sitelib}/gbp/scripts/__init__.py* +%{python3_sitelib}/gbp/scripts/clone.py* +%{python3_sitelib}/gbp/scripts/config.py* +%{python3_sitelib}/gbp/scripts/pull.py* +%{python3_sitelib}/gbp/scripts/supercommand.py* +%{python3_sitelib}/gbp/scripts/common/*.py* +%{python3_sitelib}/gbp/git/*.py* +%{python3_sitelib}/gbp/pkg/*.py* %config %{_sysconfdir}/git-buildpackage %if %{with docs} %{_mandir}/man1/gbp.1* @@ -263,10 +264,10 @@ done %files rpm %defattr(-,root,root,-) -%dir %{python_sitelib}/gbp/rpm +%dir %{python3_sitelib}/gbp/rpm %{_bindir}/*rpm* -%{python_sitelib}/gbp/scripts/*rpm*.py* -%{python_sitelib}/gbp/rpm/*py* +%{python3_sitelib}/gbp/scripts/*rpm*.py* +%{python3_sitelib}/gbp/rpm/*py* %if %{with docs} %{_mandir}/man1/gbp-buildpackage-rpm.1* %{_mandir}/man1/gbp-import-orig-rpm.1* @@ -278,9 +279,9 @@ done %files bb %defattr(-,root,root,-) -%dir %{python_sitelib}/gbp/bb -%{python_sitelib}/gbp/scripts/*bb*.py* -%{python_sitelib}/gbp/bb/*py* +%dir %{python3_sitelib}/gbp/bb +%{python3_sitelib}/gbp/scripts/*bb*.py* +%{python3_sitelib}/gbp/bb/*py* %if %{with docs} diff --git a/setup.py b/setup.py index e733f9d..4bf75f5 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # vim: set fileencoding=utf-8 : # Copyright (C) 2006-2011 Guido Günther # @@ -29,7 +29,7 @@ def fetch_version(): try: popen = subprocess.Popen('dpkg-parsechangelog', stdout=subprocess.PIPE) out, ret = popen.communicate() - for line in out.split('\n'): + for line in out.decode().split('\n'): if line.startswith('Version:'): version = line.split(' ')[1].strip() break @@ -49,7 +49,7 @@ def readme(): setup(name = "gbp", version = fetch_version(), - author = u'Guido Günther', + author = 'Guido Günther', author_email = 'agx@sigxcpu.org', url = 'https://honk.sigxcpu.org/piki/projects/git-buildpackage/', description = 'Suite to help with Debian packages in Git repositories', diff --git a/tests/02_test_upstream_source_tar_unpack.py b/tests/02_test_upstream_source_tar_unpack.py index e6147ab..4d44f05 100644 --- a/tests/02_test_upstream_source_tar_unpack.py +++ b/tests/02_test_upstream_source_tar_unpack.py @@ -52,7 +52,7 @@ class TestUnpack(unittest.TestCase): context.teardown() def test_upstream_source_type(self): - for (comp, archive) in self.archives.iteritems(): + for (comp, archive) in self.archives.items(): source = gbp.pkg.UpstreamSource(archive[0]) assert source.is_orig() == True assert source.is_dir() == False @@ -63,13 +63,13 @@ class TestUnpack(unittest.TestCase): assert type(source.unpacked) == str def test_upstream_source_unpack(self): - for (comp, archive) in self.archives.iteritems(): + for (comp, archive) in self.archives.items(): source = gbp.pkg.UpstreamSource(archive[0]) source.unpack(".") self._check_files(archive[1], comp) def test_upstream_source_unpack_no_filter(self): - for (comp, archive) in self.archives.iteritems(): + for (comp, archive) in self.archives.items(): source = gbp.pkg.UpstreamSource(archive[0]) source.unpack(".", []) self._check_files(archive[1], comp) @@ -77,7 +77,7 @@ class TestUnpack(unittest.TestCase): def test_upstream_source_unpack_filtered(self): exclude = "README" - for (comp, archive) in self.archives.iteritems(): + for (comp, archive) in self.archives.items(): source = gbp.pkg.UpstreamSource(archive[0]) source.unpack(".", [exclude]) archive[1].remove(exclude) diff --git a/tests/03_test_dch_guess_version.py b/tests/03_test_dch_guess_version.py index 6109bfb..5dca3b7 100644 --- a/tests/03_test_dch_guess_version.py +++ b/tests/03_test_dch_guess_version.py @@ -4,7 +4,7 @@ from . import context -import testutils +from . import testutils from gbp.scripts import dch diff --git a/tests/09_test_write_tree.py b/tests/09_test_write_tree.py index 55a1da6..9ae636e 100644 --- a/tests/09_test_write_tree.py +++ b/tests/09_test_write_tree.py @@ -20,7 +20,7 @@ class TestWriteTree(testutils.DebianGitTestRepo): for i in range(4): path = os.path.join(self.repo.path, 'testfile%d' % i) with open(path, 'w') as f: - print >>f, "testdata %d" % i + print("testdata %d" % i, file=f) paths.append(path) return paths diff --git a/tests/14_test_gbp_import_dscs.py b/tests/14_test_gbp_import_dscs.py index ba3d5f7..2fdc2e6 100644 --- a/tests/14_test_gbp_import_dscs.py +++ b/tests/14_test_gbp_import_dscs.py @@ -17,7 +17,7 @@ from . import context -import testutils +from . import testutils import gbp.log import gbp.scripts.import_dscs as import_dscs diff --git a/tests/15_test_DebianSource.py b/tests/15_test_DebianSource.py index feca625..a4ea556 100644 --- a/tests/15_test_DebianSource.py +++ b/tests/15_test_DebianSource.py @@ -18,7 +18,7 @@ from . import context import os -import testutils +from . import testutils from gbp.deb.source import DebianSource, DebianSourceError from gbp.deb.format import DebianSourceFormat from gbp.git.vfs import GitVfs diff --git a/tests/17_test_dch_guess_documented_commit.py b/tests/17_test_dch_guess_documented_commit.py index 89eba2d..78adca8 100644 --- a/tests/17_test_dch_guess_documented_commit.py +++ b/tests/17_test_dch_guess_documented_commit.py @@ -4,7 +4,7 @@ from . import context -import testutils +from . import testutils from gbp.scripts import dch diff --git a/tests/19_test_gbp_scripts_config.py b/tests/19_test_gbp_scripts_config.py index c984329..8bb2105 100644 --- a/tests/19_test_gbp_scripts_config.py +++ b/tests/19_test_gbp_scripts_config.py @@ -78,7 +78,7 @@ class TestGbpConfigCommand(unittest.TestCase): 'pull' ]: printstub = self.AllValuesPrintStub(cmd) ret = gbp.scripts.config.print_cmd_all_values(cmd, printstub) - self.assertTrue('%s.color' % cmd in printstub.result.keys()) + self.assertTrue('%s.color' % cmd in list(printstub.result.keys())) self.assertEqual(ret, 0) def test_invalid_cms(self): diff --git a/tests/component/__init__.py b/tests/component/__init__.py index baabbbd..66a5e2f 100644 --- a/tests/component/__init__.py +++ b/tests/component/__init__.py @@ -24,7 +24,7 @@ import os import re import shutil import tempfile -from StringIO import StringIO +from io import StringIO from nose import SkipTest from nose.tools import eq_, ok_ # pylint: disable=E0611 diff --git a/tests/component/rpm/__init__.py b/tests/component/rpm/__init__.py index 2665575..008329b 100644 --- a/tests/component/rpm/__init__.py +++ b/tests/component/rpm/__init__.py @@ -48,7 +48,7 @@ class RepoManifest(object): for prj_e in self._doc.getElementsByTagName('project'): branches = [] for br_e in prj_e.getElementsByTagName('branch'): - branches.append(dict(br_e.attributes.items())) + branches.append(dict(list(br_e.attributes.items()))) yield prj_e.getAttribute('name'), branches diff --git a/tests/component/rpm/test_import_orig_rpm.py b/tests/component/rpm/test_import_orig_rpm.py index ebf592a..620697c 100644 --- a/tests/component/rpm/test_import_orig_rpm.py +++ b/tests/component/rpm/test_import_orig_rpm.py @@ -24,7 +24,7 @@ import tarfile import tempfile from nose.plugins.skip import SkipTest from nose.tools import assert_raises, eq_ # pylint: disable=E0611 -from StringIO import StringIO +from io import StringIO from gbp.scripts.import_orig_rpm import main as import_orig_rpm from gbp.git import GitRepository @@ -112,7 +112,7 @@ class TestImportOrig(ImportOrigTestBase): def _create_dummy_spec(path, **kwargs): """Create a dummy spec file""" with open(path, 'w') as fobj: - print kwargs + print(kwargs) fobj.write(DUMMY_SPEC % kwargs) def test_invalid_args(self): diff --git a/tests/component/rpm/test_import_srpm.py b/tests/component/rpm/test_import_srpm.py index 6635400..7dcfe22 100644 --- a/tests/component/rpm/test_import_srpm.py +++ b/tests/component/rpm/test_import_srpm.py @@ -18,7 +18,7 @@ import os import shutil -import urllib2 +import urllib.request, urllib.error, urllib.parse from nose.plugins.skip import SkipTest from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 from mock import Mock @@ -287,8 +287,8 @@ class TestDownloadImport(ComponentTestBase): 'master/gbp-test-1.0-1.src.rpm' # Mock to use local files instead of really downloading local_fn = os.path.join(DATA_DIR, os.path.basename(srpm)) - urllib2.urlopen = Mock() - urllib2.urlopen.return_value = open(local_fn, 'r') + urllib.request.urlopen = Mock() + urllib.request.urlopen.return_value = open(local_fn, 'r') eq_(mock_import(['--no-pristine-tar', '--download', srpm]), 0) # Check repository state @@ -299,8 +299,8 @@ class TestDownloadImport(ComponentTestBase): """Test graceful failure when trying download from nonexistent url""" srpm = 'http://url.does.not.exist.com/foo.src.rpm' # Do not connect to remote, mock failure - urllib2.urlopen = Mock() - urllib2.urlopen.side_effect = urllib2.HTTPError(srpm, 404, "Not found", + urllib.request.urlopen = Mock() + urllib.request.urlopen.side_effect = urllib.error.HTTPError(srpm, 404, "Not found", None, None) eq_(mock_import(['--download', srpm]), 1) diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index e44b60b..f8cfafe 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -17,9 +17,9 @@ import gbp.log gbp.log.setup(color=False, verbose=True) -repo_dir, bare_dir, clone_dir, mirror_clone_dir = map( +repo_dir, bare_dir, clone_dir, mirror_clone_dir = list(map( lambda x, tmpdir=context.new_tmpdir(__name__): tmpdir.join(x), - ['repo', 'bare', 'clone', 'mirror_clone']) + ['repo', 'bare', 'clone', 'mirror_clone'])) def test_create(): """ diff --git a/tests/test_import_orig.py b/tests/test_import_orig.py index aa39e38..72dc67f 100644 --- a/tests/test_import_orig.py +++ b/tests/test_import_orig.py @@ -52,15 +52,15 @@ class TestFindSource(TestImportOrigBase): def test_failure(self): """Test failure modes""" - with self.assertRaisesRegexp(GbpError, + with self.assertRaisesRegex(GbpError, "More than one archive specified"): find_source(False, ['too', 'much']) - with self.assertRaisesRegexp(GbpError, + with self.assertRaisesRegex(GbpError, "No archive to import specified"): find_source(False, []) - with self.assertRaisesRegexp(GbpError, + with self.assertRaisesRegex(GbpError, "you can't pass both --uscan and a filename"): find_source(True, ['tarball']) diff --git a/tests/test_rpm.py b/tests/test_rpm.py index f059f55..3b25f8c 100644 --- a/tests/test_rpm.py +++ b/tests/test_rpm.py @@ -319,7 +319,7 @@ class TestSpecFile(object): spec = SpecFileTester(spec_filepath) # Check all the tags - for name, val in spec.protected('_tags').iteritems(): + for name, val in spec.protected('_tags').items(): rval = None if name in ('version', 'release', 'epoch'): rval = '0' -- 2.7.4