|
17 | 17 |
|
18 | 18 | import configparser |
19 | 19 | import hashlib |
| 20 | +import re |
20 | 21 | import sys |
21 | 22 | from collections import defaultdict |
22 | 23 | from functools import reduce |
|
25 | 26 |
|
26 | 27 | from jinja2 import Environment, FileSystemLoader |
27 | 28 |
|
| 29 | +VERSION_REGEX = re.compile(r"v{?[0-9.]+.*}?|latest") |
28 | 30 |
|
29 | 31 | OUT_DIR = Path(__file__).resolve().parent.parent.parent / ".github" / "workflows" |
30 | 32 | TOX_FILE = Path(__file__).resolve().parent.parent.parent / "tox.ini" |
@@ -207,10 +209,20 @@ def parse_tox(): |
207 | 209 | line = line.strip().lower() |
208 | 210 |
|
209 | 211 | try: |
210 | | - # parse tox environment definition |
211 | | - try: |
212 | | - (raw_python_versions, framework, framework_versions) = line.split("-") |
213 | | - except ValueError: |
| 212 | + # Parse tox environment definitions. |
| 213 | + # The format is pythonversions-integrationname-integrationversions. |
| 214 | + # Some valid examples: |
| 215 | + # {pyX.Y,pyX.Z}-integrationname-vA.B.C |
| 216 | + # {pyX.Y,pyX.Z}-integrationname-v{A.B.C} |
| 217 | + # {pyX.Y,pyX.Z}-integrationname |
| 218 | + # No that integrationname can also contain dashes, which makes this a |
| 219 | + # bit more annoying. |
| 220 | + raw_python_versions = line.split("-")[0] |
| 221 | + framework_versions = line.rsplit("-", maxsplit=1)[-1] |
| 222 | + framework = line[ |
| 223 | + len(raw_python_versions) + 1 : -(len(framework_versions) + 1) |
| 224 | + ] |
| 225 | + if not VERSION_REGEX.match(framework_versions): |
214 | 226 | (raw_python_versions, framework) = line.split("-") |
215 | 227 | framework_versions = [] |
216 | 228 |
|
|
0 commit comments