Return a version found in a ``path`` or None. Prefix the version with 'v ' if the version does not start with v.
(path)
| 41 | |
| 42 | |
| 43 | def hint(path): |
| 44 | """ |
| 45 | Return a version found in a ``path`` or None. Prefix the version with 'v ' if |
| 46 | the version does not start with v. |
| 47 | """ |
| 48 | for pattern in VERSION_PATTERNS_REGEX(): |
| 49 | segments = path.split("/") |
| 50 | # skip the first path segment unless there's only one segment |
| 51 | first_segment = 1 if len(segments) > 1 else 0 |
| 52 | interesting_segments = segments[first_segment:] |
| 53 | # we iterate backwards from the end of the paths segments list |
| 54 | for segment in interesting_segments[::-1]: |
| 55 | version = re.search(pattern, segment) |
| 56 | if version: |
| 57 | v = version.group(0) |
| 58 | # prefix with v space |
| 59 | if not v.lower().startswith("v"): |
| 60 | v = f"v {v}" |
| 61 | return v |
| 62 | |
| 63 | |
| 64 | def is_dot_num(s): |
nothing calls this directly
no test coverage detected