From 043579e468f2746ad5467e0bc45f50eaa22720b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Neuh=C3=A4user?= Date: Sat, 21 Aug 2010 20:53:05 +0200 Subject: [PATCH] Added a fallback for itertools product to pycompat for python versions < 2.6 --- sphinx/util/pycompat.py | 12 ++++++++++++ sphinx/versioning.py | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py index 5f23bbe18..faebcd01c 100644 --- a/sphinx/util/pycompat.py +++ b/sphinx/util/pycompat.py @@ -21,6 +21,18 @@ except ImportError: # Python 3 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 if sys.version_info >= (3, 0): diff --git a/sphinx/versioning.py b/sphinx/versioning.py index 430dc1423..0ea494f06 100644 --- a/sphinx/versioning.py +++ b/sphinx/versioning.py @@ -12,12 +12,13 @@ from uuid import uuid4 from operator import itemgetter from collections import defaultdict -from itertools import product try: from itertools import izip_longest as zip_longest except ImportError: from itertools import zip_longest +from sphinx.util.pycompat import product + # anything below that ratio is considered equal/changed VERSIONING_RATIO = 65