Fixed pep8 whining in module grubcfg

added myself to copyright
This commit is contained in:
Alf Gaida 2017-03-29 17:22:44 +02:00
parent 65b5d67a08
commit 4eb0e70984

View File

@ -5,6 +5,7 @@
#
# Copyright 2014-2015, Philip Müller <philm@manjaro.org>
# Copyright 2015-2017, Teo Mrnjavac <teo@kde.org>
# Copyright 2017, Alf Gaida <agaida@siduction.org>
#
# Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -25,7 +26,8 @@ import re
def modify_grub_default(partitions, root_mount_point, distributor):
""" Configures '/etc/default/grub' for hibernation and plymouth.
"""
Configures '/etc/default/grub' for hibernation and plymouth.
:param partitions:
:param root_mount_point:
@ -35,7 +37,9 @@ def modify_grub_default(partitions, root_mount_point, distributor):
default_dir = os.path.join(root_mount_point, "etc/default")
default_grub = os.path.join(default_dir, "grub")
distributor_replace = distributor.replace("'", "'\\''")
dracut_bin = libcalamares.utils.target_env_call(["sh", "-c", "which dracut"])
dracut_bin = libcalamares.utils.target_env_call(
["sh", "-c", "which dracut"]
)
use_splash = ""
swap_uuid = ""
swap_outer_uuid = ""
@ -51,20 +55,26 @@ def modify_grub_default(partitions, root_mount_point, distributor):
if partition["fs"] == "linuxswap":
swap_uuid = partition["uuid"]
if partition["fs"] == "linuxswap" and "luksMapperName" in partition:
if (partition["fs"] == "linuxswap"
and "luksMapperName" in partition):
swap_outer_uuid = partition["luksUuid"]
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
cryptdevice_params = ["rd.luks.uuid={!s}".format(partition["luksUuid"])]
if (partition["mountPoint"] == "/"
and "luksMapperName" in partition):
cryptdevice_params = [
"rd.luks.uuid={!s}".format(partition["luksUuid"])
]
else:
for partition in partitions:
if partition["fs"] == "linuxswap":
swap_uuid = partition["uuid"]
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
if (partition["mountPoint"] == "/"
and "luksMapperName" in partition):
cryptdevice_params = [
"cryptdevice=UUID={!s}:{!s}".format(partition["luksUuid"],
partition["luksMapperName"]),
"cryptdevice=UUID={!s}:{!s}".format(
partition["luksUuid"], partition["luksMapperName"]
),
"root=/dev/mapper/{!s}".format(partition["luksMapperName"])
]
@ -101,7 +111,9 @@ def modify_grub_default(partitions, root_mount_point, distributor):
for i in range(len(lines)):
if lines[i].startswith("#GRUB_CMDLINE_LINUX_DEFAULT"):
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(" ".join(kernel_params))
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(
" ".join(kernel_params)
)
lines[i] = kernel_cmd
have_kernel_cmd = True
elif lines[i].startswith("GRUB_CMDLINE_LINUX_DEFAULT"):
@ -118,20 +130,26 @@ def modify_grub_default(partitions, root_mount_point, distributor):
for existing_param in existing_params:
existing_param_name = existing_param.split("=")[0]
if existing_param_name not in ["quiet", "resume", "splash"]: # the only ones we ever add
# the only ones we ever add
if existing_param_name not in [
"quiet", "resume", "splash"]:
kernel_params.append(existing_param)
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(" ".join(kernel_params))
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(
" ".join(kernel_params)
)
lines[i] = kernel_cmd
have_kernel_cmd = True
elif lines[i].startswith("#GRUB_DISTRIBUTOR") or lines[i].startswith("GRUB_DISTRIBUTOR"):
elif (lines[i].startswith("#GRUB_DISTRIBUTOR")
or lines[i].startswith("GRUB_DISTRIBUTOR")):
lines[i] = distributor_line
have_distributor_line = True
else:
lines = []
if "defaults" in libcalamares.job.configuration:
for key, value in libcalamares.job.configuration["defaults"].items():
for key, value in libcalamares.job.configuration[
"defaults"].items():
if value.__class__.__name__ == "bool":
if value:
escaped_value = "true"
@ -143,7 +161,9 @@ def modify_grub_default(partitions, root_mount_point, distributor):
lines.append("{!s}='{!s}'".format(key, escaped_value))
if not have_kernel_cmd:
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(" ".join(kernel_params))
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(
" ".join(kernel_params)
)
lines.append(kernel_cmd)
if not have_distributor_line:
@ -159,14 +179,16 @@ def modify_grub_default(partitions, root_mount_point, distributor):
def run():
""" Calls routine with given parameters to modify '/etc/default/grub'.
"""
Calls routine with given parameters to modify '/etc/default/grub'.
:return:
"""
fw_type = libcalamares.globalstorage.value("firmwareType")
if libcalamares.globalstorage.value("bootLoader") is None and fw_type != "efi":
if (libcalamares.globalstorage.value("bootLoader") is None
and fw_type != "efi"):
return None
partitions = libcalamares.globalstorage.value("partitions")
@ -175,7 +197,8 @@ def run():
esp_found = False
for partition in partitions:
if partition["mountPoint"] == libcalamares.globalstorage.value("efiSystemPartition"):
if (partition["mountPoint"]
== libcalamares.globalstorage.value("efiSystemPartition")):
esp_found = True
if not esp_found: