From: Virgil Dupras Date: Tue, 14 Jan 2014 00:55:46 +0000 (-0500) Subject: Support Python 3.3 X-Git-Tag: release-2.1~5^2 X-Git-Url: https://git.mdrn.pl/django-pagination.git/commitdiff_plain/0b4a8b2e6f6881e26441f6a501718b63debd4a61?hp=9c0dadb323c1737b89def3be1eed9d92b3048e3b Support Python 3.3 I went for the minimal option and tried to preserve the previous logic as much as possible. I target Python 3.3 so that I don't have to touch the u'' strings. --- diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index affdc16..a703928 100644 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -60,7 +60,7 @@ def do_autopaginate(parser, token): # Check whether there are any other autopaginations are later in this template expr = lambda obj: (obj.token_type == TOKEN_BLOCK and \ len(obj.split_contents()) > 0 and obj.split_contents()[0] == "autopaginate") - multiple_paginations = len(filter(expr, parser.tokens)) > 0 + multiple_paginations = len([tok for tok in parser.tokens if expr(tok)]) > 0 i = iter(token.split_contents()) paginate_by = None @@ -69,26 +69,26 @@ def do_autopaginate(parser, token): orphans = None word = None try: - word = i.next() + word = next(i) assert word == "autopaginate" - queryset_var = i.next() - word = i.next() + queryset_var = next(i) + word = next(i) if word != "as": paginate_by = word try: paginate_by = int(paginate_by) except ValueError: pass - word = i.next() + word = next(i) if word != "as": orphans = word try: orphans = int(orphans) except ValueError: pass - word = i.next() + word = next(i) assert word == "as" - context_var = i.next() + context_var = next(i) except StopIteration: pass if queryset_var is None: diff --git a/setup.py b/setup.py index a3acd63..2686bd8 100755 --- a/setup.py +++ b/setup.py @@ -54,6 +54,8 @@ setup( "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.3", ], install_requires=[ 'django >= 1.2',