Skip to content

Commit

Permalink
Fix Code Climate problem
Browse files Browse the repository at this point in the history
Reduce code complexity
  • Loading branch information
jan-cerny committed Sep 12, 2023
1 parent 56e92b7 commit 6d0a593
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/ssg_test_suite/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,7 @@ def install_packages(test_env, packages):
"Couldn't install required packages: {packages}".format(packages=",".join(packages)))


def cpe_to_platform(cpe):
trivials = ["fedora", "sles", "ubuntu"]
for platform in trivials:
if platform in cpe:
return platform
def _match_rhel_version(cpe):
rhel_cpe = {
"redhat:enterprise_linux": r":enterprise_linux:([^:]+):",
"centos:centos": r"centos:centos:([0-9]+)"}
Expand All @@ -616,6 +612,16 @@ def cpe_to_platform(cpe):
if match:
major_version = match.groups()[0].split(".")[0]
return "rhel" + major_version


def cpe_to_platform(cpe):
trivials = ["fedora", "sles", "ubuntu"]
for platform in trivials:
if platform in cpe:
return platform
rhel_version = _match_rhel_version(cpe)
if rhel_version is not None:
return rhel_version
if "oracle:linux" in cpe:
match = re.search(r":linux:([^:]+):", cpe)
if match:
Expand Down

0 comments on commit 6d0a593

Please sign in to comment.