Skip to content

Commit

Permalink
Fix python2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Honny1 committed Jan 18, 2024
1 parent 140a4d6 commit 2d19ce6
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions utils/profile_tool/most_used_rules.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import sys
import json

from ssg.build_profile import XCCDFBenchmark
from .profile import get_profile
from ..controleval import (
load_controls_manager,
get_available_products,
get_product_profiles_files,
)


PYTHON_2 = sys.version_info[0] < 3

if not PYTHON_2:
from .profile import get_profile
from ..controleval import (
load_controls_manager,
get_available_products,
get_product_profiles_files,
)


def _count_rules_per_rules_list(rules_list, rules):
Expand Down Expand Up @@ -52,10 +58,12 @@ def command_most_used_rules(args):
rules = {}

if len(args.BENCHMARKS) == 0:
if PYTHON_2:
raise Exception("This feature is not supported for python2.")
_process_all_products_from_controls(rules)
else:
for benchmark in args.BENCHMARKS:
_count_rules_per_benchmark(benchmark, rules)

for benchmark in args.BENCHMARKS:
_count_rules_per_benchmark(benchmark, rules)

sorted_rules = _sorted_rules(rules)

Expand Down

0 comments on commit 2d19ce6

Please sign in to comment.