MCPcopy Create free account
hub / github.com/aboutcode-org/vulnerablecode / from_name

Function from_name

vulnerabilities/rpm_utils.py:57–74  ·  view source on GitHub ↗

Return an (E, N, V, R, A) tuple given a file name, by splitting [e:]name-version-release.arch into the four possible subcomponents. Default epoch, version, release and arch to None if not specified. Accepts RPM names with and without extensions

(rpm_string)

Source from the content-addressed store, hash-verified

55
56# https://github.com/nexB/scancode-toolkit/blob/16ae20a343c5332114edac34c7b6fcf2fb6bca74/src/packagedcode/nevra.py#L36
57def from_name(rpm_string):
58 """
59 Return an (E, N, V, R, A) tuple given a file name, by splitting
60 [e:]name-version-release.arch into the four possible subcomponents.
61 Default epoch, version, release and arch to None if not specified.
62 Accepts RPM names with and without extensions
63 """
64 parse_nevra = re.compile("^" "(.*)" "-" "([^-]*)" "-" "([^-]*)" "\\." "([^.]*)" "$").match
65 m = parse_nevra(rpm_string)
66 if not m:
67 return None
68 n, v, r, a = m.groups()
69 if ":" not in v:
70 return None, n, v, r, a
71 e, v = v.split(":", 1)
72 if e.isdigit():
73 e = int(e)
74 return (e, n, v, r, a)
75
76
77def rpm_to_purl(rpm_string, namespace):

Callers 1

rpm_to_purlFunction · 0.85

Calls 1

compileMethod · 0.80

Tested by

no test coverage detected