Merge pull request #734 from siduction/pep8-luksopenswaphookcfg

Fixed pep8 whininig in module luksopenswaphookcfg
This commit is contained in:
adriaandegroot 2017-06-04 11:13:24 +02:00 committed by GitHub
commit 42f4162338

View File

@ -4,6 +4,7 @@
# === This file is part of Calamares - <http://github.com/calamares> === # === This file is part of Calamares - <http://github.com/calamares> ===
# #
# Copyright 2016, Teo Mrnjavac <teo@kde.org> # Copyright 2016, Teo Mrnjavac <teo@kde.org>
# Copyright 2017, Alf Gaida <agaida@siduction.org>
# #
# Calamares is free software: you can redistribute it and/or modify # Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -33,7 +34,9 @@ def write_openswap_conf(partitions, root_mount_point, openswap_conf_path):
swap_mapper_name = partition["luksMapperName"] swap_mapper_name = partition["luksMapperName"]
elif partition["mountPoint"] == "/" and "luksMapperName" in partition: elif partition["mountPoint"] == "/" and "luksMapperName" in partition:
mountable_keyfile_device = "/dev/mapper/{!s}".format(partition["luksMapperName"]) mountable_keyfile_device = (
"/dev/mapper/{!s}".format(partition["luksMapperName"])
)
if not mountable_keyfile_device or not swap_outer_uuid: if not mountable_keyfile_device or not swap_outer_uuid:
return None return None
@ -41,7 +44,8 @@ def write_openswap_conf(partitions, root_mount_point, openswap_conf_path):
swap_device_path = "/dev/disk/by-uuid/{!s}".format(swap_outer_uuid) swap_device_path = "/dev/disk/by-uuid/{!s}".format(swap_outer_uuid)
lines = [] lines = []
with open(os.path.join(root_mount_point, openswap_conf_path), 'r') as openswap_file: with open(os.path.join(root_mount_point,
openswap_conf_path), 'r') as openswap_file:
lines = [x.strip() for x in openswap_file.readlines()] lines = [x.strip() for x in openswap_file.readlines()]
for i in range(len(lines)): for i in range(len(lines)):
@ -57,7 +61,8 @@ def write_openswap_conf(partitions, root_mount_point, openswap_conf_path):
elif lines[i].startswith("keyfile_filename"): elif lines[i].startswith("keyfile_filename"):
lines[i] = "keyfile_filename=crypto_keyfile.bin" lines[i] = "keyfile_filename=crypto_keyfile.bin"
with open(os.path.join(root_mount_point, openswap_conf_path), 'w') as openswap_file: with open(os.path.join(root_mount_point,
openswap_conf_path), 'w') as openswap_file:
openswap_file.write("\n".join(lines) + "\n") openswap_file.write("\n".join(lines) + "\n")
return None return None
@ -75,4 +80,6 @@ def run():
openswap_conf_path = openswap_conf_path.lstrip('/') openswap_conf_path = openswap_conf_path.lstrip('/')
return write_openswap_conf(partitions, root_mount_point, openswap_conf_path) return write_openswap_conf(
partitions, root_mount_point, openswap_conf_path
)