Fallback values in a prettier way

This commit is contained in:
Anders Ingemann 2013-12-30 20:44:29 +01:00
parent 83e1339145
commit 8b5bc77650
3 changed files with 4 additions and 12 deletions

View file

@ -29,9 +29,7 @@ class GPTPartitionMap(AbstractPartitionMap):
for partition in self.partitions: for partition in self.partitions:
partition.create(volume) partition.create(volume)
boot_idx = self.root.get_index() boot_idx = getattr(self, 'boot', self.root).get_index()
if hasattr(self, 'boot'):
boot_idx = self.boot.get_index()
log_check_call(['/sbin/parted', '--script', volume.device_path, log_check_call(['/sbin/parted', '--script', volume.device_path,
'--', 'set ' + str(boot_idx) + ' boot on']) '--', 'set ' + str(boot_idx) + ' boot on'])
log_check_call(['/sbin/parted', '--script', volume.device_path, log_check_call(['/sbin/parted', '--script', volume.device_path,

View file

@ -32,8 +32,6 @@ class MBRPartitionMap(AbstractPartitionMap):
for partition in self.partitions: for partition in self.partitions:
partition.create(volume) partition.create(volume)
boot_idx = self.root.get_index() boot_idx = getattr(self, 'boot', self.root).get_index()
if hasattr(self, 'boot'):
boot_idx = self.boot.get_index()
log_check_call(['/sbin/parted', '--script', volume.device_path, log_check_call(['/sbin/parted', '--script', volume.device_path,
'--', 'set ' + str(boot_idx) + ' boot on']) '--', 'set ' + str(boot_idx) + ' boot on'])

View file

@ -10,14 +10,10 @@ class PackageList(object):
self.local = set() self.local = set()
if 'remote' in data: if 'remote' in data:
for package in data['remote']: for package in data['remote']:
target = None
if isinstance(package, dict): if isinstance(package, dict):
name = package['name'] self.add(package['name'], package.get('target', None))
if 'target' in package:
target = package['target']
else: else:
name = package self.add(package, None)
self.add(name, target)
if 'local' in data: if 'local' in data:
for package_path in data['local']: for package_path in data['local']:
self.local.add(package_path) self.local.add(package_path)