Simplify dict() construction for fstab-lines

main
Adriaan de Groot 8 years ago
parent d355a42a44
commit d8a47bb8be

@ -233,6 +233,8 @@ class FstabGenerator(object):
if not mount_point and not filesystem == "swap": if not mount_point and not filesystem == "swap":
return None return None
if not mount_point:
mount_point = "swap"
options = self.mount_options.get(filesystem, options = self.mount_options.get(filesystem,
self.mount_options["default"]) self.mount_options["default"])
@ -253,42 +255,20 @@ class FstabGenerator(object):
self.root_is_ssd = is_ssd self.root_is_ssd = is_ssd
if filesystem == "btrfs" and "subvol" in partition: if filesystem == "btrfs" and "subvol" in partition:
if has_luks: options="subvol={},".format(partition["subvol"]) + options
return dict(
device="/dev/mapper/" + partition["luksMapperName"], if has_luks:
mount_point=mount_point, device="/dev/mapper/" + partition["luksMapperName"]
fs=filesystem, else:
options=",".join( device="UUID=" + partition["uuid"]
["subvol={}".format(partition["subvol"]), options]
), return dict(device=device,
check=check,
)
else:
return dict(
device="UUID=" + partition["uuid"],
mount_point=mount_point, mount_point=mount_point,
fs=filesystem, fs=filesystem,
options=",".join( options=options,
["subvol={}".format(partition["subvol"]), options]
),
check=check, check=check,
) )
if has_luks:
return dict(device="/dev/mapper/" + partition["luksMapperName"],
mount_point=mount_point or "swap",
fs=filesystem,
options=options,
check=check,
)
else:
return dict(device="UUID=" + partition["uuid"],
mount_point=mount_point or "swap",
fs=filesystem,
options=options,
check=check,
)
def print_fstab_line(self, dct, file=None): def print_fstab_line(self, dct, file=None):
""" Prints line to '/etc/fstab' file. """ """ Prints line to '/etc/fstab' file. """
line = "{:41} {:<14} {:<7} {:<10} 0 {}".format(dct["device"], line = "{:41} {:<14} {:<7} {:<10} 0 {}".format(dct["device"],

Loading…
Cancel
Save