File: variable.py

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (41 lines) | stat: -rw-r--r-- 1,267 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from ...constants import STR_TO_BOOL
from ..general import (
    OVALEntity,
    load_property_and_notes_of_oval_entity,
    required_attribute,
)


def load_variable(oval_variable_xml_el):
    variable_property, notes = load_property_and_notes_of_oval_entity(
        oval_variable_xml_el
    )

    variable = Variable(
        oval_variable_xml_el.tag,
        required_attribute(oval_variable_xml_el, "id"),
        required_attribute(oval_variable_xml_el, "datatype"),
        variable_property,
    )
    variable.comment = oval_variable_xml_el.get("comment", "")
    variable.deprecated = STR_TO_BOOL.get(
        oval_variable_xml_el.get("deprecated", ""), False
    )
    variable.notes = notes
    variable.version = required_attribute(oval_variable_xml_el, "version")
    return variable


class Variable(OVALEntity):
    def __init__(self, tag, id_, data_type, properties):
        super(Variable, self).__init__(tag, id_, properties)
        self.data_type = data_type

    def get_xml_element(self):
        return super(Variable, self).get_xml_element(datatype=self.data_type)

    def get_variable_references(self):
        return self._get_references("var_ref")

    def get_object_references(self):
        return self._get_references("object_ref")