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)
| 55 | |
| 56 | # https://github.com/nexB/scancode-toolkit/blob/16ae20a343c5332114edac34c7b6fcf2fb6bca74/src/packagedcode/nevra.py#L36 |
| 57 | def 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 | |
| 77 | def rpm_to_purl(rpm_string, namespace): |