10
10
from __future__ import annotations
11
11
12
12
from dataclasses import dataclass
13
- from itertools import product , zip_longest
13
+ from itertools import cycle , product , zip_longest
14
14
from typing import Any
15
15
16
16
from shrub .v3 .evg_build_variant import BuildVariant
@@ -69,7 +69,7 @@ def create_variant(
69
69
70
70
71
71
def get_python_binary (python : str , host : str ) -> str :
72
- """Get the appropriate python binary given a python version and host"""
72
+ """Get the appropriate python binary given a python version and host. """
73
73
if host == "win64" :
74
74
is_32 = python .startswith ("32-bit" )
75
75
if is_32 :
@@ -98,22 +98,11 @@ def get_display_name(base: str, host: str, version: str, python: str) -> str:
98
98
return f"{ base } { HOSTS [host ].display_name } { version } { python } "
99
99
100
100
101
- def get_pairs (versions : list [str ], pythons : list [str ]) -> str :
102
- """Get pairs of versions and pythons, ensuring that we hit all of each.
103
- The shorter list will repeat until the full length of the longer list.
104
- """
105
- values = []
106
- i = 0
107
- for version , python in zip_longest (versions , pythons ):
108
- if version is None :
109
- values .append ((versions [i % len (versions )], python ))
110
- i += 1
111
- elif python is None :
112
- values .append ((version , pythons [i % len (pythons )]))
113
- i += 1
114
- else :
115
- values .append ((version , python ))
116
- return values
101
+ def zip_cycle (* iterables , empty_default = None ):
102
+ """Get all combinations of the inputs, cycling over the shorter list(s)."""
103
+ cycles = [cycle (i ) for i in iterables ]
104
+ for _ in zip_longest (* iterables ):
105
+ yield tuple (next (i , empty_default ) for i in cycles )
117
106
118
107
119
108
##############
@@ -130,7 +119,7 @@ def create_ocsp_variants() -> list[BuildVariant]:
130
119
131
120
# OCSP tests on rhel8 with all server v4.4+ and python versions.
132
121
versions = [v for v in ALL_VERSIONS if v != "4.0" ]
133
- for version , python in get_pairs (versions , ALL_PYTHONS ):
122
+ for version , python in zip_cycle (versions , ALL_PYTHONS ):
134
123
expansions = base_expansions .copy ()
135
124
expansions ["VERSION" ] = version
136
125
host = "rhel8"
0 commit comments