Whitespace -> PEP-8

This commit is contained in:
Stefano Rivera 2010-11-23 08:54:42 +02:00
parent 04eb3ada8b
commit b78b21f43e

View File

@ -35,8 +35,8 @@ from sys import exit, argv, stderr
import ubuntutools.misc import ubuntutools.misc
debian_distros = ['etch', 'lenny', 'squeeze', 'sid', 'stable', \ debian_distros = ['etch', 'lenny', 'squeeze', 'sid', 'stable', 'testing',
'testing', 'unstable', 'experimental'] 'unstable', 'experimental']
class pbuilder_dist: class pbuilder_dist:
@ -87,7 +87,8 @@ class pbuilder_dist:
############################################################## ##############################################################
self.base = os.path.expanduser(os.environ.get('PBUILDFOLDER', '~/pbuilder/')) self.base = os.path.expanduser(os.environ.get('PBUILDFOLDER',
'~/pbuilder/'))
if not os.path.isdir(self.base): if not os.path.isdir(self.base):
try: try:
@ -124,13 +125,14 @@ class pbuilder_dist:
% distro) % distro)
exit(1) exit(1)
if not os.path.isfile(os.path.join('/usr/share/debootstrap/scripts/', distro)): if not os.path.isfile(os.path.join('/usr/share/debootstrap/scripts/',
distro)):
if os.path.isdir('/usr/share/debootstrap/scripts/'): if os.path.isdir('/usr/share/debootstrap/scripts/'):
# Debian experimental doesn't have a debootstrap file but # Debian experimental doesn't have a debootstrap file but
# should work nevertheless. # should work nevertheless.
if distro not in debian_distros: if distro not in debian_distros:
answer = ask('Warning: Unknown distribution "%s". Do you ' \ answer = ask(('Warning: Unknown distribution "%s". Do you '
'want to continue [y/N]? ' % distro) 'want to continue [y/N]? ') % distro)
if answer not in ('y', 'Y'): if answer not in ('y', 'Y'):
exit(0) exit(0)
else: else:
@ -156,11 +158,14 @@ class pbuilder_dist:
self.operation = 'build' self.operation = 'build'
return [operation] return [operation]
else: else:
print >> stderr, 'Error: Could not find file "%s".' % operation print >> stderr, ('Error: Could not find file "%s".'
% operation)
exit(1) exit(1)
else: else:
print >> stderr, 'Error: "%s" is not a recognized argument.' % operation print >> stderr, (
print >> stderr, 'Please use one of these: %s.' % ', '.join(arguments) 'Error: "%s" is not a recognized argument.\n'
'Please use one of these: %s.'
) % (operation, ', '.join(arguments))
exit(1) exit(1)
else: else:
self.operation = operation self.operation = operation
@ -178,7 +183,8 @@ class pbuilder_dist:
self.chroot_string = self.target_distro self.chroot_string = self.target_distro
self.build_architecture = self.system_architecture self.build_architecture = self.system_architecture
else: else:
self.chroot_string = self.target_distro + '-' + self.build_architecture self.chroot_string = (self.target_distro + '-'
+ self.build_architecture)
prefix = os.path.join(self.base, self.chroot_string) prefix = os.path.join(self.base, self.chroot_string)
result = '%s_result/' % prefix result = '%s_result/' % prefix
@ -237,7 +243,8 @@ class pbuilder_dist:
else: else:
if self.build_architecture in ('amd64', 'i386'): if self.build_architecture in ('amd64', 'i386'):
arguments += ['--mirror', 'http://archive.ubuntu.com/ubuntu/'] arguments += ['--mirror', 'http://archive.ubuntu.com/ubuntu/']
elif self.build_architecture == 'powerpc' and self.target_distro == 'dapper': elif (self.build_architecture == 'powerpc'
and self.target_distro == 'dapper'):
arguments += ['--mirror', 'http://archive.ubuntu.com/ubuntu/'] arguments += ['--mirror', 'http://archive.ubuntu.com/ubuntu/']
else: else:
arguments += ['--mirror', arguments += ['--mirror',
@ -252,7 +259,8 @@ class pbuilder_dist:
arguments += ['--debootstrapopts', arguments += ['--debootstrapopts',
'--arch=' + self.build_architecture] '--arch=' + self.build_architecture]
apt_conf_dir = os.path.join(self.base, 'etc/%s/apt.conf' % self.target_distro) apt_conf_dir = os.path.join(self.base,
'etc/%s/apt.conf' % self.target_distro)
if os.path.exists(apt_conf_dir): if os.path.exists(apt_conf_dir):
arguments += ['--aptconfdir', apt_conf_dir] arguments += ['--aptconfdir', apt_conf_dir]
@ -313,9 +321,10 @@ def main():
# Copy arguments into another list for save manipulation # Copy arguments into another list for save manipulation
args = argv[1:] args = argv[1:]
if '-' in script_name and (parts[0] != 'pbuilder' and \ if ('-' in script_name and parts[0] not in ('pbuilder', 'cowbuilder')
parts[0] != 'cowbuilder') or len(parts) > 3: or len(parts) > 3):
print >> stderr, 'Error: "%s" is not a valid name for a "pbuilder-dist" executable.' % script_name print >> stderr, ('Error: "%s" is not a valid name for a '
'"pbuilder-dist" executable.') % script_name
exit(1) exit(1)
if len(args) < 1: if len(args) < 1:
@ -334,9 +343,10 @@ def main():
if len(parts) > 2: if len(parts) > 2:
requested_arch = parts[2] requested_arch = parts[2]
elif len(args) > 0 and args[0] in ("alpha", "amd64", "arm", "armeb", elif len(args) > 0 and args[0] in (
"armel", "i386", "lpia", "m68k", "mips", "mipsel", "powerpc", "ppc64", 'alpha', 'amd64', 'arm', 'armeb', 'armel', 'i386', 'lpia', 'm68k',
"sh4", "sh4eb", "sparc", "sparc64"): 'mips', 'mipsel', 'powerpc', 'ppc64', 'sh4', 'sh4eb', 'sparc',
'sparc64'):
requested_arch = args.pop(0) requested_arch = args.pop(0)
else: else:
requested_arch = None requested_arch = None
@ -344,11 +354,12 @@ def main():
if requested_arch: if requested_arch:
app.build_architecture = requested_arch app.build_architecture = requested_arch
# For some foreign architectures we need to use qemu # For some foreign architectures we need to use qemu
if requested_arch != app.system_architecture and (app.system_architecture, if (requested_arch != app.system_architecture
requested_arch) not in [("amd64", "i386"), ("amd64", "lpia"), and (app.system_architecture, requested_arch) not in [
("arm", "armel"), ("armel", "arm"), ("i386", "lpia"), ("lpia", "i386"), ('amd64', 'i386'), ('amd64', 'lpia'), ('arm', 'armel'),
("powerpc", "ppc64"), ("ppc64", "powerpc"), ("sparc", "sparc64"), ('armel', 'arm'), ('i386', 'lpia'), ('lpia', 'i386'),
("sparc64", "sparc")]: ('powerpc', 'ppc64'), ('ppc64', 'powerpc'),
('sparc', 'sparc64'), ('sparc64', 'sparc')]):
args.append('--debootstrap qemu-debootstrap') args.append('--debootstrap qemu-debootstrap')
if 'mainonly' in argv or '--main-only' in argv: if 'mainonly' in argv or '--main-only' in argv:
@ -366,12 +377,13 @@ def main():
args = app.set_operation(args.pop(0)) + args args = app.set_operation(args.pop(0)) + args
if app.operation == 'build' and not '.dsc' in ' '.join(args): if app.operation == 'build' and not '.dsc' in ' '.join(args):
print >> stderr, 'Error: You have to specify a .dsc file if you want to build.' print >> stderr, ('Error: You have to specify a .dsc file if you want '
'to build.')
exit(1) exit(1)
# Execute the pbuilder command # Execute the pbuilder command
if not '--debug-echo' in args: if not '--debug-echo' in args:
p = subprocess.Popen(app.get_command(args)) p = subprocess.Popen(app.get_command(args)))
exit(p.wait()) exit(p.wait())
else: else:
print app.get_command([arg for arg in args if arg != '--debug-echo']) print app.get_command([arg for arg in args if arg != '--debug-echo'])