Parse the version strings.
(lhs: str, rhs: str)
| 510 | |
| 511 | |
| 512 | def parse_version_strs(lhs: str, rhs: str) -> tuple[Iterable[int | str], Iterable[int | str]]: |
| 513 | """ |
| 514 | Parse the version strings. |
| 515 | """ |
| 516 | |
| 517 | def _try_cast(val: str) -> int | str: |
| 518 | val = val.strip() |
| 519 | try: |
| 520 | m = match("(\\d+)(.*)", val) |
| 521 | if m is not None: |
| 522 | val = m.groups()[0] |
| 523 | return int(val) |
| 524 | return val |
| 525 | except ValueError: |
| 526 | return val |
| 527 | |
| 528 | # remove git version suffixes if present |
| 529 | lhs = lhs.split("+", 1)[0] |
| 530 | rhs = rhs.split("+", 1)[0] |
| 531 | |
| 532 | # parse the version strings in this basic way without `packaging` package |
| 533 | lhs_ = map(_try_cast, lhs.split(".")) |
| 534 | rhs_ = map(_try_cast, rhs.split(".")) |
| 535 | return lhs_, rhs_ |
| 536 | |
| 537 | |
| 538 | def version_leq(lhs: str, rhs: str) -> bool: |
no test coverage detected
searching dependent graphs…