Skip to content

Commit

Permalink
Refactor: Extract function get_cis_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-cerny committed Feb 20, 2024
1 parent ea336e9 commit f8ab2b3
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions ssg/build_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ def __init__(self, rid=None, roval=None, rsce=None,
self.dict['fix'] = ranaconda_fix


def get_cis_uri(product):
cis_uri = cis_ns
if product:
constants_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "products", product, "transforms/constants.xslt")
if os.path.exists(constants_path):
root = ElementTree.parse(constants_path)
cis_var = root.find('./{%s}variable[@name="cisuri"]' % (xslt_ns))
if cis_var is not None and cis_var.text:
cis_uri = cis_var.text
return cis_uri


class XCCDFBenchmark(object):
"""
Class for processing an XCCDF benchmark to generate
Expand Down Expand Up @@ -131,15 +143,7 @@ def __init__(self, filepath, product=""):
raise RuntimeError("Multiple rules exist with same id attribute: %s!" % rule_id)

self.indexed_rules[rule_id] = rule

self.cis_ns = cis_ns
if product:
constants_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "products", product, "transforms/constants.xslt")
if os.path.exists(constants_path):
root = ElementTree.parse(constants_path)
cis_var = root.find('./{%s}variable[@name="cisuri"]' % (xslt_ns))
if cis_var is not None and cis_var.text:
self.cis_ns = cis_var.text
self.cis_ns = get_cis_uri(product)

def get_profile_stats(self, profile):
"""Obtain statistics for the profile"""
Expand Down

0 comments on commit f8ab2b3

Please sign in to comment.