mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
grub: Prettier type checking when writing grub defaults
This commit is contained in:
parent
e030b9f84f
commit
2ffc4dd6c3
1 changed files with 9 additions and 15 deletions
|
@ -200,23 +200,17 @@ class WriteGrubConfig(Task):
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
grub_config_contents = ''
|
grub_config_contents = ''
|
||||||
for key, value in info.grub_config.items():
|
for key, value in info.grub_config.items():
|
||||||
if value is None:
|
|
||||||
continue
|
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
grub_config_contents += '{}="{}"\n'.format(key, value)
|
grub_config_contents += '{}="{}"\n'.format(key, value)
|
||||||
continue
|
elif isinstance(value, int):
|
||||||
if isinstance(value, int):
|
|
||||||
grub_config_contents += '{}={}\n'.format(key, value)
|
grub_config_contents += '{}={}\n'.format(key, value)
|
||||||
continue
|
elif isinstance(value, bool):
|
||||||
if isinstance(value, bool):
|
|
||||||
grub_config_contents += '{}="{}"\n'.format(key, str(value).lower())
|
grub_config_contents += '{}="{}"\n'.format(key, str(value).lower())
|
||||||
continue
|
elif isinstance(value, list):
|
||||||
if isinstance(value, list):
|
if len(value) > 0:
|
||||||
if len(value) == 0:
|
|
||||||
continue
|
|
||||||
args_list = ' '.join(map(str, value))
|
args_list = ' '.join(map(str, value))
|
||||||
grub_config_contents += '{}="{}"\n'.format(key, args_list)
|
grub_config_contents += '{}="{}"\n'.format(key, args_list)
|
||||||
continue
|
elif value is not None:
|
||||||
raise TaskError('Don\'t know how to handle type {}, '
|
raise TaskError('Don\'t know how to handle type {}, '
|
||||||
'when creating grub config'.format(type(value)))
|
'when creating grub config'.format(type(value)))
|
||||||
grub_defaults = os.path.join(info.root, 'etc/default/grub')
|
grub_defaults = os.path.join(info.root, 'etc/default/grub')
|
||||||
|
|
Loading…
Add table
Reference in a new issue