|
1
|
|
|
import re |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
# SSG Makefile to official product name mapping |
|
4
|
|
|
CHROMIUM = 'Google Chromium Browser' |
|
5
|
|
|
FEDORA = 'Fedora' |
|
6
|
|
|
FIREFOX = 'Mozilla Firefox' |
|
7
|
|
|
JRE = 'Java Runtime Environment' |
|
8
|
|
|
RHEL = 'Red Hat Enterprise Linux' |
|
9
|
|
|
DEBIAN = 'Debian' |
|
10
|
|
|
UBUNTU = 'Ubuntu' |
|
11
|
|
|
EAP = 'JBoss Enterprise Application Platform' |
|
12
|
|
|
FUSE = 'JBoss Fuse' |
|
13
|
|
|
OPENSUSE = 'openSUSE' |
|
14
|
|
|
SUSE = 'SUSE Linux Enterprise' |
|
15
|
|
|
WRLINUX = 'Wind River Linux' |
|
16
|
|
|
OL = 'Oracle Linux' |
|
17
|
|
|
OCP = 'Red Hat OpenShift Container Platform' |
|
18
|
|
|
|
|
19
|
|
|
multi_list = ["rhel", "fedora", "rhel-osp", "debian", "ubuntu", |
|
|
|
|
|
|
20
|
|
|
"wrlinux", "opensuse", "sle", "ol", "ocp"] |
|
21
|
|
|
|
|
22
|
|
|
PRODUCT_NAME_PARSER = re.compile("([a-zA-Z\-]+)([0-9]+)") |
|
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
def parse_name(product): |
|
|
|
|
|
|
26
|
|
|
product_version = None |
|
27
|
|
|
match = PRODUCT_NAME_PARSER.match(product) |
|
28
|
|
|
|
|
29
|
|
|
if match is not None: |
|
30
|
|
|
if isinstance(match.group(1), str) or \ |
|
|
|
|
|
|
31
|
|
|
isinstance(match.group(1), unicode): |
|
|
|
|
|
|
32
|
|
|
product = match.group(1) |
|
33
|
|
|
if match.group(2).isdigit(): |
|
34
|
|
|
product_version = match.group(2) |
|
35
|
|
|
|
|
36
|
|
|
return product, product_version |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
def map_name(version): |
|
|
|
|
|
|
40
|
|
|
"""Maps SSG Makefile internal product name to official product name""" |
|
41
|
|
|
|
|
42
|
|
|
if version.startswith("multi_platform_"): |
|
43
|
|
|
trimmed_version = version[len("multi_platform_"):] |
|
44
|
|
|
if trimmed_version not in multi_list: |
|
45
|
|
|
raise RuntimeError( |
|
46
|
|
|
"%s is an invalid product version. If it's multi_platform the " |
|
47
|
|
|
"suffix has to be from (%s)." |
|
48
|
|
|
% (version, ", ".join(multi_list)) |
|
49
|
|
|
) |
|
50
|
|
|
return map_name(trimmed_version) |
|
51
|
|
|
|
|
52
|
|
|
if version.startswith("chromium"): |
|
53
|
|
|
return CHROMIUM |
|
54
|
|
|
if version.startswith("fedora"): |
|
55
|
|
|
return FEDORA |
|
56
|
|
|
if version.startswith("firefox"): |
|
57
|
|
|
return FIREFOX |
|
58
|
|
|
if version.startswith("jre"): |
|
59
|
|
|
return JRE |
|
60
|
|
|
if version.startswith("rhel"): |
|
61
|
|
|
return RHEL |
|
62
|
|
|
if version.startswith("debian"): |
|
63
|
|
|
return DEBIAN |
|
64
|
|
|
if version.startswith("ubuntu"): |
|
65
|
|
|
return UBUNTU |
|
66
|
|
|
if version.startswith("eap"): |
|
67
|
|
|
return EAP |
|
68
|
|
|
if version.startswith("fuse"): |
|
69
|
|
|
return FUSE |
|
70
|
|
|
if version.startswith("opensuse"): |
|
71
|
|
|
return OPENSUSE |
|
72
|
|
|
if version.startswith("sle"): |
|
73
|
|
|
return SUSE |
|
74
|
|
|
if version.startswith("wrlinux"): |
|
75
|
|
|
return WRLINUX |
|
76
|
|
|
if version.startswith("ol"): |
|
77
|
|
|
return OL |
|
78
|
|
|
if version.startswith("ocp"): |
|
79
|
|
|
return OCP |
|
80
|
|
|
|
|
81
|
|
|
raise RuntimeError("Can't map version '%s' to any known product!" |
|
82
|
|
|
% (version)) |
|
83
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.