Port requestbackport to Python 3

This commit is contained in:
Stefano Rivera 2019-09-04 16:09:16 -03:00
parent 0de4509da6
commit 7c0efe2914
3 changed files with 16 additions and 14 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
#
# Copyright (C) 2011, Stefano Rivera <stefanor@ubuntu.com>
#
@ -123,7 +123,7 @@ def find_rdepends(releases, published_binaries):
except RDependsException:
# Not published? TODO: Check
continue
for relationship, rdeps in raw_rdeps.iteritems():
for relationship, rdeps in raw_rdeps.items():
for rdep in rdeps:
# Ignore circular deps:
if rdep['Package'] in published_binaries:
@ -134,14 +134,14 @@ def find_rdepends(releases, published_binaries):
intermediate[binpkg][rdep['Package']].append((release, relationship))
output = []
for binpkg, rdeps in intermediate.iteritems():
for binpkg, rdeps in intermediate.items():
output += ['', binpkg, '-' * len(binpkg)]
for pkg, appearences in rdeps.iteritems():
for pkg, appearences in rdeps.items():
output += ['* %s' % pkg]
for release, relationship in appearences:
output += [' [ ] %s (%s)' % (release, relationship)]
found_any = sum(len(rdeps) for rdeps in intermediate.itervalues())
found_any = sum(len(rdeps) for rdeps in intermediate.values())
if found_any:
output = [
"Reverse dependencies:",
@ -168,7 +168,7 @@ def locate_package(package, distribution):
try:
package_spph = archive.getSourcePackage(package, distribution)
return package_spph
except PackageNotFoundException, e:
except PackageNotFoundException as e:
if pass_ == 'binary':
Logger.error(str(e))
sys.exit(1)
@ -292,7 +292,7 @@ def main():
try:
destinations = determine_destinations(options.source,
options.destination)
except DestinationException, e:
except DestinationException as e:
Logger.error(str(e))
sys.exit(1)

View File

@ -33,6 +33,7 @@ if sys.version_info[0] >= 3:
'pull-lp-source',
'pull-revu-source',
'pull-uca-source',
'requestbackport',
'reverse-build-depends',
'setup-packaging-environment',
]
@ -46,7 +47,6 @@ else:
scripts = [
'import-bug-from-debian',
'merge-changelog',
'requestbackport',
'requestsync',
'reverse-depends',
'seeded-in-ubuntu',

View File

@ -18,6 +18,7 @@
from __future__ import print_function
import codecs
import tempfile
import os
import re
@ -27,6 +28,7 @@ import ubuntutools.subprocess
if sys.version_info[0] < 3:
input = raw_input # noqa, pylint: disable=undefined-variable
open = codecs.open
class Question(object):
@ -133,7 +135,7 @@ class EditFile(object):
def edit(self, optional=False):
if optional:
print("\n\nCurrently the %s looks like:" % self.description)
with open(self.filename, 'r') as f:
with open(self.filename, 'r', encoding='utf-8') as f:
print(f.read())
if YesNoQuestion().ask("Edit", "no") == "no":
return
@ -146,7 +148,7 @@ class EditFile(object):
modified = old_mtime != os.stat(self.filename).st_mtime
placeholders_present = False
if self.placeholders:
with open(self.filename, 'r') as f:
with open(self.filename, 'r', encoding='utf-8') as f:
for line in f:
for placeholder in self.placeholders:
if placeholder.search(line.strip()):
@ -188,8 +190,8 @@ class EditBugReport(EditFile):
placeholders)
def check_edit(self):
with open(self.filename, 'r') as f:
report = f.read().decode('utf-8')
with open(self.filename, 'r', encoding='utf-8') as f:
report = f.read()
if self.split_re.match(report) is None:
print("The %s doesn't start with 'Summary:' and 'Description:' "
@ -199,8 +201,8 @@ class EditBugReport(EditFile):
return True
def get_report(self):
with open(self.filename, 'r') as f:
report = f.read().decode('utf-8')
with open(self.filename, 'r', encoding='utf-8') as f:
report = f.read()
match = self.split_re.match(report)
title = match.group(1).replace(u'\n', u' ')