diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-06-27 12:56:38 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-02 23:08:37 +0100 |
commit | 052c8198d783cf126594efac7969e49a7b3be99f (patch) | |
tree | 5ff883d51fabc6c3191d585588c015346f94ca1e /scripts/lib/wic | |
parent | 73d0d23014e041f206cfaa3cd40c7ba9fc35d5d6 (diff) | |
download | poky-052c8198d783cf126594efac7969e49a7b3be99f.tar.gz |
wic: Call methods better way
Shortened code by using getattr to obtain a method to call for
prepare_empty_partition_* and prepare_rootfs_* methods.
(From OE-Core rev: 066f713f71828ff6f408448e5ea4fcd56faa423e)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r-- | scripts/lib/wic/kickstart/custom_commands/partition.py | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py index e3ae3ce765..0741bb2ab1 100644 --- a/scripts/lib/wic/kickstart/custom_commands/partition.py +++ b/scripts/lib/wic/kickstart/custom_commands/partition.py | |||
@@ -160,8 +160,12 @@ class Wic_PartData(Mic_PartData): | |||
160 | self.prepare_swap_partition(cr_workdir, oe_builddir, | 160 | self.prepare_swap_partition(cr_workdir, oe_builddir, |
161 | native_sysroot) | 161 | native_sysroot) |
162 | elif self.fstype: | 162 | elif self.fstype: |
163 | self.prepare_empty_partition(cr_workdir, oe_builddir, | 163 | for prefix in ("ext", "btrfs", "vfat", "squashfs"): |
164 | native_sysroot) | 164 | if self.fstype.startswith(prefix): |
165 | method = getattr(self, | ||
166 | "prepare_empty_partition_" + prefix) | ||
167 | method(cr_workdir, oe_builddir, native_sysroot) | ||
168 | break | ||
165 | return | 169 | return |
166 | 170 | ||
167 | plugins = pluginmgr.get_source_plugins() | 171 | plugins = pluginmgr.get_source_plugins() |
@@ -223,23 +227,11 @@ class Wic_PartData(Mic_PartData): | |||
223 | if os.path.isfile(rootfs): | 227 | if os.path.isfile(rootfs): |
224 | os.remove(rootfs) | 228 | os.remove(rootfs) |
225 | 229 | ||
226 | if self.fstype.startswith("ext"): | 230 | for prefix in ("ext", "btrfs", "vfat", "squashfs"): |
227 | return self.prepare_rootfs_ext(rootfs, oe_builddir, | 231 | if self.fstype.startswith(prefix): |
228 | rootfs_dir, native_sysroot, | 232 | method = getattr(self, "prepare_rootfs_" + prefix) |
229 | pseudo) | 233 | return method(rootfs, oe_builddir, rootfs_dir, |
230 | elif self.fstype.startswith("btrfs"): | 234 | native_sysroot, pseudo) |
231 | return self.prepare_rootfs_btrfs(rootfs, oe_builddir, | ||
232 | rootfs_dir, native_sysroot, | ||
233 | pseudo) | ||
234 | |||
235 | elif self.fstype.startswith("vfat"): | ||
236 | return self.prepare_rootfs_vfat(rootfs, oe_builddir, | ||
237 | rootfs_dir, native_sysroot, | ||
238 | pseudo) | ||
239 | elif self.fstype.startswith("squashfs"): | ||
240 | return self.prepare_rootfs_squashfs(rootfs, oe_builddir, | ||
241 | rootfs_dir, native_sysroot, | ||
242 | pseudo) | ||
243 | 235 | ||
244 | def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir, | 236 | def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir, |
245 | native_sysroot, pseudo): | 237 | native_sysroot, pseudo): |
@@ -391,23 +383,6 @@ class Wic_PartData(Mic_PartData): | |||
391 | 383 | ||
392 | return 0 | 384 | return 0 |
393 | 385 | ||
394 | def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot): | ||
395 | """ | ||
396 | Prepare an empty partition. | ||
397 | """ | ||
398 | if self.fstype.startswith("ext"): | ||
399 | return self.prepare_empty_partition_ext(cr_workdir, oe_builddir, | ||
400 | native_sysroot) | ||
401 | elif self.fstype.startswith("btrfs"): | ||
402 | return self.prepare_empty_partition_btrfs(cr_workdir, oe_builddir, | ||
403 | native_sysroot) | ||
404 | elif self.fstype.startswith("vfat"): | ||
405 | return self.prepare_empty_partition_vfat(cr_workdir, oe_builddir, | ||
406 | native_sysroot) | ||
407 | elif self.fstype.startswith("squashfs"): | ||
408 | return self.prepare_empty_partition_squashfs(cr_workdir, oe_builddir, | ||
409 | native_sysroot) | ||
410 | |||
411 | def prepare_empty_partition_ext(self, cr_workdir, oe_builddir, | 386 | def prepare_empty_partition_ext(self, cr_workdir, oe_builddir, |
412 | native_sysroot): | 387 | native_sysroot): |
413 | """ | 388 | """ |