mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Added a fallback for itertools product to pycompat for python versions < 2.6
This commit is contained in:
parent
aa9fabc1e1
commit
043579e468
@ -21,6 +21,18 @@ except ImportError:
|
|||||||
# Python 3
|
# Python 3
|
||||||
class_types = (type,)
|
class_types = (type,)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from itertools import product
|
||||||
|
except ImportError: # python < 2.6
|
||||||
|
# this code has been taken from the python documentation
|
||||||
|
def product(*args, **kwargs):
|
||||||
|
pools = map(tuple, args) * kwargs.get('repeat', 1)
|
||||||
|
result = [[]]
|
||||||
|
for pool in pools:
|
||||||
|
result = [x + [y] for x in result for y in pool]
|
||||||
|
for prod in result:
|
||||||
|
yield tuple(prod)
|
||||||
|
|
||||||
|
|
||||||
# the ubiquitous "bytes" helper function
|
# the ubiquitous "bytes" helper function
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
|
@ -12,12 +12,13 @@
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from itertools import product
|
|
||||||
try:
|
try:
|
||||||
from itertools import izip_longest as zip_longest
|
from itertools import izip_longest as zip_longest
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
|
|
||||||
|
from sphinx.util.pycompat import product
|
||||||
|
|
||||||
|
|
||||||
# anything below that ratio is considered equal/changed
|
# anything below that ratio is considered equal/changed
|
||||||
VERSIONING_RATIO = 65
|
VERSIONING_RATIO = 65
|
||||||
|
Loading…
Reference in New Issue
Block a user