From 8b5bc7765064bb7e90ab48140068b2da6bf25a63 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Mon, 30 Dec 2013 20:44:29 +0100 Subject: [PATCH] Fallback values in a prettier way --- base/fs/partitionmaps/gpt.py | 4 +--- base/fs/partitionmaps/mbr.py | 4 +--- base/pkg/packagelist.py | 8 ++------ 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/base/fs/partitionmaps/gpt.py b/base/fs/partitionmaps/gpt.py index 2d45229..bc0b03e 100644 --- a/base/fs/partitionmaps/gpt.py +++ b/base/fs/partitionmaps/gpt.py @@ -29,9 +29,7 @@ class GPTPartitionMap(AbstractPartitionMap): for partition in self.partitions: partition.create(volume) - boot_idx = self.root.get_index() - if hasattr(self, 'boot'): - boot_idx = self.boot.get_index() + boot_idx = getattr(self, 'boot', self.root).get_index() log_check_call(['/sbin/parted', '--script', volume.device_path, '--', 'set ' + str(boot_idx) + ' boot on']) log_check_call(['/sbin/parted', '--script', volume.device_path, diff --git a/base/fs/partitionmaps/mbr.py b/base/fs/partitionmaps/mbr.py index 8b04d12..d90cdbe 100644 --- a/base/fs/partitionmaps/mbr.py +++ b/base/fs/partitionmaps/mbr.py @@ -32,8 +32,6 @@ class MBRPartitionMap(AbstractPartitionMap): for partition in self.partitions: partition.create(volume) - boot_idx = self.root.get_index() - if hasattr(self, 'boot'): - boot_idx = self.boot.get_index() + boot_idx = getattr(self, 'boot', self.root).get_index() log_check_call(['/sbin/parted', '--script', volume.device_path, '--', 'set ' + str(boot_idx) + ' boot on']) diff --git a/base/pkg/packagelist.py b/base/pkg/packagelist.py index 8edebe4..9fb0917 100644 --- a/base/pkg/packagelist.py +++ b/base/pkg/packagelist.py @@ -10,14 +10,10 @@ class PackageList(object): self.local = set() if 'remote' in data: for package in data['remote']: - target = None if isinstance(package, dict): - name = package['name'] - if 'target' in package: - target = package['target'] + self.add(package['name'], package.get('target', None)) else: - name = package - self.add(name, target) + self.add(package, None) if 'local' in data: for package_path in data['local']: self.local.add(package_path)