From: Michał Górny Date: Sun, 13 Jan 2013 21:58:30 +0000 (+0100) Subject: Fix jinjaext compatibility with Python 3. X-Git-Tag: 2.7~91^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67c24803e6bd1f43d919fe0a89c21fc98f2f5402;p=thirdparty%2Fjinja.git Fix jinjaext compatibility with Python 3. Patch by Arfrever. Fixes: https://github.com/mitsuhiko/jinja2/issues/115 --- diff --git a/docs/jinjaext.py b/docs/jinjaext.py index 12b54470..8395a554 100644 --- a/docs/jinjaext.py +++ b/docs/jinjaext.py @@ -8,6 +8,7 @@ :copyright: Copyright 2008 by Armin Ronacher. :license: BSD. """ +import collections import os import re import inspect @@ -22,6 +23,7 @@ from pygments.style import Style from pygments.token import Keyword, Name, Comment, String, Error, \ Number, Operator, Generic from jinja2 import Environment, FileSystemLoader +from jinja2.utils import next def parse_rst(state, content_offset, doc): @@ -110,10 +112,10 @@ def dump_functions(mapping): def directive(dirname, arguments, options, content, lineno, content_offset, block_text, state, state_machine): reverse_mapping = {} - for name, func in mapping.iteritems(): + for name, func in mapping.items(): reverse_mapping.setdefault(func, []).append(name) filters = [] - for func, names in reverse_mapping.iteritems(): + for func, names in reverse_mapping.items(): aliases = sorted(names, key=lambda x: len(x)) name = aliases.pop() filters.append((name, aliases, func)) @@ -145,9 +147,9 @@ def jinja_nodes(dirname, arguments, options, content, lineno, doc.append(p + '.. autoclass:: %s(%s)' % (node.__name__, sig), '') if node.abstract: members = [] - for key, name in node.__dict__.iteritems(): + for key, name in node.__dict__.items(): if not key.startswith('_') and \ - not hasattr(node.__base__, key) and callable(name): + not hasattr(node.__base__, key) and isinstance(name, collections.Callable): members.append(key) if members: members.sort() @@ -169,10 +171,10 @@ def inject_toc(app, doctree, docname): titleiter = iter(doctree.traverse(nodes.title)) try: # skip first title, we are not interested in that one - titleiter.next() - title = titleiter.next() + next(titleiter) + title = next(titleiter) # and check if there is at least another title - titleiter.next() + next(titleiter) except StopIteration: return tocnode = nodes.section('')