From f6a634a64e34f0b9912166a63121424dbf630498 Mon Sep 17 00:00:00 2001 From: Joost Cassee Date: Thu, 21 Jul 2011 07:17:01 +0200 Subject: [PATCH] Small changes to enumerate compatibility Also update the changelog and version number. --- CHANGELOG.rst | 4 ++++ analytical/__init__.py | 2 +- analytical/templatetags/google_analytics.py | 18 ++++++++---------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 86b4029..16c87be 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,7 @@ +Version 0.9.1 +------------- +* Fixed compatibility with Python 2.5 (Iván Raskovsky) + Version 0.9.0 ------------- * Updated Clicky tracking code to support multiple site ids. diff --git a/analytical/__init__.py b/analytical/__init__.py index eddcc3a..9b04301 100644 --- a/analytical/__init__.py +++ b/analytical/__init__.py @@ -10,6 +10,6 @@ Django_ project. See the ``docs`` directory for more information. __author__ = "Joost Cassee" __email__ = "joost@cassee.net" -__version__ = "0.9.0" +__version__ = "0.9.1" __copyright__ = "Copyright (C) 2011 Joost Cassee and others" __license__ = "MIT License" diff --git a/analytical/templatetags/google_analytics.py b/analytical/templatetags/google_analytics.py index 8c76fa5..24fcdde 100644 --- a/analytical/templatetags/google_analytics.py +++ b/analytical/templatetags/google_analytics.py @@ -10,6 +10,14 @@ from django.template import Library, Node, TemplateSyntaxError from analytical.utils import is_internal_ip, disable_html, get_required_setting +def enumerate(sequence, start=0): + """Copy of the Python 2.6 `enumerate` builtin for compatibility.""" + n = start + for elem in sequence: + yield n, elem + n += 1 + + SCOPE_VISITOR = 1 SCOPE_SESSION = 2 SCOPE_PAGE = 3 @@ -36,16 +44,6 @@ CUSTOM_VAR_CODE = "_gaq.push(['_setCustomVar', %(index)s, '%(name)s', " \ register = Library() -def enumerate(sequence, start=0): - """ - Port of 2.6's python enumerate() for compatibility with previos versions - """ - n = start - for elem in sequence: - yield n, elem - n += 1 - - @register.tag def google_analytics(parser, token): """