check-mir: Fix remaining PEP 8 issues (and use future print function).

This commit is contained in:
Benjamin Drung 2014-03-18 23:54:36 +01:00
parent ad94031d84
commit 50e589a239

View File

@ -21,6 +21,8 @@
# this program; if not, write to the Free Software Foundation, Inc., # this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from __future__ import print_function
import sys import sys
import optparse import optparse
import os.path import os.path
@ -42,7 +44,7 @@ def check_support(apt_cache, pkgname, alt=False):
try: try:
pkg = apt_cache[pkgname] pkg = apt_cache[pkgname]
except KeyError: except KeyError:
print >> sys.stderr, prefix, 'does not exist (pure virtual?)' print(prefix, 'does not exist (pure virtual?)', file=sys.stderr)
return False return False
section = pkg.candidate.section section = pkg.candidate.section
@ -51,30 +53,31 @@ def check_support(apt_cache, pkgname, alt=False):
# promotion # promotion
source_records = apt.apt_pkg.SourceRecords() source_records = apt.apt_pkg.SourceRecords()
if not source_records.lookup(pkg.candidate.source_name): if not source_records.lookup(pkg.candidate.source_name):
print >> sys.stderr, 'ERROR: Cannot lookup source package for', \ print('ERROR: Cannot lookup source package for', pkg.name,
pkg.name file=sys.stderr)
print prefix, 'package is in', section.split('/')[0] print(prefix, 'package is in', section.split('/')[0])
return False return False
src = apt.apt_pkg.TagSection(source_records.record) src = apt.apt_pkg.TagSection(source_records.record)
if (src['Section'].startswith('universe') or if (src['Section'].startswith('universe') or
src['Section'].startswith('multiverse')): src['Section'].startswith('multiverse')):
print prefix, 'binary and source package is in', \ print(prefix, 'binary and source package is in',
section.split('/')[0] section.split('/')[0])
return False return False
else: else:
print prefix, 'is in', section.split('/')[0] + ', but its source', \ print(prefix, 'is in', section.split('/')[0] + ', but its source',
pkg.candidate.source_name, \ pkg.candidate.source_name,
('is already in main; file an ubuntu-archive bug for ' 'is already in main; file an ubuntu-archive bug for '
'promoting the current preferred alternative') 'promoting the current preferred alternative')
return True return True
if alt: if alt:
print prefix, 'is already in main; consider preferring it' print(prefix, 'is already in main; consider preferring it')
return True return True
def check_build_dependencies(apt_cache, control): def check_build_dependencies(apt_cache, control):
print 'Checking support status of build dependencies...' print('Checking support status of build dependencies...')
any_unsupported = False any_unsupported = False
@ -93,10 +96,11 @@ def check_build_dependencies(apt_cache, control):
return any_unsupported return any_unsupported
def check_binary_dependencies(apt_cache, control): def check_binary_dependencies(apt_cache, control):
any_unsupported = False any_unsupported = False
print '\nChecking support status of binary dependencies...' print('\nChecking support status of binary dependencies...')
while True: while True:
try: try:
control.next() control.next()
@ -121,6 +125,7 @@ def check_binary_dependencies(apt_cache, control):
return any_unsupported return any_unsupported
def main(): def main():
description = "Check if any of a package's build or binary " + \ description = "Check if any of a package's build or binary " + \
"dependencies are in universe or multiverse. " + \ "dependencies are in universe or multiverse. " + \
@ -130,8 +135,8 @@ def main():
apt_cache = apt.Cache() apt_cache = apt.Cache()
if not os.path.exists('debian/control'): if not os.path.exists('debian/control'):
print >> sys.stderr, ('debian/control not found. You need to run ' print('debian/control not found. You need to run this tool in a '
'this tool in a source package directory') 'source package directory', file=sys.stderr)
sys.exit(1) sys.exit(1)
# get build dependencies from debian/control # get build dependencies from debian/control
@ -142,11 +147,11 @@ def main():
unsupported_binary_deps = check_binary_dependencies(apt_cache, control) unsupported_binary_deps = check_binary_dependencies(apt_cache, control)
if unsupported_build_deps or unsupported_binary_deps: if unsupported_build_deps or unsupported_binary_deps:
print ('\nPlease check https://wiki.ubuntu.com/MainInclusionProcess if ' print('\nPlease check https://wiki.ubuntu.com/MainInclusionProcess if '
'this source package needs to get into in main/restricted, or ' 'this source package needs to get into in main/restricted, or '
'reconsider if the package really needs above dependencies.') 'reconsider if the package really needs above dependencies.')
else: else:
print 'All dependencies are supported in main or restricted.' print('All dependencies are supported in main or restricted.')
if __name__ == '__main__': if __name__ == '__main__':
main() main()