Skip to content

Commit

Permalink
Show attributes of child elements of OVAL variables
Browse files Browse the repository at this point in the history
It's important to add attributes of these elements because they are
significant for understanding the operation performed. For example, the
arithmetic element has the arithmetic operation in the
arithmetic_operation attribute.  This commit also simplifies the
generator code.
  • Loading branch information
jan-cerny committed Jul 11, 2024
1 parent 8676dcc commit 377f0a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -619,14 +619,16 @@ function generate_endpoint_element(tbody, element_id, element_dict) {
first_col.className = "pf-m-truncate pf-m-fit-content";
row.appendChild(first_col);
first_col.appendChild(get_bold_text(remove_uuid(element_id) + ":"));

const second_col = COL.cloneNode();
second_col.setAttribute("role", "cell");
second_col.className = "pf-m-truncate pf-m-fit-content";
row.appendChild(second_col);
for (const [key, value] of Object.entries(element_dict)) {
if (key.endsWith("@text")) {
const col = COL.cloneNode();
col.setAttribute("role", "cell");
col.className = "pf-m-truncate pf-m-fit-content";
col.textContent = value;
row.appendChild(col);
if (key.endsWith("@text") || key.startsWith("var_ref@") || key.startsWith("object_ref@")) {
second_col.textContent = value;
} else if (typeof value == "object") {
// recursion
generate_endpoint_element(second_col, key, value);
} else {
const label_key = remove_uuid(key);
first_col.appendChild(get_label("pf-m-blue", `${label_key}: ${value}`));
Expand All @@ -636,20 +638,7 @@ function generate_endpoint_element(tbody, element_id, element_dict) {

function generate_endpoint_elements(tbody, data) {
for (const [element_id, element_dict] of Object.entries(data)) {
if (Object.values(element_dict).every(v => typeof v === "object")) {
const row = ROW.cloneNode();
row.setAttribute("role", "row");
tbody.appendChild(row);
const col = COL.cloneNode();
col.appendChild(get_bold_text(element_id + ":"));
row.appendChild(col);
const col2 = COL.cloneNode();
row.appendChild(col2);
// recursion
generate_endpoint_elements(col2, element_dict);
} else {
generate_endpoint_element(tbody, element_id, element_dict);
}
generate_endpoint_element(tbody, element_id, element_dict);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def _get_items(self, xml_test_property):
element_dict
)
if len(element):
element_dict = self._get_items(element)
# parse children like set, regex_capture, concat
element_dict.update(self._get_items(element))

items_of_test_property[id_in_items_of_test_property] = element_dict
return items_of_test_property

0 comments on commit 377f0a7

Please sign in to comment.