Passed
Push — master ( 9f554c...be3169 )
by Marek
02:19
created

GRUB2BootloaderArgumentGenerator.csv_format()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
#!/usr/bin/python2
2
3
#
4
# create_grub2_bootloader_argument.py
5
#        generate template-based checks for unsuccessful file modifications detailed
6
7
8
from template_common import FilesGenerator, UnknownTargetError
9
10
import re
11
12
class GRUB2BootloaderArgumentGenerator(FilesGenerator):
13
    def generate(self, target, args):
14
        arg_name, arg_value = args[0:2]
15
        arg_name_value = arg_name + '=' + arg_value
16
17
        if target == "bash":
18
            self.file_from_template(
19
                "./template_BASH_grub2_bootloader_argument",
20
                {
21
                    "ARG_NAME": arg_name,
22
                    "ARG_NAME_VALUE": arg_name_value
23
                },
24
                "./bash/grub2_{0}_argument.sh", arg_name
25
            )
26
        elif target == "oval":
27
            self.file_from_template(
28
                "./template_OVAL_grub2_bootloader_argument",
29
                {
30
                    "ARG_NAME": arg_name,
31
                    "ARG_NAME_VALUE": arg_name_value
32
                },
33
                "./oval/grub2_{0}_argument.xml", arg_name
34
            )
35
        else:
36
            raise UnknownTargetError(target)
37
38
    def csv_format(self):
39
        return("CSV should contains lines of the format: " +
40
               "SYSCALL")
41