summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-01-10 12:58:38 -0800
committerDavid Lord <davidism@gmail.com>2020-01-10 12:58:38 -0800
commite492255f270add52d051ef4f8e87899f40e57687 (patch)
tree5c32f9e526b2efae6d901bc4dd77655dbf8ab3b5
parent143667d95d73730415bb1281d1cd5e439b366fec (diff)
downloadjinja2-e492255f270add52d051ef4f8e87899f40e57687.tar.gz
remove old scripts and examples
-rw-r--r--docs/examples/cache_extension.py (renamed from docs/cache_extension.py)0
-rw-r--r--docs/examples/inline_gettext_extension.py (renamed from ext/inlinegettext.py)0
-rw-r--r--docs/extensions.rst40
-rw-r--r--examples/bench.py499
-rw-r--r--examples/profile.py54
-rw-r--r--examples/rwbench/django/_form.html1
-rw-r--r--examples/rwbench/django/_input_field.html1
-rw-r--r--examples/rwbench/django/_textarea.html1
-rw-r--r--examples/rwbench/django/index.html29
-rw-r--r--examples/rwbench/django/layout.html29
-rw-r--r--examples/rwbench/djangoext.py126
-rw-r--r--examples/rwbench/genshi/helpers.html12
-rw-r--r--examples/rwbench/genshi/index.html41
-rw-r--r--examples/rwbench/genshi/layout.html30
-rw-r--r--examples/rwbench/jinja/helpers.html12
-rw-r--r--examples/rwbench/jinja/index.html29
-rw-r--r--examples/rwbench/jinja/layout.html29
-rw-r--r--examples/rwbench/mako/helpers.html11
-rw-r--r--examples/rwbench/mako/index.html31
-rw-r--r--examples/rwbench/mako/layout.html30
-rw-r--r--examples/rwbench/rwbench.py122
-rw-r--r--ext/django2jinja/django2jinja.py812
-rw-r--r--ext/django2jinja/example.py7
-rw-r--r--ext/django2jinja/templates/index.html58
-rw-r--r--ext/django2jinja/templates/layout.html4
-rw-r--r--ext/django2jinja/templates/subtemplate.html1
-rw-r--r--ext/djangojinja2.py91
-rwxr-xr-xscripts/jinja2-debug.py50
-rw-r--r--scripts/make-release.py178
-rw-r--r--scripts/pylintrc301
-rw-r--r--src/jinja2/ext.py4
31 files changed, 34 insertions, 2599 deletions
diff --git a/docs/cache_extension.py b/docs/examples/cache_extension.py
index 387cd46..387cd46 100644
--- a/docs/cache_extension.py
+++ b/docs/examples/cache_extension.py
diff --git a/ext/inlinegettext.py b/docs/examples/inline_gettext_extension.py
index 50a0671..50a0671 100644
--- a/ext/inlinegettext.py
+++ b/docs/examples/inline_gettext_extension.py
diff --git a/docs/extensions.rst b/docs/extensions.rst
index 8cb0ff7..7abed65 100644
--- a/docs/extensions.rst
+++ b/docs/extensions.rst
@@ -254,13 +254,17 @@ errors that are horrible to debug. Always make sure you are using the nodes
you create correctly. The API documentation below shows which nodes exist and
how to use them.
-Example Extension
-~~~~~~~~~~~~~~~~~
+
+Example Extensions
+------------------
+
+Cache
+~~~~~
The following example implements a ``cache`` tag for Jinja by using the
`cachelib`_ library:
-.. literalinclude:: cache_extension.py
+.. literalinclude:: examples/cache_extension.py
:language: python
And here is how you use it in an environment::
@@ -284,8 +288,30 @@ following example caches a sidebar for 300 seconds:
.. _cachelib: https://github.com/pallets/cachelib
+
+Inline ``gettext``
+~~~~~~~~~~~~~~~~~~
+
+The following example demonstrates using :meth:`Extension.filter_stream`
+to parse calls to the ``_()`` gettext function inline with static data
+without needing Jinja blocks.
+
+.. code-block:: html
+
+ <h1>_(Welcome)</h1>
+ <p>_(This is a paragraph)</p>
+
+It requires the i18n extension to be loaded and configured.
+
+.. literalinclude:: examples/inline_gettext_extension.py
+ :language: python
+
+
Extension API
-~~~~~~~~~~~~~
+-------------
+
+Extension
+~~~~~~~~~
Extensions always have to extend the :class:`jinja2.ext.Extension` class:
@@ -302,8 +328,9 @@ Extensions always have to extend the :class:`jinja2.ext.Extension` class:
If the extension implements custom tags this is a set of tag names
the extension is listening for.
-Parser API
-~~~~~~~~~~
+
+Parser
+~~~~~~
The parser passed to :meth:`Extension.parse` provides ways to parse
expressions of different types. The following methods may be used by
@@ -356,6 +383,7 @@ characters in strings:
.. autofunction:: jinja2.lexer.count_newlines
+
AST
~~~
diff --git a/examples/bench.py b/examples/bench.py
deleted file mode 100644
index e610718..0000000
--- a/examples/bench.py
+++ /dev/null
@@ -1,499 +0,0 @@
-"""\
- This benchmark compares some python templating engines with Jinja so
- that we get a picture of how fast Jinja is for a semi real world
- template. If a template engine is not installed the test is skipped.\
-"""
-import cgi
-import sys
-from timeit import Timer
-
-from jinja2 import Environment as JinjaEnvironment
-from jinja2._compat import text_type
-
-context = {
- "page_title": "mitsuhiko's benchmark",
- "table": [
- dict(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, j=10) for x in range(1000)
- ],
-}
-
-jinja_template = JinjaEnvironment(
- line_statement_prefix="%", variable_start_string="${", variable_end_string="}"
-).from_string(
- """\
-<!doctype html>
-<html>
- <head>
- <title>${page_title|e}</title>
- </head>
- <body>
- <div class="header">
- <h1>${page_title|e}</h1>
- </div>
- <ul class="navigation">
- % for href, caption in [
- ('index.html', 'Index'),
- ('downloads.html', 'Downloads'),
- ('products.html', 'Products')
- ]
- <li><a href="${href|e}">${caption|e}</a></li>
- % endfor
- </ul>
- <div class="table">
- <table>
- % for row in table
- <tr>
- % for cell in row
- <td>${cell}</td>
- % endfor
- </tr>
- % endfor
- </table>
- </div>
- </body>
-</html>\
-"""
-)
-
-
-def test_jinja():
- jinja_template.render(context)
-
-
-try:
- from tornado.template import Template
-except ImportError:
- test_tornado = None
-else:
- tornado_template = Template(
- """\
-<!doctype html>
-<html>
- <head>
- <title>{{ page_title }}</title>
- </head>
- <body>
- <div class="header">
- <h1>{{ page_title }}</h1>
- </div>
- <ul class="navigation">
- {% for href, caption in [ \
- ('index.html', 'Index'), \
- ('downloads.html', 'Downloads'), \
- ('products.html', 'Products') \
- ] %}
- <li><a href="{{ href }}">{{ caption }}</a></li>
- {% end %}
- </ul>
- <div class="table">
- <table>
- {% for row in table %}
- <tr>
- {% for cell in row %}
- <td>{{ cell }}</td>
- {% end %}
- </tr>
- {% end %}
- </table>
- </div>
- </body>
-</html>\
-"""
- )
-
- def test_tornado():
- tornado_template.generate(**context)
-
-
-try:
- from django.conf import settings
-
- settings.configure()
- from django.template import Template as DjangoTemplate, Context as DjangoContext
-except ImportError:
- test_django = None
-else:
- django_template = DjangoTemplate(
- """\
-<!doctype html>
-<html>
- <head>
- <title>{{ page_title }}</title>
- </head>
- <body>
- <div class="header">
- <h1>{{ page_title }}</h1>
- </div>
- <ul class="navigation">
- {% for href, caption in navigation %}
- <li><a href="{{ href }}">{{ caption }}</a></li>
- {% endfor %}
- </ul>
- <div class="table">
- <table>
- {% for row in table %}
- <tr>
- {% for cell in row %}
- <td>{{ cell }}</td>
- {% endfor %}
- </tr>
- {% endfor %}
- </table>
- </div>
- </body>
-</html>\
-"""
- )
-
- def test_django():
- c = DjangoContext(context)
- c["navigation"] = [
- ("index.html", "Index"),
- ("downloads.html", "Downloads"),
- ("products.html", "Products"),
- ]
- django_template.render(c)
-
-
-try:
- from mako.template import Template as MakoTemplate
-except ImportError:
- test_mako = None
-else:
- mako_template = MakoTemplate(
- """\
-<!doctype html>
-<html>
- <head>
- <title>${page_title|h}</title>
- </head>
- <body>
- <div class="header">
- <h1>${page_title|h}</h1>
- </div>
- <ul class="navigation">
- % for href, caption in [('index.html', 'Index'), ('downloads.html', 'Downloads'), \
-('products.html', 'Products')]:
- <li><a href="${href|h}">${caption|h}</a></li>
- % endfor
- </ul>
- <div class="table">
- <table>
- % for row in table:
- <tr>
- % for cell in row:
- <td>${cell}</td>
- % endfor
- </tr>
- % endfor
- </table>
- </div>
- </body>
-</html>\
-"""
- )
-
- def test_mako():
- mako_template.render(**context)
-
-
-try:
- from genshi.template import MarkupTemplate as GenshiTemplate
-except ImportError:
- test_genshi = None
-else:
- genshi_template = GenshiTemplate(
- """\
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
- <head>
- <title>${page_title}</title>
- </head>
- <body>
- <div class="header">
- <h1>${page_title}</h1>
- </div>
- <ul class="navigation">
- <li py:for="href, caption in [
- ('index.html', 'Index'),
- ('downloads.html', 'Downloads'),
- ('products.html', 'Products')]"><a href="${href}">${caption}</a></li>
- </ul>
- <div class="table">
- <table>
- <tr py:for="row in table">
- <td py:for="cell in row">${cell}</td>
- </tr>
- </table>
- </div>
- </body>
-</html>\
-"""
- )
-
- def test_genshi():
- genshi_template.generate(**context).render("html", strip_whitespace=False)
-
-
-try:
- from Cheetah.Template import Template as CheetahTemplate
-except ImportError:
- test_cheetah = None
-else:
- cheetah_template = CheetahTemplate(
- """\
-#import cgi
-<!doctype html>
-<html>
- <head>
- <title>$cgi.escape($page_title)</title>
- </head>
- <body>
- <div class="header">
- <h1>$cgi.escape($page_title)</h1>
- </div>
- <ul class="navigation">
- #for $href, $caption in [('index.html', 'Index'), ('downloads.html', 'Downloads'), \
-('products.html', 'Products')]:
- <li><a href="$cgi.escape($href)">$cgi.escape($caption)</a></li>
- #end for
- </ul>
- <div class="table">
- <table>
- #for $row in $table:
- <tr>
- #for $cell in $row:
- <td>$cell</td>
- #end for
- </tr>
- #end for
- </table>
- </div>
- </body>
-</html>\
-""",
- searchList=[dict(context)],
- )
-
- def test_cheetah():
- text_type(cheetah_template)
-
-
-try:
- import tenjin
-except ImportError:
- test_tenjin = None
-else:
- tenjin_template = tenjin.Template()
- tenjin_template.convert(
- """\
-<!doctype html>
-<html>
- <head>
- <title>${page_title}</title>
- </head>
- <body>
- <div class="header">
- <h1>${page_title}</h1>
- </div>
- <ul class="navigation">
-<?py for href, caption in [('index.html', 'Index'), ('downloads.html', 'Downloads'), \
-('products.html', 'Products')]: ?>
- <li><a href="${href}">${caption}</a></li>
-<?py #end ?>
- </ul>
- <div class="table">
- <table>
-<?py for row in table: ?>
- <tr>
-<?py for cell in row: ?>
- <td>#{cell}</td>
-<?py #end ?>
- </tr>
-<?py #end ?>
- </table>
- </div>
- </body>
-</html>\
-"""
- )
-
- def test_tenjin():
- tenjin_template.render(context, locals())
-
-
-try:
- from spitfire.compiler import util as SpitfireTemplate
- from spitfire.compiler.analyzer import o2_options as spitfire_optimizer
-except ImportError:
- test_spitfire = None
-else:
- spitfire_template = SpitfireTemplate.load_template(
- """\
-<!doctype html>
-<html>
- <head>
- <title>$cgi.escape($page_title)</title>
- </head>
- <body>
- <div class="header">
- <h1>$cgi.escape($page_title)</h1>
- </div>
- <ul class="navigation">
- #for $href, $caption in [('index.html', 'Index'), ('downloads.html', 'Downloads'), \
-('products.html', 'Products')]
- <li><a href="$cgi.escape($href)">$cgi.escape($caption)</a></li>
- #end for
- </ul>
- <div class="table">
- <table>
- #for $row in $table
- <tr>
- #for $cell in $row
- <td>$cell</td>
- #end for
- </tr>
- #end for
- </table>
- </div>
- </body>
-</html>\
-""",
- "spitfire_tmpl",
- spitfire_optimizer,
- {"enable_filters": False},
- )
- spitfire_context = dict(context, **{"cgi": cgi})
-
- def test_spitfire():
- spitfire_template(search_list=[spitfire_context]).main()
-
-
-try:
- from chameleon.zpt.template import PageTemplate
-except ImportError:
- test_chameleon = None
-else:
- chameleon_template = PageTemplate(
- """\
-<html xmlns:tal="http://xml.zope.org/namespaces/tal">
- <head>
- <title tal:content="page_title">Page Title</title>
- </head>
- <body>
- <div class="header">
- <h1 tal:content="page_title">Page Title</h1>
- </div>
- <ul class="navigation">
- <li tal:repeat="item sections"><a tal:attributes="href item[0]" \
-tal:content="item[1]">caption</a></li>
- </ul>
- <div class="table">
- <table>
- <tr tal:repeat="row table">
- <td tal:repeat="cell row" tal:content="row[cell]">cell</td>
- </tr>
- </table>
- </div>
- </body>
-</html>\
-"""
- )
- chameleon_context = dict(context)
- chameleon_context["sections"] = [
- ("index.html", "Index"),
- ("downloads.html", "Downloads"),
- ("products.html", "Products"),
- ]
-
- def test_chameleon():
- chameleon_template.render(**chameleon_context)
-
-
-try:
- from chameleon.zpt.template import PageTemplate
- from chameleon.genshi import language
-except ImportError:
- test_chameleon_genshi = None
-else:
- chameleon_genshi_template = PageTemplate(
- """\
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
- <head>
- <title>${page_title}</title>
- </head>
- <body>
- <div class="header">
- <h1>${page_title}</h1>
- </div>
- <ul class="navigation">
- <li py:for="info in sections"><a href="${info[0]}">${info[1]}</a></li>
- </ul>
- <div class="table">
- <table>
- <tr py:for="row in table">
- <td py:for="cell in row">${row[cell]}</td>
- </tr>
- </table>
- </div>
- </body>
-</html>\
-""",
- parser=language.Parser(),
- )
- chameleon_genshi_context = dict(context)
- chameleon_genshi_context["sections"] = [
- ("index.html", "Index"),
- ("downloads.html", "Downloads"),
- ("products.html", "Products"),
- ]
-
- def test_chameleon_genshi():
- chameleon_genshi_template.render(**chameleon_genshi_context)
-
-
-sys.stdout.write(
- "\r"
- + "\n".join(
- (
- "=" * 80,
- "Template Engine BigTable Benchmark".center(80),
- "=" * 80,
- __doc__,
- "-" * 80,
- )
- )
- + "\n"
-)
-
-
-for test in (
- "jinja",
- "mako",
- "tornado",
- "tenjin",
- "spitfire",
- "django",
- "genshi",
- "cheetah",
- "chameleon",
- "chameleon_genshi",
-):
- if locals()["test_" + test] is None:
- sys.stdout.write(" %-20s*not installed*\n" % test)
- continue
- t = Timer(setup="from __main__ import test_%s as bench" % test, stmt="bench()")
- sys.stdout.write(" >> %-20s<running>" % test)
- sys.stdout.flush()
- sys.stdout.write("\r %-20s%.4f seconds\n" % (test, t.timeit(number=50) / 50))
-sys.stdout.write("-" * 80 + "\n")
-sys.stdout.write(
- """\
- WARNING: The results of this benchmark are useless to compare the
- performance of template engines and should not be taken seriously in any
- way. It's testing the performance of simple loops and has no real-world
- usefulnes. It only used to check if changes on the Jinja code affect
- performance in a good or bad way and how it roughly compares to others.
-"""
- + "=" * 80
- + "\n"
-)
diff --git a/examples/profile.py b/examples/profile.py
deleted file mode 100644
index b16d99f..0000000
--- a/examples/profile.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from __future__ import print_function
-
-try:
- from cProfile import Profile
-except ImportError:
- from profile import Profile
-from pstats import Stats
-from jinja2 import Environment as JinjaEnvironment
-
-context = {
- "page_title": "mitsuhiko's benchmark",
- "table": [
- dict(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, j=10) for x in range(1000)
- ],
-}
-
-source = """\
-% macro testmacro(x)
- <span>${x}</span>
-% endmacro
-<!doctype html>
-<html>
- <head>
- <title>${page_title|e}</title>
- </head>
- <body>
- <div class="header">
- <h1>${page_title|e}</h1>
- </div>
- <div class="table">
- <table>
- % for row in table
- <tr>
- % for cell in row
- <td>${testmacro(cell)}</td>
- % endfor
- </tr>
- % endfor
- </table>
- </div>
- </body>
-</html>\
-"""
-jinja_template = JinjaEnvironment(
- line_statement_prefix="%", variable_start_string="${", variable_end_string="}"
-).from_string(source)
-print(jinja_template.environment.compile(source, raw=True))
-
-
-p = Profile()
-p.runcall(lambda: jinja_template.render(context))
-stats = Stats(p)
-stats.sort_stats("time", "calls")
-stats.print_stats()
diff --git a/examples/rwbench/django/_form.html b/examples/rwbench/django/_form.html
deleted file mode 100644
index 9c4f710..0000000
--- a/examples/rwbench/django/_form.html
+++ /dev/null
@@ -1 +0,0 @@
-<form action="{{ action }}" method="{{ method }}">{{ body }}</form>
diff --git a/examples/rwbench/django/_input_field.html b/examples/rwbench/django/_input_field.html
deleted file mode 100644
index 290fdbd..0000000
--- a/examples/rwbench/django/_input_field.html
+++ /dev/null
@@ -1 +0,0 @@
-<input type="{{ type }}" value="{{ value }}" name="{{ name }}">
diff --git a/examples/rwbench/django/_textarea.html b/examples/rwbench/django/_textarea.html
deleted file mode 100644
index 7f10424..0000000
--- a/examples/rwbench/django/_textarea.html
+++ /dev/null
@@ -1 +0,0 @@
-<textarea name="{{ name }}" rows="{{ rows }}" cols="{{ cols }}">{{ value }}</textarea>
diff --git a/examples/rwbench/django/index.html b/examples/rwbench/django/index.html
deleted file mode 100644
index 6f620bb..0000000
--- a/examples/rwbench/django/index.html
+++ /dev/null
@@ -1,29 +0,0 @@
-{% extends "layout.html" %}
-{% block page_title %}Index Page{% endblock %}
-{% block body %}
- {% for article in articles %}
- {% if article.published %}
- <div class="article">
- <h2><a href="{{ article.href }}">{{ article.title }}</a></h2>
- <p class="meta">written by <a href="{{ article.user.href }}">{{ article.user.username }}</a> on {{ article.pub_date|dateformat }}</p>
- <div class="text">{{ article.body|safe }}</div>
- </div>
- {% endif %}
- {% endfor %}
- {% form %}
- <dl>
- <dt>Name</dt>
- <dd>{% input_field 'name' %}</dd>
- <dt>E-Mail</dt>
- <dd>{% input_field 'email' %}</dd>
- <dt>URL</dt>
- <dd>{% input_field 'url' %}</dd>
- <dt>Comment</dt>
- <dd>{% textarea 'comment' %}</dd>
- <dt>Captcha</dt>
- <dd>{% input_field 'captcha' %}</dd>
- </dl>
- {% input_field '' 'submit' 'Submit' %}
- {% input_field 'cancel' 'submit' 'Cancel' %}
- {% endform %}
-{% endblock %}
diff --git a/examples/rwbench/django/layout.html b/examples/rwbench/django/layout.html
deleted file mode 100644
index b75cbfb..0000000
--- a/examples/rwbench/django/layout.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
- <title>{% block page_title %}{% endblock %} | RealWorld Benchmark</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-</head>
-<body>
- <div class="contents">
- <div class="header">
- <h1>RealWorld Benchmark</h1>
- <blockquote><p>
- A less stupid benchmark for Mako and Jinja to get an impression how
- code changes affect runtime performance.
- </p></blockquote>
- </div>
- <ul class="navigation">
- {% for href, caption in page_navigation %}
- <li><a href="{{ href }}">{{ caption }}</a></li>
- {% endfor %}
- </ul>
- <div class="body">
- {% block body %}{% endblock %}
- </div>
- <div class="footer">
- &copy; Copyright 2008 by I don't know who.
- </div>
- </div>
-</body>
-</html>
diff --git a/examples/rwbench/djangoext.py b/examples/rwbench/djangoext.py
deleted file mode 100644
index 0052aef..0000000
--- a/examples/rwbench/djangoext.py
+++ /dev/null
@@ -1,126 +0,0 @@
-# -*- coding: utf-8 -*-
-from os.path import join
-
-from django import template as django_template_module
-from django.conf import settings
-from django.template import Context as DjangoContext
-from django.template import loader as django_loader
-from django.template import Node
-from django.template import TokenParser
-from django.template import Variable
-from rwbench import dateformat
-from rwbench import ROOT
-
-settings.configure(
- TEMPLATE_DIRS=(join(ROOT, "django"),),
- TEMPLATE_LOADERS=(
- (
- "django.template.loaders.cached.Loader",
- ("django.template.loaders.filesystem.Loader",),
- ),
- ),
-)
-
-# for django extensions. We monkey patch our extensions in so that
-# we don't have to initialize a more complex django setup.
-django_extensions = django_template_module.Library()
-django_template_module.builtins.append(django_extensions)
-
-django_extensions.filter(dateformat)
-
-
-def var_or_none(x):
- if x is not None:
- return Variable(x)
-
-
-# and more django extensions
-@django_extensions.tag
-def input_field(parser, token):
- p = TokenParser(token.contents)
- args = [p.value()]
- while p.more():
- args.append(p.value())
- return InputFieldNode(*args)
-
-
-@django_extensions.tag
-def textarea(parser, token):
- p = TokenParser(token.contents)
- args = [p.value()]
- while p.more():
- args.append(p.value())
- return TextareaNode(*args)
-
-
-@django_extensions.tag
-def form(parser, token):
- p = TokenParser(token.contents)
- args = []
- while p.more():
- args.append(p.value())
- body = parser.parse(("endform",))
- parser.delete_first_token()
- return FormNode(body, *args)
-
-
-class InputFieldNode(Node):
- def __init__(self, name, type=None, value=None):
- self.name = var_or_none(name)
- self.type = var_or_none(type)
- self.value = var_or_none(value)
-
- def render(self, context):
- name = self.name.resolve(context)
- type = "text"
- value = ""
- if self.type is not None:
- type = self.type.resolve(context)
- if self.value is not None:
- value = self.value.resolve(context)
- tmpl = django_loader.get_template("_input_field.html")
- return tmpl.render(DjangoContext({"name": name, "type": type, "value": value}))
-
-
-class TextareaNode(Node):
- def __init__(self, name, rows=None, cols=None, value=None):
- self.name = var_or_none(name)
- self.rows = var_or_none(rows)
- self.cols = var_or_none(cols)
- self.value = var_or_none(value)
-
- def render(self, context):
- name = self.name.resolve(context)
- rows = 10
- cols = 40
- value = ""
- if self.rows is not None:
- rows = int(self.rows.resolve(context))
- if self.cols is not None:
- cols = int(self.cols.resolve(context))
- if self.value is not None:
- value = self.value.resolve(context)
- tmpl = django_loader.get_template("_textarea.html")
- return tmpl.render(
- DjangoContext({"name": name, "rows": rows, "cols": cols, "value": value})
- )
-
-
-class FormNode(Node):
- def __init__(self, body, action=None, method=None):
- self.body = body
- self.action = action
- self.method = method
-
- def render(self, context):
- body = self.body.render(context)
- action = ""
- method = "post"
- if self.action is not None:
- action = self.action.resolve(context)
- if self.method is not None:
- method = self.method.resolve(context)
- tmpl = django_loader.get_template("_form.html")
- return tmpl.render(
- DjangoContext({"body": body, "action": action, "method": method})
- )
diff --git a/examples/rwbench/genshi/helpers.html b/examples/rwbench/genshi/helpers.html
deleted file mode 100644
index ecc6dc4..0000000
--- a/examples/rwbench/genshi/helpers.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<div xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/"
- py:strip="">
-
- <py:def function="input_field(name='', value='', type='text')">
- <input type="$type" value="$value" name="$name" />
- </py:def>
-
- <py:def function="textarea(name, value='', rows=10, cols=40)">
- <textarea name="$name" rows="$rows" cols="cols">$value</textarea>
- </py:def>
-
-</div>
diff --git a/examples/rwbench/genshi/index.html b/examples/rwbench/genshi/index.html
deleted file mode 100644
index 70f697d..0000000
--- a/examples/rwbench/genshi/index.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<?python
- from rwbench import dateformat
-?>
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:py="http://genshi.edgewall.org/">
- <xi:include href="layout.html" />
- <xi:include href="helpers.html" />
- <head><title>Index Page</title></head>
- <body>
- <div class="article" py:for="article in articles">
- <py:if test="article.published">
- <h2><a href="${article.href}">${article.title}</a></h2>
- <p class="meta">written by <a href="${article.user.href}"
- >${article.user.username}</a> on ${dateformat(article.pub_date)}</p>
- <div class="text">${Markup(article.body)}</div>
- </py:if>
- </div>
- <!--
- For a fair and balanced comparison we would have to use a def here
- that wraps the form data but I don't know what would be the best
- Genshi equivalent for that. Quite frankly I doubt that this makes
- sense in Genshi anyways.
- -->
- <form action="" method="post">
- <dl>
- <dt>Name</dt>
- <dd>${input_field('name')}</dd>
- <dt>E-Mail</dt>
- <dd>${input_field('email')}</dd>
- <dt>URL</dt>
- <dd>${input_field('url')}</dd>
- <dt>Comment</dt>
- <dd>${textarea('comment')}</dd>
- <dt>Captcha</dt>
- <dd>${input_field('captcha')}</dd>
- </dl>
- ${input_field(type='submit', value='Submit')}
- ${input_field(name='cancel', type='submit', value='Cancel')}
- </form>
- </body>
-</html>
diff --git a/examples/rwbench/genshi/layout.html b/examples/rwbench/genshi/layout.html
deleted file mode 100644
index d56fffd..0000000
--- a/examples/rwbench/genshi/layout.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" >
- <py:match path="head" once="true">
- <head>
- <title>${select('title/text()')} | RealWorld Benchmark</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- </head>
- </py:match>
- <py:match path="body" once="true">
- <body>
- <div class="contents">
- <div class="header">
- <h1>RealWorld Benchmark</h1>
- <blockquote><p>
- A less stupid benchmark for Mako and Jinja to get an impression how
- code changes affect runtime performance.
- </p></blockquote>
- </div>
- <ul class="navigation">
- <li py:for="href, caption in page_navigation"><a href="$href">$caption</a></li>
- </ul>
- <div class="body">
- ${select('*|text()')}
- </div>
- <div class="footer">
- &copy; Copyright 2008 by I don't know who.
- </div>
- </div>
- </body>
- </py:match>
-</html>
diff --git a/examples/rwbench/jinja/helpers.html b/examples/rwbench/jinja/helpers.html
deleted file mode 100644
index 89976aa..0000000
--- a/examples/rwbench/jinja/helpers.html
+++ /dev/null
@@ -1,12 +0,0 @@
-{% macro input_field(name, value='', type='text') -%}
- <input type="{{ type }}" value="{{ value|e }}" name="{{ name }}">
-{%- endmacro %}
-
-{% macro textarea(name, value='', rows=10, cols=40) -%}
- <textarea name="{{ name }}" rows="{{ rows }}" cols="{{ cols }}">{{
- value|e }}</textarea>
-{%- endmacro %}
-
-{% macro form(action='', method='post') -%}
- <form action="{{ action|e }}" method="{{ method }}">{{ caller() }}</form>
-{%- endmacro %}
diff --git a/examples/rwbench/jinja/index.html b/examples/rwbench/jinja/index.html
deleted file mode 100644
index b006d05..0000000
--- a/examples/rwbench/jinja/index.html
+++ /dev/null
@@ -1,29 +0,0 @@
-{% extends "layout.html" %}
-{% from "helpers.html" import input_field, textarea, form %}
-{% block page_title %}Index Page{% endblock %}
-{% block body %}
- {%- for article in articles if article.published %}
- <div class="article">
- <h2><a href="{{ article.href|e }}">{{ article.title|e }}</a></h2>
- <p class="meta">written by <a href="{{ article.user.href|e
- }}">{{ article.user.username|e }}</a> on {{ article.pub_date|dateformat }}</p>
- <div class="text">{{ article.body }}</div>
- </div>
- {%- endfor %}
- {%- call form() %}
- <dl>
- <dt>Name</dt>
- <dd>{{ input_field('name') }}</dd>
- <dt>E-Mail</dt>
- <dd>{{ input_field('email') }}</dd>
- <dt>URL</dt>
- <dd>{{ input_field('url') }}</dd>
- <dt>Comment</dt>
- <dd>{{ textarea('comment') }}</dd>
- <dt>Captcha</dt>
- <dd>{{ input_field('captcha') }}</dd>
- </dl>
- {{ input_field(type='submit', value='Submit') }}
- {{ input_field('cancel', type='submit', value='Cancel') }}
- {%- endcall %}
-{% endblock %}
diff --git a/examples/rwbench/jinja/layout.html b/examples/rwbench/jinja/layout.html
deleted file mode 100644
index 308ba9d..0000000
--- a/examples/rwbench/jinja/layout.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
- <title>{% block page_title %}{% endblock %} | RealWorld Benchmark</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-</head>
-<body>
- <div class="contents">
- <div class="header">
- <h1>RealWorld Benchmark</h1>
- <blockquote><p>
- A less stupid benchmark for Mako and Jinja to get an impression how
- code changes affect runtime performance.
- </p></blockquote>
- </div>
- <ul class="navigation">
- {%- for href, caption in page_navigation %}
- <li><a href="{{ href|e }}">{{ caption }}</a></li>
- {%- endfor %}
- </ul>
- <div class="body">
- {% block body %}{% endblock %}
- </div>
- <div class="footer">
- &copy; Copyright 2008 by I don't know who.
- </div>
- </div>
-</body>
-</html>
diff --git a/examples/rwbench/mako/helpers.html b/examples/rwbench/mako/helpers.html
deleted file mode 100644
index a0290eb..0000000
--- a/examples/rwbench/mako/helpers.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<%def name="input_field(name='', value='', type='text')">
- <input type="${type}" value="${value|h}" name="${name}">
-</%def>
-
-<%def name="textarea(name, value='', rows=10, cols=40)">
- <textarea name="${name}" rows="${rows}" cols="${cols}">${value|h}</textarea>
-</%def>
-
-<%def name="form(action='', method='post')">
- <form action="${action|h}" method="${method}">${caller.body()}</form>
-</%def>
diff --git a/examples/rwbench/mako/index.html b/examples/rwbench/mako/index.html
deleted file mode 100644
index c4c6303..0000000
--- a/examples/rwbench/mako/index.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<%!
- from rwbench import dateformat
-%>
-<%inherit file="layout.html" />
-<%namespace file="helpers.html" import="input_field, textarea, form" />
-<%def name="page_title()">Index Page</%def>
-% for article in articles:
- <% if not article.published: continue %>
-<div class="article">
- <h2><a href="${article.href|h}">${article.title|h}</a></h2>
- <p class="meta">written by <a href="${article.user.href|h
- }">${article.user.username|h}</a> on ${dateformat(article.pub_date)}</p>
- <div class="text">${article.body}</div>
-</div>
-% endfor
-<%call expr="form()">
- <dl>
- <dt>Name</dt>
- <dd>${input_field('name')}</dd>
- <dt>E-Mail</dt>
- <dd>${input_field('email')}</dd>
- <dt>URL</dt>
- <dd>${input_field('url')}</dd>
- <dt>Comment</dt>
- <dd>${textarea('comment')}</dd>
- <dt>Captcha</dt>
- <dd>${input_field('captcha')}</dd>
- </dl>
- ${input_field(type='submit', value='Submit')}
- ${input_field(name='cancel', type='submit', value='Cancel')}
-</%call>
diff --git a/examples/rwbench/mako/layout.html b/examples/rwbench/mako/layout.html
deleted file mode 100644
index 15e9282..0000000
--- a/examples/rwbench/mako/layout.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
- <title>${self.page_title()} | RealWorld Benchmark</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-</head>
-<body>
- <div class="contents">
- <div class="header">
- <h1>RealWorld Benchmark</h1>
- <blockquote><p>
- A less stupid benchmark for Mako and Jinja to get an impression how
- code changes affect runtime performance.
- </p></blockquote>
- </div>
- <ul class="navigation">
- % for href, caption in page_navigation:
- <li><a href="${href|h}">${caption}</a></li>
- % endfor
- </ul>
- <div class="body">
- ${self.body()}
- </div>
- <div class="footer">
- &copy; Copyright 2008 by I don't know who.
- </div>
- </div>
-</body>
-</html>
-<%def name="page_title()"></%def>
diff --git a/examples/rwbench/rwbench.py b/examples/rwbench/rwbench.py
deleted file mode 100644
index 957216a..0000000
--- a/examples/rwbench/rwbench.py
+++ /dev/null
@@ -1,122 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- RealWorldish Benchmark
- ~~~~~~~~~~~~~~~~~~~~~~
-
- A more real-world benchmark of Jinja. Like the other benchmark in the
- Jinja repository this has no real-world usefulnes (despite the name).
- Just go away and ignore it. NOW!
-
- :copyright: (c) 2009 by the Jinja Team.
- :license: BSD.
-"""
-from __future__ import print_function
-
-import sys
-from datetime import datetime
-from os.path import abspath
-from os.path import dirname
-from os.path import join
-from pstats import Stats
-from random import choice
-from random import randrange
-from timeit import Timer
-
-from djangoext import django_loader
-from djangoext import DjangoContext
-from genshi.template import TemplateLoader as GenshiTemplateLoader
-from mako.lookup import TemplateLookup
-
-from jinja2 import Environment
-from jinja2 import FileSystemLoader
-from jinja2.utils import generate_lorem_ipsum
-
-try:
- from cProfile import Profile
-except ImportError:
- from profile import Profile
-
-ROOT = abspath(dirname(__file__))
-
-
-def dateformat(x):
- return x.strftime("%Y-%m-%d")
-
-
-jinja_env = Environment(loader=FileSystemLoader(join(ROOT, "jinja")))
-jinja_env.filters["dateformat"] = dateformat
-mako_lookup = TemplateLookup(directories=[join(ROOT, "mako")])
-genshi_loader = GenshiTemplateLoader([join(ROOT, "genshi")])
-
-
-class Article(object):
- def __init__(self, id):
- self.id = id
- self.href = "/article/%d" % self.id
- self.title = generate_lorem_ipsum(1, False, 5, 10)
- self.user = choice(users)
- self.body = generate_lorem_ipsum()
- self.pub_date = datetime.utcfromtimestamp(randrange(10 ** 9, 2 * 10 ** 9))
- self.published = True
-
-
-class User(object):
- def __init__(self, username):
- self.href = "/user/%s" % username
- self.username = username
-
-
-users = map(User, [u"John Doe", u"Jane Doe", u"Peter Somewhat"])
-articles = map(Article, range(20))
-navigation = [
- ("index", "Index"),
- ("about", "About"),
- ("foo?bar=1", "Foo with Bar"),
- ("foo?bar=2&s=x", "Foo with X"),
- ("blah", "Blub Blah"),
- ("hehe", "Haha"),
-] * 5
-
-context = dict(users=users, articles=articles, page_navigation=navigation)
-
-jinja_template = jinja_env.get_template("index.html")
-mako_template = mako_lookup.get_template("index.html")
-genshi_template = genshi_loader.load("index.html")
-
-
-def test_jinja():
- jinja_template.render(context)
-
-
-def test_mako():
- mako_template.render_unicode(**context)
-
-
-def test_django():
- # not cached because django is not thread safe and does
- # not cache by itself so it would be unfair to cache it here.
- django_template = django_loader.get_template("index.html")
- django_template.render(DjangoContext(context))
-
-
-def test_genshi():
- genshi_template.generate(**context).render("html", doctype="html")
-
-
-if __name__ == "__main__":
- sys.stdout.write("Realworldish Benchmark:\n")
- for test in "jinja", "mako", "django", "genshi":
- t = Timer(setup="from __main__ import test_%s as bench" % test, stmt="bench()")
- sys.stdout.write(" >> %-20s<running>" % test)
- sys.stdout.flush()
- sys.stdout.write(
- "\r %-20s%.4f seconds\n" % (test, t.timeit(number=200) / 200)
- )
-
- if "-p" in sys.argv:
- print("Jinja profile")
- p = Profile()
- p.runcall(test_jinja)
- stats = Stats(p)
- stats.sort_stats("time", "calls")
- stats.print_stats()
diff --git a/ext/django2jinja/django2jinja.py b/ext/django2jinja/django2jinja.py
deleted file mode 100644
index 11e1a2b..0000000
--- a/ext/django2jinja/django2jinja.py
+++ /dev/null
@@ -1,812 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Django to Jinja
-~~~~~~~~~~~~~~~
-
-Helper module that can convert django templates into Jinja templates.
-
-This file is not intended to be used as stand alone application but to
-be used as library. To convert templates you basically create your own
-writer, add extra conversion logic for your custom template tags,
-configure your django environment and run the `convert_templates`
-function.
-
-Here a simple example::
-
- # configure django (or use settings.configure)
- import os
-
- os.environ["DJANGO_SETTINGS_MODULE"] = "yourapplication.settings"
- from yourapplication.foo.templatetags.bar import MyNode
-
- from django2jinja import Writer, convert_templates
-
- def write_my_node(writer, node):
- writer.start_variable()
- writer.write("myfunc(")
- for idx, arg in enumerate(node.args):
- if idx:
- writer.write(", ")
- writer.node(arg)
- writer.write(")")
- writer.end_variable()
-
- writer = Writer()
- writer.node_handlers[MyNode] = write_my_node
- convert_templates("/path/to/output/folder", writer=writer)
-
-Here is an example hos to automatically translate your django
-variables to jinja2::
-
- import re
- # List of tuple (Match pattern, Replace pattern, Exclusion pattern)
- var_re = (
- (re.compile("(u|user)\\.is_authenticated"), "\\1.is_authenticated()", None),
- (re.compile("\\.non_field_errors"), ".non_field_errors()", None),
- (re.compile("\\.label_tag"), ".label_tag()", None),
- (re.compile("\\.as_dl"), ".as_dl()", None),
- (re.compile("\\.as_table"), ".as_table()", None),
- (re.compile("\\.as_widget"), ".as_widget()", None),
- (re.compile("\\.as_hidden"), ".as_hidden()", None),
- (re.compile("\\.get_([0-9_\\w]+)_url"), ".get_\\1_url()", None),
- (re.compile("\\.url"), ".url()", re.compile("(form|calendar).url")),
- (re.compile("\\.get_([0-9_\\w]+)_display"), ".get_\\1_display()", None),
- (re.compile("loop\\.counte"), "loop.index", None),
- (re.compile("loop\\.revcounte"), "loop.revindex", None),
- (
- re.compile("request\\.GET\\.([0-9_\\w]+)"),
- "request.GET.get('\\1', '')",
- None,
- ),
- (re.compile("request\\.get_host"), "request.get_host()", None),
- (re.compile("\\.all(?!_)"), ".all()", None),
- (re.compile("\\.all\\.0"), ".all()[0]", None),
- (re.compile("\\.([0-9])($|\\s+)"), "[\\1]\\2", None),
- (re.compile("\\.items"), ".items()", None),
- )
- writer = Writer(var_re=var_re)
-
-For details about the writing process have a look at the module code.
-
-:copyright: (c) 2009 by the Jinja Team.
-:license: BSD.
-"""
-from __future__ import print_function
-
-import os
-import re
-import sys
-
-from django.conf import settings
-from django.template import defaulttags as core_tags
-from django.template import FilterExpression
-from django.template import libraries
-from django.template import loader
-from django.template import loader_tags
-from django.template import TextNode
-from django.template import TOKEN_TEXT
-from django.template import TOKEN_VAR
-from django.template import Variable
-from django.template.debug import DebugVariableNode as VariableNode
-from django.templatetags import i18n as i18n_tags
-
-from jinja2 import defaults
-
-_node_handlers = {}
-_resolved_filters = {}
-_newline_re = re.compile(r"(?:\r\n|\r|\n)")
-
-# Django stores an itertools object on the cycle node. Not only is this
-# thread unsafe but also a problem for the converter which needs the raw
-# string values passed to the constructor to create a jinja loop.cycle()
-# call from it.
-_old_cycle_init = core_tags.CycleNode.__init__
-
-
-def _fixed_cycle_init(self, cyclevars, variable_name=None):
- self.raw_cycle_vars = map(Variable, cyclevars)
- _old_cycle_init(self, cyclevars, variable_name)
-
-
-core_tags.CycleNode.__init__ = _fixed_cycle_init
-
-
-def node(cls):
- def proxy(f):
- _node_handlers[cls] = f
- return f
-
- return proxy
-
-
-def convert_templates(
- output_dir, extensions=(".html", ".txt"), writer=None, callback=None
-):
- """Iterates over all templates in the template dirs configured and
- translates them and writes the new templates into the output
- directory.
- """
- if writer is None:
- writer = Writer()
-
- def filter_templates(files):
- for filename in files:
- ifilename = filename.lower()
- for extension in extensions:
- if ifilename.endswith(extension):
- yield filename
-
- def translate(f, loadname):
- template = loader.get_template(loadname)
- original = writer.stream
- writer.stream = f
- writer.body(template.nodelist)
- writer.stream = original
-
- if callback is None:
-
- def callback(template):
- print(template)
-
- for directory in settings.TEMPLATE_DIRS:
- for dirname, _, files in os.walk(directory):
- dirname = dirname[len(directory) + 1 :]
- for filename in filter_templates(files):
- source = os.path.normpath(os.path.join(dirname, filename))
- target = os.path.join(output_dir, dirname, filename)
- basetarget = os.path.dirname(target)
- if not os.path.exists(basetarget):
- os.makedirs(basetarget)
- callback(source)
- with open(target, "w") as f:
- translate(f, source)
-
-
-class Writer(object):
- """The core writer class."""
-
- def __init__(
- self,
- stream=None,
- error_stream=None,
- block_start_string=defaults.BLOCK_START_STRING,
- block_end_string=defaults.BLOCK_END_STRING,
- variable_start_string=defaults.VARIABLE_START_STRING,
- variable_end_string=defaults.VARIABLE_END_STRING,
- comment_start_string=defaults.COMMENT_START_STRING,
- comment_end_string=defaults.COMMENT_END_STRING,
- initial_autoescape=True,
- use_jinja_autoescape=False,
- custom_node_handlers=None,
- var_re=None,
- env=None,
- ):
- if stream is None:
- stream = sys.stdout
- if error_stream is None:
- error_stream = sys.stderr
- self.stream = stream
- self.error_stream = error_stream
- self.block_start_string = block_start_string
- self.block_end_string = block_end_string
- self.variable_start_string = variable_start_string
- self.variable_end_string = variable_end_string
- self.comment_start_string = comment_start_string
- self.comment_end_string = comment_end_string
- self.autoescape = initial_autoescape
- self.spaceless = False
- self.use_jinja_autoescape = use_jinja_autoescape
- self.node_handlers = dict(_node_handlers, **(custom_node_handlers or {}))
- self._loop_depth = 0
- self._filters_warned = set()
- self.var_re = [] if var_re is None else var_re
- self.env = env
-
- def enter_loop(self):
- """Increments the loop depth so that write functions know if
- they are in a loop.
- """
- self._loop_depth += 1
-
- def leave_loop(self):
- """Reverse of enter_loop."""
- self._loop_depth -= 1
-
- @property
- def in_loop(self):
- """True if we are in a loop."""
- return self._loop_depth > 0
-
- def write(self, s):
- """Writes stuff to the stream."""
- self.stream.write(s.encode(settings.FILE_CHARSET))
-
- def print_expr(self, expr):
- """Open a variable tag, write to the string to the stream and
- close.
- """
- self.start_variable()
- self.write(expr)
- self.end_variable()
-
- def _post_open(self):
- if self.spaceless:
- self.write("- ")
- else:
- self.write(" ")
-
- def _pre_close(self):
- if self.spaceless:
- self.write(" -")
- else:
- self.write(" ")
-
- def start_variable(self):
- """Start a variable."""
- self.write(self.variable_start_string)
- self._post_open()
-
- def end_variable(self, always_safe=False):
- """End a variable."""
- if not always_safe and self.autoescape and not self.use_jinja_autoescape:
- self.write("|e")
- self._pre_close()
- self.write(self.variable_end_string)
-
- def start_block(self):
- """Starts a block."""
- self.write(self.block_start_string)
- self._post_open()
-
- def end_block(self):
- """Ends a block."""
- self._pre_close()
- self.write(self.block_end_string)
-
- def tag(self, name):
- """Like `print_expr` just for blocks."""
- self.start_block()
- self.write(name)
- self.end_block()
-
- def variable(self, name):
- """Prints a variable. This performs variable name
- transformation.
- """
- self.write(self.translate_variable_name(name))
-
- def literal(self, value):
- """Writes a value as literal."""
- value = repr(value)
- if value[:2] in ('u"', "u'"):
- value = value[1:]
- self.write(value)
-
- def filters(self, filters, is_block=False):
- """Dumps a list of filters."""
- want_pipe = not is_block
- for filter, args in filters:
- name = self.get_filter_name(filter)
- if name is None:
- self.warn("Could not find filter %s" % name)
- continue
- if (
- name not in defaults.DEFAULT_FILTERS
- and name not in self._filters_warned
- ):
- self._filters_warned.add(name)
- self.warn("Filter %s probably doesn't exist in Jinja" % name)
- if not want_pipe:
- want_pipe = True
- else:
- self.write("|")
- self.write(name)
- if args:
- self.write("(")
- for idx, (is_var, value) in enumerate(args):
- if idx:
- self.write(", ")
- if is_var:
- self.node(value)
- else:
- self.literal(value)
- self.write(")")
-
- def get_location(self, origin, position):
- """Returns the location for an origin and position tuple as name
- and lineno.
- """
- if hasattr(origin, "source"):
- source = origin.source
- name = "<unknown source>"
- else:
- source = origin.loader(origin.loadname, origin.dirs)[0]
- name = origin.loadname
- lineno = len(_newline_re.findall(source[: position[0]])) + 1
- return name, lineno
-
- def warn(self, message, node=None):
- """Prints a warning to the error stream."""
- if node is not None and hasattr(node, "source"):
- filename, lineno = self.get_location(*node.source)
- message = "[%s:%d] %s" % (filename, lineno, message)
- print(message, file=self.error_stream)
-
- def translate_variable_name(self, var):
- """Performs variable name translation."""
- if self.in_loop and var == "forloop" or var.startswith("forloop."):
- var = var[3:]
-
- for reg, rep, unless in self.var_re:
- no_unless = unless and unless.search(var) or True
- if reg.search(var) and no_unless:
- var = reg.sub(rep, var)
- break
- return var
-
- def get_filter_name(self, filter):
- """Returns the filter name for a filter function or `None` if there
- is no such filter.
- """
- if filter not in _resolved_filters:
- for library in libraries.values():
- for key, value in library.filters.items():
- _resolved_filters[value] = key
- return _resolved_filters.get(filter, None)
-
- def node(self, node):
- """Invokes the node handler for a node."""
- for cls, handler in self.node_handlers.items():
- if type(node) is cls or type(node).__name__ == cls:
- handler(self, node)
- break
- else:
- self.warn(
- "Untranslatable node %s.%s found"
- % (node.__module__, node.__class__.__name__),
- node,
- )
-
- def body(self, nodes):
- """Calls node() for every node in the iterable passed."""
- for node in nodes:
- self.node(node)
-
-
-@node(TextNode)
-def text_node(writer, node):
- writer.write(node.s)
-
-
-@node(Variable)
-def variable(writer, node):
- if node.translate:
- writer.warn("i18n system used, make sure to install translations", node)
- writer.write("_(")
- if node.literal is not None:
- writer.literal(node.literal)
- else:
- writer.variable(node.var)
- if node.translate:
- writer.write(")")
-
-
-@node(VariableNode)
-def variable_node(writer, node):
- writer.start_variable()
- if (
- node.filter_expression.var.var == "block.super"
- and not node.filter_expression.filters
- ):
- writer.write("super()")
- else:
- writer.node(node.filter_expression)
- writer.end_variable()
-
-
-@node(FilterExpression)
-def filter_expression(writer, node):
- writer.node(node.var)
- writer.filters(node.filters)
-
-
-@node(core_tags.CommentNode)
-def comment_tag(writer, node):
- pass
-
-
-@node(core_tags.DebugNode)
-def debug_tag(writer, node):
- writer.warn(
- "Debug tag detected. Make sure to add a global function "
- "called debug to the namespace.",
- node=node,
- )
- writer.print_expr("debug()")
-
-
-@node(core_tags.ForNode)
-def for_loop(writer, node):
- writer.start_block()
- writer.write("for ")
- for idx, var in enumerate(node.loopvars):
- if idx:
- writer.write(", ")
- writer.variable(var)
- writer.write(" in ")
- if node.is_reversed:
- writer.write("(")
- writer.node(node.sequence)
- if node.is_reversed:
- writer.write(")|reverse")
- writer.end_block()
- writer.enter_loop()
- writer.body(node.nodelist_loop)
- writer.leave_loop()
- writer.tag("endfor")
-
-
-@node(core_tags.IfNode)
-def if_condition(writer, node):
- writer.start_block()
- writer.write("if ")
- join_with = "and"
- if node.link_type == core_tags.IfNode.LinkTypes.or_:
- join_with = "or"
-
- for idx, (ifnot, expr) in enumerate(node.bool_exprs):
- if idx:
- writer.write(" %s " % join_with)
- if ifnot:
- writer.write("not ")
- writer.node(expr)
- writer.end_block()
- writer.body(node.nodelist_true)
- if node.nodelist_false:
- writer.tag("else")
- writer.body(node.nodelist_false)
- writer.tag("endif")
-
-
-@node(core_tags.IfEqualNode)
-def if_equal(writer, node):
- writer.start_block()
- writer.write("if ")
- writer.node(node.var1)
- if node.negate:
- writer.write(" != ")
- else:
- writer.write(" == ")
- writer.node(node.var2)
- writer.end_block()
- writer.body(node.nodelist_true)
- if node.nodelist_false:
- writer.tag("else")
- writer.body(node.nodelist_false)
- writer.tag("endif")
-
-
-@node(loader_tags.BlockNode)
-def block(writer, node):
- writer.tag("block " + node.name.replace("-", "_").rstrip("_"))
- node = node
- while node.parent is not None:
- node = node.parent
- writer.body(node.nodelist)
- writer.tag("endblock")
-
-
-@node(loader_tags.ExtendsNode)
-def extends(writer, node):
- writer.start_block()
- writer.write("extends ")
- if node.parent_name_expr:
- writer.node(node.parent_name_expr)
- else:
- writer.literal(node.parent_name)
- writer.end_block()
- writer.body(node.nodelist)
-
-
-@node(loader_tags.ConstantIncludeNode)
-@node(loader_tags.IncludeNode)
-def include(writer, node):
- writer.start_block()
- writer.write("include ")
- if hasattr(node, "template"):
- writer.literal(node.template.name)
- else:
- writer.node(node.template_name)
- writer.end_block()
-
-
-@node(core_tags.CycleNode)
-def cycle(writer, node):
- if not writer.in_loop:
- writer.warn("Untranslatable free cycle (cycle outside loop)", node=node)
- return
- if node.variable_name is not None:
- writer.start_block()
- writer.write("set %s = " % node.variable_name)
- else:
- writer.start_variable()
- writer.write("loop.cycle(")
- for idx, var in enumerate(node.raw_cycle_vars):
- if idx:
- writer.write(", ")
- writer.node(var)
- writer.write(")")
- if node.variable_name is not None:
- writer.end_block()
- else:
- writer.end_variable()
-
-
-@node(core_tags.FilterNode)
-def filter(writer, node):
- writer.start_block()
- writer.write("filter ")
- writer.filters(node.filter_expr.filters, True)
- writer.end_block()
- writer.body(node.nodelist)
- writer.tag("endfilter")
-
-
-@node(core_tags.AutoEscapeControlNode)
-def autoescape_control(writer, node):
- original = writer.autoescape
- writer.autoescape = node.setting
- writer.body(node.nodelist)
- writer.autoescape = original
-
-
-@node(core_tags.SpacelessNode)
-def spaceless(writer, node):
- original = writer.spaceless
- writer.spaceless = True
- writer.warn("entering spaceless mode with different semantics", node)
- # do the initial stripping
- nodelist = list(node.nodelist)
- if nodelist:
- if isinstance(nodelist[0], TextNode):
- nodelist[0] = TextNode(nodelist[0].s.lstrip())
- if isinstance(nodelist[-1], TextNode):
- nodelist[-1] = TextNode(nodelist[-1].s.rstrip())
- writer.body(nodelist)
- writer.spaceless = original
-
-
-@node(core_tags.TemplateTagNode)
-def template_tag(writer, node):
- tag = {
- "openblock": writer.block_start_string,
- "closeblock": writer.block_end_string,
- "openvariable": writer.variable_start_string,
- "closevariable": writer.variable_end_string,
- "opencomment": writer.comment_start_string,
- "closecomment": writer.comment_end_string,
- "openbrace": "{",
- "closebrace": "}",
- }.get(node.tagtype)
- if tag:
- writer.start_variable()
- writer.literal(tag)
- writer.end_variable()
-
-
-@node(core_tags.URLNode)
-def url_tag(writer, node):
- writer.warn("url node used. make sure to provide a proper url() function", node)
- if node.asvar:
- writer.start_block()
- writer.write("set %s = " % node.asvar)
- else:
- writer.start_variable()
- writer.write("url(")
- writer.literal(node.view_name)
- for arg in node.args:
- writer.write(", ")
- writer.node(arg)
- for key, arg in node.kwargs.items():
- writer.write(", %s=" % key)
- writer.node(arg)
- writer.write(")")
- if node.asvar:
- writer.end_block()
- else:
- writer.end_variable()
-
-
-@node(core_tags.WidthRatioNode)
-def width_ratio(writer, node):
- writer.warn(
- "widthratio expanded into formula. You may want to provide "
- "a helper function for this calculation",
- node,
- )
- writer.start_variable()
- writer.write("(")
- writer.node(node.val_expr)
- writer.write(" / ")
- writer.node(node.max_expr)
- writer.write(" * ")
- writer.write(str(int(node.max_width)))
- writer.write(")|round|int")
- writer.end_variable(always_safe=True)
-
-
-@node(core_tags.WithNode)
-def with_block(writer, node):
- writer.warn(
- "with block expanded into set statement. This could cause "
- "variables following that block to be overridden.",
- node,
- )
- writer.start_block()
- writer.write("set %s = " % node.name)
- writer.node(node.var)
- writer.end_block()
- writer.body(node.nodelist)
-
-
-@node(core_tags.RegroupNode)
-def regroup(writer, node):
- if node.expression.var.literal:
- writer.warn(
- "literal in groupby filter used. Behavior in that "
- "situation is undefined and translation is skipped.",
- node,
- )
- return
- elif node.expression.filters:
- writer.warn(
- "filters in groupby filter used. Behavior in that "
- "situation is undefined which is most likely a bug "
- "in your code. Filters were ignored.",
- node,
- )
- writer.start_block()
- writer.write("set %s = " % node.var_name)
- writer.node(node.target)
- writer.write("|groupby(")
- writer.literal(node.expression.var.var)
- writer.write(")")
- writer.end_block()
-
-
-@node(core_tags.LoadNode)
-def warn_load(writer, node):
- writer.warn("load statement used which was ignored on conversion", node)
-
-
-@node(i18n_tags.GetAvailableLanguagesNode)
-def get_available_languages(writer, node):
- writer.warn("make sure to provide a get_available_languages function", node)
- writer.tag(
- "set %s = get_available_languages()"
- % writer.translate_variable_name(node.variable)
- )
-
-
-@node(i18n_tags.GetCurrentLanguageNode)
-def get_current_language(writer, node):
- writer.warn("make sure to provide a get_current_language function", node)
- writer.tag(
- "set %s = get_current_language()"
- % writer.translate_variable_name(node.variable)
- )
-
-
-@node(i18n_tags.GetCurrentLanguageBidiNode)
-def get_current_language_bidi(writer, node):
- writer.warn("make sure to provide a get_current_language_bidi function", node)
- writer.tag(
- "set %s = get_current_language_bidi()"
- % writer.translate_variable_name(node.variable)
- )
-
-
-@node(i18n_tags.TranslateNode)
-def simple_gettext(writer, node):
- writer.warn("i18n system used, make sure to install translations", node)
- writer.start_variable()
- writer.write("_(")
- writer.node(node.value)
- writer.write(")")
- writer.end_variable()
-
-
-@node(i18n_tags.BlockTranslateNode)
-def translate_block(writer, node):
- first_var = []
- variables = set()
-
- def touch_var(name):
- variables.add(name)
- if not first_var:
- first_var.append(name)
-
- def dump_token_list(tokens):
- for token in tokens:
- if token.token_type == TOKEN_TEXT:
- writer.write(token.contents)
- elif token.token_type == TOKEN_VAR:
- writer.print_expr(token.contents)
- touch_var(token.contents)
-
- writer.warn("i18n system used, make sure to install translations", node)
- writer.start_block()
- writer.write("trans")
- idx = -1
- for idx, (key, var) in enumerate(node.extra_context.items()):
- if idx:
- writer.write(",")
- writer.write(" %s=" % key)
- touch_var(key)
- writer.node(var.filter_expression)
-
- if node.plural and node.countervar and node.counter:
- plural_var = node.countervar
- if plural_var not in variables:
- if idx > -1:
- writer.write(",")
- touch_var(plural_var)
- writer.write(" %s=" % plural_var)
- writer.node(node.counter)
-
- writer.end_block()
- dump_token_list(node.singular)
- if node.plural and node.countervar and node.counter:
- writer.start_block()
- writer.write("pluralize")
- if node.countervar != first_var[0]:
- writer.write(" " + node.countervar)
- writer.end_block()
- dump_token_list(node.plural)
- writer.tag("endtrans")
-
-
-@node("SimpleNode")
-def simple_tag(writer, node):
- """Check if the simple tag exist as a filter in """
- name = node.tag_name
- if (
- writer.env
- and name not in writer.env.filters
- and name not in writer._filters_warned
- ):
- writer._filters_warned.add(name)
- writer.warn("Filter %s probably doesn't exist in Jinja" % name)
-
- if not node.vars_to_resolve:
- # No argument, pass the request
- writer.start_variable()
- writer.write("request|")
- writer.write(name)
- writer.end_variable()
- return
-
- first_var = node.vars_to_resolve[0]
- args = node.vars_to_resolve[1:]
- writer.start_variable()
-
- # Copied from Writer.filters()
- writer.node(first_var)
-
- writer.write("|")
- writer.write(name)
- if args:
- writer.write("(")
- for idx, var in enumerate(args):
- if idx:
- writer.write(", ")
- if var.var:
- writer.node(var)
- else:
- writer.literal(var.literal)
- writer.write(")")
- writer.end_variable()
-
-
-# get rid of node now, it shouldn't be used normally
-del node
diff --git a/ext/django2jinja/example.py b/ext/django2jinja/example.py
deleted file mode 100644
index 070549f..0000000
--- a/ext/django2jinja/example.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from django.conf import settings
-from django2jinja import convert_templates
-from django2jinja import Writer
-
-settings.configure(TEMPLATE_DIRS=["templates"], TEMPLATE_DEBUG=True)
-writer = Writer(use_jinja_autoescape=True)
-convert_templates("converted", writer=writer)
diff --git a/ext/django2jinja/templates/index.html b/ext/django2jinja/templates/index.html
deleted file mode 100644
index d0fbe38..0000000
--- a/ext/django2jinja/templates/index.html
+++ /dev/null
@@ -1,58 +0,0 @@
-{% extends "layout.html" %}
-{% load i18n %}
-{% block title %}Foo{% endblock %}
-{% block page-body %}
- {{ block.super }}
- Hello {{ name|cut:"d" }}!
-
- {% for item in seq reversed %}
- {% if forloop.index|divisibleby:2 %}
- <li class="{% cycle 'a' 'b' %}">{{ item }}</li>
- {% endif %}
- {% endfor %}
- {% ifequal foo bar %}
- haha
- {% else %}
- hmm
- {% endifequal %}
- {% filter upper %}
- {% include "subtemplate.html" %}
- {% include foo %}
- {% endfilter %}
- {% spaceless %}
- Hello World
- {{ foo }}
- Hmm
- {% endspaceless %}
- {% templatetag opencomment %}...{% templatetag closecomment %}
- {% url foo a, b, c=d %}
- {% url foo a, b, c=d as hmm %}
-
- {% with object.value as value %}
- <img src='bar.gif' height='10' width='{% widthratio value 200 100 %}'>
- {% endwith %}
-
- <pre>{% debug %}</pre>
-
- {% blocktrans with book|title as book_t and author|title as author_t %}
- This is {{ book_t }} by {{ author_t }}
- {% endblocktrans %}
-
- {% blocktrans count list|length as counter %}
- There is only one {{ name }} object.
- {% plural %}
- There are {{ counter }} {{ name }} objects.
- {% endblocktrans %}
-
- {% blocktrans with name|escape as name count list|length as counter %}
- There is only one {{ name }} object.
- {% plural %}
- There are {{ counter }} {{ name }} objects.
- {% endblocktrans %}
-
- {% blocktrans %}This string will have {{ value }} inside.{% endblocktrans %}
-
- <p>{% trans "This is the title." %}</p>
-
- {% regroup people by gender as grouped %}
-{% endblock %}
diff --git a/ext/django2jinja/templates/layout.html b/ext/django2jinja/templates/layout.html
deleted file mode 100644
index 3f21a12..0000000
--- a/ext/django2jinja/templates/layout.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<title>{% block title %}{% endblock %}</title>
-<div class="body">
- {% block page-body %}{% endblock %}
-</div>
diff --git a/ext/django2jinja/templates/subtemplate.html b/ext/django2jinja/templates/subtemplate.html
deleted file mode 100644
index 980a0d5..0000000
--- a/ext/django2jinja/templates/subtemplate.html
+++ /dev/null
@@ -1 +0,0 @@
-Hello World!
diff --git a/ext/djangojinja2.py b/ext/djangojinja2.py
deleted file mode 100644
index 48c7cf6..0000000
--- a/ext/djangojinja2.py
+++ /dev/null
@@ -1,91 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- djangojinja2
- ~~~~~~~~~~~~
-
- Adds support for Jinja to Django.
-
- Configuration variables:
-
- ======================= =============================================
- Key Description
- ======================= =============================================
- `JINJA2_TEMPLATE_DIRS` List of template folders
- `JINJA2_EXTENSIONS` List of Jinja extensions to use
- `JINJA2_CACHE_SIZE` The size of the Jinja template cache.
- ======================= =============================================
-
- :copyright: (c) 2009 by the Jinja Team.
- :license: BSD.
-"""
-from itertools import chain
-
-from django.conf import settings
-from django.http import HttpResponse
-from django.template import TemplateDoesNotExist
-from django.template.context import get_standard_processors
-
-from jinja2 import Environment
-from jinja2 import FileSystemLoader
-from jinja2 import TemplateNotFound
-
-
-# the environment is unconfigured until the first template is loaded.
-_jinja_env = None
-
-
-def get_env():
- """Get the Jinja env and initialize it if necessary."""
- global _jinja_env
- if _jinja_env is None:
- _jinja_env = create_env()
- return _jinja_env
-
-
-def create_env():
- """Create a new Jinja environment."""
- searchpath = list(settings.JINJA2_TEMPLATE_DIRS)
- return Environment(
- loader=FileSystemLoader(searchpath),
- auto_reload=settings.TEMPLATE_DEBUG,
- cache_size=getattr(settings, "JINJA2_CACHE_SIZE", 400),
- extensions=getattr(settings, "JINJA2_EXTENSIONS", ()),
- )
-
-
-def get_template(template_name, globals=None):
- """Load a template."""
- try:
- return get_env().get_template(template_name, globals=globals)
- except TemplateNotFound as e:
- raise TemplateDoesNotExist(str(e))
-
-
-def select_template(templates, globals=None):
- """Try to load one of the given templates."""
- env = get_env()
- for template in templates:
- try:
- return env.get_template(template, globals=globals)
- except TemplateNotFound:
- continue
- raise TemplateDoesNotExist(", ".join(templates))
-
-
-def render_to_string(template_name, context=None, request=None, processors=None):
- """Render a template into a string."""
- context = dict(context or {})
- if request is not None:
- context["request"] = request
- for processor in chain(get_standard_processors(), processors or ()):
- context.update(processor(request))
- return get_template(template_name).render(context)
-
-
-def render_to_response(
- template_name, context=None, request=None, processors=None, mimetype=None
-):
- """Render a template into a response object."""
- return HttpResponse(
- render_to_string(template_name, context, request, processors), mimetype=mimetype
- )
diff --git a/scripts/jinja2-debug.py b/scripts/jinja2-debug.py
deleted file mode 100755
index 96628dd..0000000
--- a/scripts/jinja2-debug.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-"""
- Jinja Debug Interface
- ~~~~~~~~~~~~~~~~~~~~~
-
- Helper script for internal Jinja debugging. Requires Werkzeug.
-
- :copyright: Copyright 2010 by Armin Ronacher.
- :license: BSD.
-"""
-from __future__ import print_function
-
-import sys
-
-from werkzeug import script
-
-import jinja2
-
-env = jinja2.Environment(
- extensions=[
- "jinja2.ext.i18n",
- "jinja2.ext.do",
- "jinja2.ext.loopcontrols",
- "jinja2.ext.with_",
- "jinja2.ext.autoescape",
- ],
- autoescape=True,
-)
-
-
-def shell_init_func():
- def _compile(x):
- print(env.compile(x, raw=True))
-
- result = {"e": env, "c": _compile, "t": env.from_string, "p": env.parse}
- for key in jinja2.__all__:
- result[key] = getattr(jinja2, key)
- return result
-
-
-def action_compile():
- print(env.compile(sys.stdin.read(), raw=True))
-
-
-action_shell = script.make_shell(shell_init_func)
-
-
-if __name__ == "__main__":
- script.run()
diff --git a/scripts/make-release.py b/scripts/make-release.py
deleted file mode 100644
index de36ae1..0000000
--- a/scripts/make-release.py
+++ /dev/null
@@ -1,178 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-"""
- make-release
- ~~~~~~~~~~~~
-
- Helper script that performs a release. Does pretty much everything
- automatically for us.
-
- :copyright: (c) 2011 by Armin Ronacher.
- :license: BSD, see LICENSE for more details.
-"""
-from __future__ import print_function
-
-import os
-import re
-import sys
-from datetime import date
-from datetime import datetime
-from subprocess import PIPE
-from subprocess import Popen
-
-_date_strip_re = re.compile(r"(?<=\d)(st|nd|rd|th)")
-
-
-def parse_changelog():
- with open("CHANGES.rst") as f:
- lineiter = iter(f)
- for line in lineiter:
- match = re.search(r"^Version\s+(.*)", line.strip())
-
- if match is None:
- continue
-
- version = match.group(1).strip()
-
- if next(lineiter).count("-") != len(match.group(0)):
- continue
-
- while 1:
- change_info = next(lineiter).strip()
-
- if change_info:
- break
-
- match = re.search(
- r"(?:codename (.*),\s*)?released on (\w+\s+\d+\w+\s+\d+)(?i)",
- change_info,
- )
-
- if match is None:
- continue
-
- codename, datestr = match.groups()
- return version, parse_date(datestr), codename
-
-
-def bump_version(version):
- try:
- parts = [int(i) for i in version.split(".")]
- except ValueError:
- fail("Current version is not numeric")
-
- parts[-1] += 1
- return ".".join(map(str, parts))
-
-
-def parse_date(string):
- string = _date_strip_re.sub("", string)
- return datetime.strptime(string, "%B %d %Y")
-
-
-def set_filename_version(filename, version_number, pattern):
- changed = []
-
- def inject_version(match):
- before, old, after = match.groups()
- changed.append(True)
- return before + version_number + after
-
- with open(filename) as f:
- contents = re.sub(
- r"^(\s*%s\s*=\s*')(.+?)(')(?sm)" % pattern, inject_version, f.read()
- )
-
- if not changed:
- fail("Could not find %s in %s", pattern, filename)
-
- with open(filename, "w") as f:
- f.write(contents)
-
-
-def set_init_version(version):
- info("Setting __init__.py version to %s", version)
- set_filename_version("jinja2/__init__.py", version, "__version__")
-
-
-def set_setup_version(version):
- info("Setting setup.py version to %s", version)
- set_filename_version("setup.py", version, "version")
-
-
-def build_and_upload():
- cmd = [sys.executable, "setup.py", "sdist", "bdist_wheel"]
- Popen(cmd).wait()
-
-
-def fail(message, *args):
- print("Error:", message % args, file=sys.stderr)
- sys.exit(1)
-
-
-def info(message, *args):
- print(message % args, file=sys.stderr)
-
-
-def get_git_tags():
- return set(Popen(["git", "tag"], stdout=PIPE).communicate()[0].splitlines())
-
-
-def git_is_clean():
- return Popen(["git", "diff", "--quiet"]).wait() == 0
-
-
-def make_git_commit(message, *args):
- message = message % args
- Popen(["git", "commit", "-am", message]).wait()
-
-
-def make_git_tag(tag):
- info('Tagging "%s"', tag)
- Popen(["git", "tag", tag]).wait()
-
-
-def main():
- os.chdir(os.path.join(os.path.dirname(__file__), ".."))
-
- rv = parse_changelog()
-
- if rv is None:
- fail("Could not parse changelog")
-
- version, release_date, codename = rv
- dev_version = bump_version(version) + ".dev"
-
- info(
- "Releasing %s (codename %s, release date %s)",
- version,
- codename,
- release_date.strftime("%d/%m/%Y"),
- )
- tags = get_git_tags()
-
- if version in tags:
- fail('Version "%s" is already tagged', version)
-
- if release_date.date() != date.today():
- fail("Release date is not today (%s != %s)", release_date.date(), date.today())
-
- if not git_is_clean():
- fail("You have uncommitted changes in git")
-
- try:
- __import__("wheel")
- except ImportError:
- fail("You need to install the wheel package.")
-
- set_init_version(version)
- set_setup_version(version)
- make_git_commit("Bump version number to %s", version)
- make_git_tag(version)
- build_and_upload()
- set_init_version(dev_version)
- set_setup_version(dev_version)
-
-
-if __name__ == "__main__":
- main()
diff --git a/scripts/pylintrc b/scripts/pylintrc
deleted file mode 100644
index 16c01fb..0000000
--- a/scripts/pylintrc
+++ /dev/null
@@ -1,301 +0,0 @@
-# lint Python modules using external checkers.
-#
-# This is the main checker controlling the other ones and the reports
-# generation. It is itself both a raw checker and an astng checker in order
-# to:
-# * handle message activation / deactivation at the module level
-# * handle some basic but necessary stats'data (number of classes, methods...)
-#
-[MASTER]
-
-# Specify a configuration file.
-#rcfile=
-
-# Profiled execution.
-profile=no
-
-# Add <file or directory> to the black list. It should be a base name, not a
-# path. You may set this option multiple times.
-ignore=.svn
-
-# Pickle collected data for later comparisons.
-persistent=yes
-
-# Set the cache size for astng objects.
-cache-size=500
-
-# List of plugins (as comma separated values of python modules names) to load,
-# usually to register additional checkers.
-load-plugins=
-
-
-[MESSAGES CONTROL]
-
-# Enable only checker(s) with the given id(s). This option conflict with the
-# disable-checker option
-#enable-checker=
-
-# Enable all checker(s) except those with the given id(s). This option conflict
-# with the disable-checker option
-#disable-checker=
-
-# Enable all messages in the listed categories.
-#enable-msg-cat=
-
-# Disable all messages in the listed categories.
-#disable-msg-cat=
-
-# Enable the message(s) with the given id(s).
-#enable-msg=
-
-# Disable the message(s) with the given id(s).
-disable-msg=C0323,W0142,C0301,C0103,C0111,E0213,C0302,C0203,W0703,R0201
-
-
-[REPORTS]
-
-# set the output format. Available formats are text, parseable, colorized and
-# html
-output-format=colorized
-
-# Include message's id in output
-include-ids=yes
-
-# Put messages in a separate file for each module / package specified on the
-# command line instead of printing them on stdout. Reports (if any) will be
-# written in a file name "pylint_global.[txt|html]".
-files-output=no
-
-# Tells whether to display a full report or only the messages
-reports=yes
-
-# Python expression which should return a note less than 10 (10 is the highest
-# note).You have access to the variables errors warning, statement which
-# respectively contain the number of errors / warnings messages and the total
-# number of statements analyzed. This is used by the global evaluation report
-# (R0004).
-evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
-
-# Add a comment according to your evaluation note. This is used by the global
-# evaluation report (R0004).
-comment=no
-
-# Enable the report(s) with the given id(s).
-#enable-report=
-
-# Disable the report(s) with the given id(s).
-#disable-report=
-
-
-# checks for
-# * unused variables / imports
-# * undefined variables
-# * redefinition of variable from builtins or from an outer scope
-# * use of variable before assignment
-#
-[VARIABLES]
-
-# Tells whether we should check for unused import in __init__ files.
-init-import=no
-
-# A regular expression matching names used for dummy variables (i.e. not used).
-dummy-variables-rgx=_|dummy
-
-# List of additional names supposed to be defined in builtins. Remember that
-# you should avoid to define new builtins when possible.
-additional-builtins=
-
-
-# try to find bugs in the code using type inference
-#
-[TYPECHECK]
-
-# Tells whether missing members accessed in mixin class should be ignored. A
-# mixin class is detected if its name ends with "mixin" (case insensitive).
-ignore-mixin-members=yes
-
-# When zope mode is activated, consider the acquired-members option to ignore
-# access to some undefined attributes.
-zope=no
-
-# List of members which are usually gotten through zope's acquisition mechanism
-# and so shouldn't trigger E0201 when accessed (need zope=yes to be considered)
-acquired-members=REQUEST,acl_users,aq_parent
-
-
-# checks for :
-# * doc strings
-# * modules / classes / functions / methods / arguments / variables name
-# * number of arguments, local variables, branchs, returns and statements in
-# functions, methods
-# * required module attributes
-# * dangerous default values as arguments
-# * redefinition of function / method / class
-# * uses of the global statement
-#
-[BASIC]
-
-# Required attributes for module, separated by a comma
-required-attributes=
-
-# Regular expression which should only match functions or classes name which do
-# not require a docstring
-no-docstring-rgx=__.*__
-
-# Regular expression which should only match correct module names
-module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
-
-# Regular expression which should only match correct module level names
-const-rgx=(([A-Z_][A-Z1-9_]*)|(__.*__))$
-
-# Regular expression which should only match correct class names
-class-rgx=[A-Z_][a-zA-Z0-9]+$
-
-# Regular expression which should only match correct function names
-function-rgx=[a-z_][a-z0-9_]*$
-
-# Regular expression which should only match correct method names
-method-rgx=[a-z_][a-z0-9_]*$
-
-# Regular expression which should only match correct instance attribute names
-attr-rgx=[a-z_][a-z0-9_]*$
-
-# Regular expression which should only match correct argument names
-argument-rgx=[a-z_][a-z0-9_]*$
-
-# Regular expression which should only match correct variable names
-variable-rgx=[a-z_][a-z0-9_]*$
-
-# Regular expression which should only match correct list comprehension /
-# generator expression variable names
-inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
-
-# Good variable names which should always be accepted, separated by a comma
-good-names=i,j,k,ex,Run,_
-
-# Bad variable names which should always be refused, separated by a comma
-bad-names=foo,bar,baz,toto,tutu,tata
-
-# List of builtins function names that should not be used, separated by a comma
-bad-functions=apply,input
-
-
-# checks for sign of poor/misdesign:
-# * number of methods, attributes, local variables...
-# * size, complexity of functions, methods
-#
-[DESIGN]
-
-# Maximum number of arguments for function / method
-max-args=12
-
-# Maximum number of locals for function / method body
-max-locals=30
-
-# Maximum number of return / yield for function / method body
-max-returns=12
-
-# Maximum number of branch for function / method body
-max-branchs=30
-
-# Maximum number of statements in function / method body
-max-statements=60
-
-# Maximum number of parents for a class (see R0901).
-max-parents=7
-
-# Maximum number of attributes for a class (see R0902).
-max-attributes=20
-
-# Minimum number of public methods for a class (see R0903).
-min-public-methods=0
-
-# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
-
-
-# checks for
-# * external modules dependencies
-# * relative / wildcard imports
-# * cyclic imports
-# * uses of deprecated modules
-#
-[IMPORTS]
-
-# Deprecated modules which should not be used, separated by a comma
-deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
-
-# Create a graph of every (i.e. internal and external) dependencies in the
-# given file (report R0402 must not be disabled)
-import-graph=
-
-# Create a graph of external dependencies in the given file (report R0402 must
-# not be disabled)
-ext-import-graph=
-
-# Create a graph of internal dependencies in the given file (report R0402 must
-# not be disabled)
-int-import-graph=
-
-
-# checks for :
-# * methods without self as first argument
-# * overridden methods signature
-# * access only to existent members via self
-# * attributes not defined in the __init__ method
-# * supported interfaces implementation
-# * unreachable code
-#
-[CLASSES]
-
-# List of interface methods to ignore, separated by a comma. This is used for
-# instance to not check methods defines in Zope's Interface base class.
-ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
-
-# List of method names used to declare (i.e. assign) instance attributes.
-defining-attr-methods=__init__,__new__,setUp
-
-
-# checks for similarities and duplicated code. This computation may be
-# memory / CPU intensive, so you should disable it if you experiments some
-# problems.
-#
-[SIMILARITIES]
-
-# Minimum lines number of a similarity.
-min-similarity-lines=10
-
-# Ignore comments when computing similarities.
-ignore-comments=yes
-
-# Ignore docstrings when computing similarities.
-ignore-docstrings=yes
-
-
-# checks for:
-# * warning notes in the code like FIXME, XXX
-# * PEP 263: source code with non ascii character but no encoding declaration
-#
-[MISCELLANEOUS]
-
-# List of note tags to take in consideration, separated by a comma.
-notes=FIXME,XXX,TODO
-
-
-# checks for :
-# * unauthorized constructions
-# * strict indentation
-# * line length
-# * use of <> instead of !=
-#
-[FORMAT]
-
-# Maximum number of characters on a single line.
-max-line-length=90
-
-# Maximum number of lines in a module
-max-module-lines=1000
-
-# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
-# tab).
-indent-string=' '
diff --git a/src/jinja2/ext.py b/src/jinja2/ext.py
index b231071..d4dda0b 100644
--- a/src/jinja2/ext.py
+++ b/src/jinja2/ext.py
@@ -111,10 +111,6 @@ class Extension(with_metaclass(ExtensionRegistry, object)):
to filter tokens returned. This method has to return an iterable of
:class:`~jinja2.lexer.Token`\\s, but it doesn't have to return a
:class:`~jinja2.lexer.TokenStream`.
-
- In the `ext` folder of the Jinja source distribution there is a file
- called `inlinegettext.py` which implements a filter that utilizes this
- method.
"""
return stream