Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nam laoreet justo in velit faucibus lobortis. Sed dictum sagittis
volutpat. Sed adipiscing vestibulum consequat. Nullam laoreet, ante
nec pretium varius, libero arcu porttitor orci, id cursus odio nibh
nec leo. Vestibulum dapibus pellentesque purus, sed bibendum tortor
laoreet id. Praesent quis sodales ipsum. Fusce ut ligula sed diam
pretium sagittis vel at ipsum. Nulla sagittis sem quam, et volutpat
velit. Fusce dapibus ligula quis lectus ultricies tempor. Pellente
'''
def test_mako(count):
template = PageTemplate(CONTENT_TEMPLATE)
base = PageTemplate(BASE_TEMPLATE)
page = PageTemplate(PAGE_TEMPLATE)
table = [xrange(150) for i in xrange(150)]
paragraphs = xrange(50)
title = 'Hello world!'
times = []
for i in range(count):
t0 = time.time()
data = template.render(
table=table, paragraphs=paragraphs,
lorem=LOREM_IPSUM, title=title,
img_count=50,
base=base,
page=page,
)
t1 = time.time()
times.append(t1-t0)
return times
if __name__ == "__main__":
parser = optparse.OptionParser(
usage="%prog [options]",
description=("Test the performance of Chameleon templates."))
util.add_standard_options_to(parser)
(options, args) = parser.parse_args()
util.run_benchmark(options, options.num_runs, test_mako)
Chameleon-2.24/benchmarks/bm_mako.py 0000644 0001750 0000144 00000007444 11641056037 020075 0 ustar mborch users 0000000 0000000 #!/usr/bin/python
"""
Benchmark for test the performance of Mako templates engine.
Includes:
-two template inherences
-HTML escaping, XML escaping, URL escaping, whitespace trimming
-function defitions and calls
-forloops
"""
__author__ = "virhilo@gmail.com (Lukasz Fidosz)"
# Python imports
import os
import sys
import optparse
import time
# Local imports
import util
def relative(*args):
return os.path.join(os.path.dirname(os.path.abspath(__file__)), *args)
sys.path.insert(0, relative('..', 'lib'))
# Mako imports
from mako.template import Template
from mako.lookup import TemplateLookup
LOREM_IPSUM = """Quisque lobortis hendrerit posuere. Curabitur
aliquet consequat sapien molestie pretium. Nunc adipiscing luc
tus mi, viverra porttitor lorem vulputate et. Ut at purus sem,
sed tincidunt ante. Vestibulum ante ipsum primis in faucibus
orci luctus et ultrices posuere cubilia Curae; Praesent pulvinar
sodales justo at congue. Praesent aliquet facilisis nisl a
molestie. Sed tempus nisl ut augue eleifend tincidunt. Sed a
lacinia nulla. Cras tortor est, mollis et consequat at,
vulputate et orci. Nulla sollicitudin"""
BASE_TEMPLATE = """
<%def name="render_table(table)">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nam laoreet justo in velit faucibus lobortis. Sed dictum sagittis
volutpat. Sed adipiscing vestibulum consequat. Nullam laoreet, ante
nec pretium varius, libero arcu porttitor orci, id cursus odio nibh
nec leo. Vestibulum dapibus pellentesque purus, sed bibendum tortor
laoreet id. Praesent quis sodales ipsum. Fusce ut ligula sed diam
pretium sagittis vel at ipsum. Nulla sagittis sem quam, et volutpat
velit. Fusce dapibus ligula quis lectus ultricies tempor. Pellente
${fun1()}
${fun2()}
${fun3()}
${fun4()}
${fun5()}
${fun6()}
"""
def test_mako(count):
lookup = TemplateLookup()
lookup.put_string('base.mako', BASE_TEMPLATE)
lookup.put_string('page.mako', PAGE_TEMPLATE)
template = Template(CONTENT_TEMPLATE, lookup=lookup)
table = [xrange(150) for i in xrange(150)]
paragraphs = xrange(50)
title = 'Hello world!'
times = []
for i in range(count):
t0 = time.time()
data = template.render(table=table, paragraphs=paragraphs,
lorem=LOREM_IPSUM, title=title,
img_count=50)
t1 = time.time()
times.append(t1-t0)
return times
if __name__ == "__main__":
parser = optparse.OptionParser(
usage="%prog [options]",
description=("Test the performance of Mako templates."))
util.add_standard_options_to(parser)
(options, args) = parser.parse_args()
util.run_benchmark(options, options.num_runs, test_mako)
Chameleon-2.24/benchmarks/util.py 0000644 0001750 0000144 00000003407 11743215542 017441 0 ustar mborch users 0000000 0000000 #!/usr/bin/env python
"""Utility code for benchmark scripts."""
__author__ = "collinwinter@google.com (Collin Winter)"
import math
import operator
def run_benchmark(options, num_runs, bench_func, *args):
"""Run the given benchmark, print results to stdout.
Args:
options: optparse.Values instance.
num_runs: number of times to run the benchmark
bench_func: benchmark function. `num_runs, *args` will be passed to this
function. This should return a list of floats (benchmark execution
times).
"""
if options.profile:
import cProfile
prof = cProfile.Profile()
prof.runcall(bench_func, num_runs, *args)
prof.print_stats(sort=options.profile_sort)
else:
data = bench_func(num_runs, *args)
if options.take_geo_mean:
product = reduce(operator.mul, data, 1)
print math.pow(product, 1.0 / len(data))
else:
for x in data:
print x
def add_standard_options_to(parser):
"""Add a bunch of common command-line flags to an existing OptionParser.
This function operates on `parser` in-place.
Args:
parser: optparse.OptionParser instance.
"""
parser.add_option("-n", action="store", type="int", default=100,
dest="num_runs", help="Number of times to run the test.")
parser.add_option("--profile", action="store_true",
help="Run the benchmark through cProfile.")
parser.add_option("--profile_sort", action="store", type="str",
default="time", help="Column to sort cProfile output by.")
parser.add_option("--take_geo_mean", action="store_true",
help="Return the geo mean, rather than individual data.")
Chameleon-2.24/docs/ 0000755 0001750 0000012 00000000000 12614070273 014654 5 ustar mborch wheel 0000000 0000000 Chameleon-2.24/docs/conf.py 0000644 0001750 0000144 00000014367 12035755170 016234 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
#
# Chameleon documentation build configuration file, created by
# sphinx-quickstart on Sun Nov 1 16:08:00 2009.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.append(os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Chameleon'
copyright = u'2008-2011 by Malthe Borch and the Repoze Community'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2.10'
# The full version, including alpha/beta/rc tags.
release = '2.10'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# " v documentation".
html_title = "Chameleon %s documentation" % version
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bchameleonm,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'chameleondoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'chameleon.tex', u'Chameleon Documentation',
u'Malthe Borch et. al', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
Chameleon-2.24/docs/configuration.rst 0000644 0001750 0000144 00000002115 11622523414 020315 0 ustar mborch users 0000000 0000000 Configuration
=============
Most settings can be provided as keyword-arguments to the template
constructor classes.
There are certain settings which are required at environment
level. Acceptable values are ``"0"``, ``"1"``, or the literals
``"true"`` or ``"false"`` (case-insensitive).
General usage
-------------
The following settings are useful in general.
``CHAMELEON_EAGER``
Parse and compile templates on instantiation.
``CHAMELEON_CACHE``
When set to a file system path, the template compiler will write
its output to files in this directory and use it as a cache.
This not only enables you to see the compiler output, but also
speeds up startup.
``CHAMELEON_RELOAD``
This setting controls the default value of the ``auto_reload``
parameter.
Development
-----------
The following settings are mostly useful during development or
debugging of the library itself.
``CHAMELEON_DEBUG``
Enables a set of debugging settings which make it easier to
discover and research issues with the engine itself.
This implicitly enables auto-reload for any template.
Chameleon-2.24/docs/index.rst 0000644 0001750 0000144 00000016332 12210043501 016547 0 ustar mborch users 0000000 0000000 Chameleon
=========
Chameleon is an HTML/XML template engine for `Python
`_.
It's designed to generate the document output of a web application,
typically HTML markup or XML.
The language used is *page templates*, originally a `Zope
`_ invention [1]_, but available here as a
:ref:`standalone library ` that you can use in any
script or application running Python 2.5 and up (including 3.x and
`pypy `_). It comes with a set of :ref:`new features
`, too.
The template engine compiles templates into Python byte-code and is optimized
for speed. For a complex template language, the performance is
:ref:`very good `.
*Found a bug?* Please report issues to the `issue tracker `_.
*Need help?* Post to the Pylons `discussion list `_ or join the ``#pyramid`` channel on `Freenode IRC `_.
Getting the code
----------------
You can `download `_ the
package from the Python package index or install the latest release
using setuptools or the newer `distribute
`_ (required for Python 3.x)::
$ easy_install Chameleon
.. _no-dependencies:
There are no required library dependencies on Python 2.7 and up
[2]_. On 2.5 and 2.6, the `ordereddict
`_ and `unittest2
`_ packages are set as
dependencies.
The project is hosted in a `GitHub repository
`_. Code contributions are
welcome. The easiest way is to use the `pull request
`_ interface.
Introduction
------------
The *page templates* language is used within your document structure
as special element attributes and text markup. Using a set of simple
language constructs, you control the document flow, element
repetition, text replacement and translation.
.. note:: If you've used page templates in a Zope environment previously, note that Chameleon uses Python as the default expression language (instead of *path* expressions).
The basic language (known as the *template attribute language* or TAL)
is simple enough to grasp from an example:
.. code-block:: genshi
Hello, ${'world'}!
${row.capitalize()} ${col}
The ``${...}`` notation is short-hand for text insertion [3]_. The
Python-expression inside the braces is evaluated and the result
included in the output. By default, the string is escaped before
insertion. To avoid this, use the ``structure:`` prefix:
.. code-block:: genshi
${structure: ...}
Note that if the expression result is an object that implements an
``__html__()`` method [4]_, this method will be called and the result
treated as "structure". An example of such an object is the
``Markup`` class that's included as a utility::
from chameleon.utils import Markup
username = Markup("%s" % username)
The macro language (known as the *macro expansion language* or METAL)
provides a means of filling in portions of a generic template.
On the left, the macro template; on the right, a template that loads
and uses the macro, filling in the "content" slot:
.. code-block:: genshi
${structure: document.body}
Example — ${document.title}
${document.title}
In the example, the expression type :ref:`load ` is
used to retrieve a template from the file system using a path relative
to the calling template.
The METAL system works with TAL such that you can for instance fill in
a slot that appears in a ``tal:repeat`` loop, or refer to variables
defined using ``tal:define``.
The third language subset is the translation system (known as the
*internationalization language* or I18N):
.. code-block:: genshi
...
You have ${round(amount, 2)} dollars in your account.
...
Each translation message is marked up using ``i18n:translate`` and
values can be mapped using ``i18n:name``. Attributes are marked for
translation using ``i18n:attributes``. The template engine generates
`gettext `_ translation strings from
the markup::
"You have ${amount} dollars in your account."
If you use a web framework such as `Pyramid
`_, the translation
system is set up automatically and will negotiate on a *target
language* based on the HTTP request or other parameter. If not, then
you need to configure this manually.
Next steps
----------
This was just an introduction. There are a number of other basic
statements that you need to know in order to use the language. This is
all covered in the :ref:`language reference `.
If you're already familiar with the page template language, you can
skip ahead to the :ref:`getting started `
section to learn how to use the template engine in your code.
To learn about integration with your favorite web framework see the
section on :ref:`framework integration `.
License
-------
This software is made available under a BSD-like license.
Contents
========
.. toctree::
:maxdepth: 2
library.rst
reference.rst
integration.rst
configuration.rst
Indices and Tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Notes
=====
.. [1] The template language specifications and API for the Page
Templates engine are based on Zope Page Templates (see in
particular `zope.pagetemplate
`_). However,
the Chameleon compiler and Page Templates engine is an entirely
new codebase, packaged as a standalone distribution. It does
not require a Zope software environment.
.. [2] The translation system in Chameleon is pluggable and based on
`gettext `_.
There is built-in support for the `zope.i18n
`_ package. If this
package is installed, it will be used by default. The
`translationstring
`_ package
offers some of the same helper and utility classes, without the
Zope application interface.
.. [3] This syntax was taken from `Genshi `_.
.. [4] See the `WebHelpers
`_
library which provide a simple wrapper around this method.
Chameleon-2.24/docs/integration.rst 0000644 0001750 0000144 00000002664 12307560376 020013 0 ustar mborch users 0000000 0000000 .. _framework-integration:
Integration
===========
Integration with Chameleon is available for a number of popular web
frameworks. The framework will usually provide loading mechanisms and
translation (internationalization) configuration.
Pyramid
-------
Chameleon is the default template engine for the `Pyramid
`_ framework. See the
section on `Page Templates
`_ for a complete reference.
Zope 2 / Plone
--------------
Install the `five.pt `_ package
to replace the reference template engine (globally).
Zope Toolkit (ZTK)
------------------
Install the `z3c.pt `_ package for
applications based on the `Zope Toolkit
`_ (ZTK). Note that you need to
explicit use the template classes from this package.
Grok
----
Support for the `Grok `_ framework is available
in the `grokcore.chameleon
`_ package.
This package will setup Grok's policy for templating integration and
associate the Chameleon template components for the ``.cpt`` template
filename extension.
Django
------
Install the `django-chameleon-templates `_ app to enable Chameleon as a template engine.
Chameleon-2.24/docs/library.rst 0000644 0001750 0000144 00000012673 12465077662 017143 0 ustar mborch users 0000000 0000000 Library Documentation
=====================
This section documents the package as a Python library. To learn about
the page template language, consult the :ref:`language reference
`.
.. _getting-started-with-cpt:
Getting started
---------------
There are several template constructor classes available, one for each
of the combinations *text* or *xml*, and *string* or *file*.
The file-based constructor requires an absolute path. To set up a
templates directory *once*, use the template loader class::
import os
path = os.path.dirname(__file__)
from chameleon import PageTemplateLoader
templates = PageTemplateLoader(os.path.join(path, "templates"))
Then, to load a template relative to the provided path, use dictionary
syntax::
template = templates['hello.pt']
Alternatively, use the appropriate template class directly. Let's try
with a string input::
from chameleon import PageTemplate
template = PageTemplate("
Hello, ${name}.
")
All template instances are callable. Provide variables by keyword
argument::
>>> template(name='John')
'
Hello, John.
'
.. _fast:
Performance
-----------
The template engine compiles (or *translates*) template source code
into Python byte-code. In simple templates this yields an increase in
performance of about 7 times in comparison to the reference
implementation.
In benchmarks for the content management system `Plone
`_, switching to Chameleon yields a request to
response improvement of 20-50%.
Extension
---------
You can extend the language through the expression engine by writing
your own expression compiler.
Let's try and write an expression compiler for an expression type that
will simply uppercase the supplied value. We'll call it ``upper``.
You can write such a compiler as a closure:
.. code-block:: python
import ast
def uppercase_expression(string):
def compiler(target, engine):
uppercased = self.string.uppercase()
value = ast.Str(uppercased)
return [ast.Assign(targets=[target], value=value)]
return compiler
To make it available under a certain prefix, we'll add it to the
expression types dictionary.
.. code-block:: python
from chameleon import PageTemplate
PageTemplate.expression_types['upper'] = uppercase_expression
Alternatively, you could subclass the template class and set the
attribute ``expression_types`` to a dictionary that includes your
expression:
.. code-block:: python
from chameleon import PageTemplateFile
from chameleon.tales import PythonExpr
class MyPageTemplateFile(PageTemplateFile):
expression_types = {
'python': PythonExpr,
'upper': uppercase_expression
}
You can now uppercase strings *natively* in your templates::
It's probably best to stick with a Python expression::
API reference
-------------
This section describes the documented API of the library.
Templates
~~~~~~~~~
Use the ``PageTemplate*`` template classes to define a template from a
string or file input:
.. automodule:: chameleon
.. autoclass:: chameleon.PageTemplate
Note: The remaining classes take the same general configuration
arguments.
.. automethod:: render
.. autoclass:: chameleon.PageTemplateFile(filename, **config)
.. autoclass:: chameleon.PageTextTemplate
.. autoclass:: chameleon.PageTextTemplateFile
Loader
~~~~~~
Some systems have framework support for loading templates from
files. The following loader class is directly compatible with the
Pylons framework and may be adapted to other frameworks:
.. class:: chameleon.PageTemplateLoader(search_path=None, default_extension=None, **config)
Load templates from ``search_path`` (must be a string or a list of
strings)::
templates = PageTemplateLoader(path)
example = templates['example.pt']
If ``default_extension`` is provided, this will be added to inputs
that do not already have an extension::
templates = PageTemplateLoader(path, ".pt")
example = templates['example']
Any additional keyword arguments will be passed to the template
constructor::
templates = PageTemplateLoader(path, debug=True, encoding="utf-8")
.. automethod:: load
Exceptions
~~~~~~~~~~
Chameleon may raise exceptions during both the cooking and the
rendering phase, but those raised during the cooking phase (parse and
compile) all inherit from a single base class:
.. class:: chameleon.TemplateError(msg, token)
This exception is the base class of all exceptions raised by the
template engine in the case where a template has an error.
It may be raised during rendering since templates are processed
lazily (unless eager loading is enabled).
An error that occurs during the rendering of a template is wrapped in
an exception class to disambiguate the two cases:
.. class:: chameleon.RenderError(*args)
Indicates an exception that resulted from the evaluation of an
expression in a template.
A complete traceback is attached to the exception beginning with
the expression that resulted in the error. The traceback includes
a string representation of the template variable scope for further
reference.
Expressions
~~~~~~~~~~~
For advanced integration, the compiler module provides support for
dynamic expression evaluation:
.. automodule:: chameleon.compiler
.. autoclass:: chameleon.compiler.ExpressionEvaluator
Chameleon-2.24/docs/reference.rst 0000644 0001750 0000012 00000144067 12614070165 017360 0 ustar mborch wheel 0000000 0000000 :tocdepth: 4
.. _language-reference:
.. highlight:: xml
Language Reference
==================
The language reference is structured such that it can be read as a
general introduction to the *page templates* language.
It's split into parts that correspond to each of the main language
features.
Syntax
######
You can safely :ref:`skip this section ` if you're familiar with
how template languages work or just want to learn by example.
An *attribute language* is a programming language designed to render
documents written in XML or HTML markup. The input must be a
well-formed document. The output from the template is usually
XML-like but isn't required to be well-formed.
The statements of the language are document tags with special
attributes, and look like this::
...
In the above example, the attribute
``namespace-prefix:command="argument"`` is the statement, and the
entire paragraph tag is the statement's element. The statement's
element is the portion of the document on which this statement
operates.
The namespace prefixes are typically declared once, at the top of a
template (note that prefix declarations for the template language
namespaces are omitted from the template output)::
...
Thankfully, sane namespace prefix defaults are in place to let us skip
most of the boilerplate::
...
Note how ``tal`` is used without an explicit namespace
declaration. Chameleon sets up defaults for ``metal`` and ``i18n`` as
well.
.. note:: Default prefixes are a special feature of Chameleon.
If the ``enable_data_attributes`` option is set then you can use
``data-prefix-command="argument"`` in addition to the namespace prefix
attributes.
.. _tal:
Basics (TAL)
############
The *template attribute language* is used to create dynamic XML-like
content. It allows elements of a document to be replaced, repeated,
or omitted.
Statements
----------
These are the available statements:
================== ==============
Statement Description
================== ==============
``tal:define`` Define variables.
``tal:switch`` Defines a switch condition
``tal:condition`` Include element only if expression is true.
``tal:repeat`` Repeat an element.
``tal:case`` Includes element only if expression is equal to parent switch.
``tal:content`` Substitute the content of an element.
``tal:replace`` Replace the element with dynamic content.
``tal:omit-tag`` Omit the element tags, leaving only the inner content.
``tal:attributes`` Dynamically change or insert element attributes.
``tal:on-error`` Substitute the content of an element if processing fails.
================== ==============
When there is only one TAL statement per element, the order in which
they are executed is simple. Starting with the root element, each
element's statements are executed, then each of its child elements is
visited, in order, to do the same::
These are your items:
Any combination of statements may appear on the same element, except
that the ``tal:content`` and ``tal:replace`` statements may not be
used on the same element.
.. note:: The ``tal:case`` and ``tal:switch`` statements are available
in Chameleon only.
TAL does not use the order in which statements are written in the
tag to determine the order in which they are executed. When an
element has multiple statements, they are executed in the order
printed in the table above.
There is a reasoning behind this ordering. Because users often want
to set up variables for use in other statements contained within this
element or subelements, ``tal:define`` is executed first. Then any
switch statement. ``tal:condition`` follows, then ``tal:repeat``, then
``tal:case``. We are now rendering an element; first ``tal:content``
or ``tal:replace``. Finally, before ``tal:attributes``, we have
``tal:omit-tag`` (which is implied with ``tal:replace``).
.. note:: *TALES* is used as the expression language for the "stuff in
the quotes". The default syntax is simply Python, but
other inputs are possible --- see the section on :ref:`expressions
`.
``tal:attributes``
^^^^^^^^^^^^^^^^^^
Removes, updates or inserts element attributes.
::
tal:attributes="href request.url"
Syntax
~~~~~~
``tal:attributes`` syntax::
argument ::= attribute_statement [';' attribute_statement]*
attribute_statement ::= (attribute_name expression | expression)
attribute_name ::= [namespace-prefix ':'] Name
namespace-prefix ::= Name
Description
~~~~~~~~~~~
The ``tal:attributes`` statement replaces the value of an attribute
(or drops, or creates an attribute) with a dynamic value. The value
of each expression is converted to a string, if necessary.
.. note:: You can qualify an attribute name with a namespace prefix,
for example ``html:table``, if you are generating an XML document
with multiple namespaces.
If an attribute expression evaluates to ``None``, the attribute is
deleted from the statement element (or simply not inserted).
If an attribute statement is just an expression, it must evaluate to a
Python dict (or implement the methods ``update()`` and ``items()``
from the dictionary specification).
If the expression evaluates to the symbol ``default`` (a symbol which
is always available when evaluating attributes), its value is defined
as the default static attribute value. If there is no such default
value, a return value of ``default`` will drop the attribute.
If you use ``tal:attributes`` on an element with an active
``tal:replace`` command, the ``tal:attributes`` statement is ignored.
If you use ``tal:attributes`` on an element with a ``tal:repeat``
statement, the replacement is made on each repetition of the element,
and the replacement expression is evaluated fresh for each repetition.
.. note:: If you want to include a semicolon (";") in an expression, it
must be escaped by doubling it (";;").
Examples
~~~~~~~~
Replacing a link::
...
Replacing two attributes::
A checkbox input::
``tal:condition``
^^^^^^^^^^^^^^^^^
Conditionally includes or omits an element::
...
Syntax
~~~~~~
``tal:condition`` syntax::
argument ::= expression
Description
~~~~~~~~~~~
The ``tal:condition`` statement includes the statement element in the
template only if the condition is met, and omits it otherwise. If
its expression evaluates to a *true* value, then normal processing of
the element continues, otherwise the statement element is immediately
removed from the template. For these purposes, the value ``nothing``
is false, and ``default`` has the same effect as returning a true
value.
.. note:: Like Python itself, ZPT considers None, zero, empty strings,
empty sequences, empty dictionaries, and instances which return a
nonzero value from ``__len__`` or ``__nonzero__`` false; all other
values are true, including ``default``.
Examples
~~~~~~~~
Test a variable before inserting it::
Testing for odd/even in a repeat-loop::
Even
Odd
``tal:content``
^^^^^^^^^^^^^^^
Replaces the content of an element.
Syntax
~~~~~~
``tal:content`` syntax::
argument ::= (['text'] | 'structure') expression
Description
~~~~~~~~~~~
Rather than replacing an entire element, you can insert text or
structure in place of its children with the ``tal:content`` statement.
The statement argument is exactly like that of ``tal:replace``, and is
interpreted in the same fashion. If the expression evaluates to
``nothing``, the statement element is left childless. If the
expression evaluates to ``default``, then the element's contents are
evaluated.
The default replacement behavior is ``text``, which replaces
angle-brackets and ampersands with their HTML entity equivalents. The
``structure`` keyword passes the replacement text through unchanged,
allowing HTML/XML markup to be inserted. This can break your page if
the text contains unanticipated markup (eg. text submitted via a web
form), which is the reason that it is not the default.
.. note:: The ``structure`` keyword exists to provide backwards
compatibility. In Chameleon, the ``structure:`` expression
type provides the same functionality (also for inline
expressions).
Examples
~~~~~~~~
Inserting the user name::
Fred Farkas
Inserting HTML/XML::
Marked up content goes here.
``tal:define``
^^^^^^^^^^^^^^
Defines local variables.
Syntax
~~~~~~
``tal:define`` syntax::
argument ::= define_scope [';' define_scope]*
define_scope ::= (['local'] | 'global')
define_var define_var ::= variable_name
expression variable_name ::= Name
Description
~~~~~~~~~~~
The ``tal:define`` statement defines variables. When you define a
local variable in a statement element, you can use that variable in
that element and the elements it contains. If you redefine a variable
in a contained element, the new definition hides the outer element's
definition within the inner element.
Note that valid variable names are any Python identifier string
including underscore, although two or more leading underscores are
disallowed (used internally by the compiler). Further, names are
case-sensitive.
Python builtins are always "in scope", but most of them may be
redefined (such as ``help``). Exceptions are:: ``float``, ``int``,
``len``, ``long``, ``str``, ``None``, ``True`` and ``False``.
In addition, the following names are reserved: ``econtext``,
``rcontext``, ``translate``, ``decode`` and ``convert``.
If the expression associated with a variable evaluates to ``nothing``,
then that variable has the value ``nothing``, and may be used as such
in further expressions. Likewise, if the expression evaluates to
``default``, then the variable has the value ``default``, and may be
used as such in further expressions.
You can define two different kinds of variables: *local* and
*global*. When you define a local variable in a statement element, you
can only use that variable in that element and the elements it
contains. If you redefine a local variable in a contained element, the
new definition hides the outer element's definition within the inner
element. When you define a global variables, you can use it in any
element processed after the defining element. If you redefine a global
variable, you replace its definition for the rest of the template.
To set the definition scope of a variable, use the keywords ``local``
or ``global`` in front of the assignment. The default setting is
``local``; thus, in practice, only the ``global`` keyword is used.
.. note:: If you want to include a semicolon (";") in an expression, it
must be escaped by doubling it (";;").
Examples
~~~~~~~~
Defining a variable::
tal:define="company_name 'Zope Corp, Inc.'"
Defining two variables, where the second depends on the first::
tal:define="mytitle context.title; tlen len(mytitle)"
``tal:switch`` and ``tal:case``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Defines a switch clause.
::
odd
even
Syntax
~~~~~~
``tal:case`` and ``tal:switch`` syntax::
argument ::= expression
Description
~~~~~~~~~~~
The *switch* and *case* construct is a short-hand syntax for matching
a set of expressions against a single parent.
The ``tal:switch`` statement is used to set a new parent expression
and the contained ``tal:case`` statements are then matched in sequence
such that only the first match succeeds.
Note that the symbol ``default`` affirms the case precisely when no
previous case has been successful. It should therefore be placed last.
.. note:: These statements are only available in Chameleon 2.x and not
part of the ZPT specification.
Examples
~~~~~~~~
::
Document
Folder
Other
``tal:omit-tag``
^^^^^^^^^^^^^^^^
Removes an element, leaving its contents.
Syntax
~~~~~~
``tal:omit-tag`` syntax::
argument ::= [ expression ]
Description
~~~~~~~~~~~
The ``tal:omit-tag`` statement leaves the contents of an element in
place while omitting the surrounding start and end tags.
If the expression evaluates to a *false* value, then normal processing
of the element continues and the tags are not omitted. If the
expression evaluates to a *true* value, or no expression is provided,
the statement element is replaced with its contents.
.. note:: Like Python itself, ZPT considers None, zero, empty strings,
empty sequences, empty dictionaries, and instances which return a
nonzero value from ``__len__`` or ``__nonzero__`` false; all other
values are true, including ``default``.
Examples
~~~~~~~~
Unconditionally omitting a tag::
...but this text will remain.
Conditionally omitting a tag::
I may be bold.
The above example will omit the ``b`` tag if the variable ``bold`` is false.
Creating ten paragraph tags, with no enclosing tag::
1
.. _tal_repeat:
``tal:repeat``
^^^^^^^^^^^^^^
Repeats an element.
Syntax
~~~~~~
``tal:repeat`` syntax::
argument ::= variable_name expression
variable_name ::= Name
Description
~~~~~~~~~~~
The ``tal:repeat`` statement replicates a sub-tree of your document
once for each item in a sequence. The expression should evaluate to a
sequence. If the sequence is empty, then the statement element is
deleted, otherwise it is repeated for each value in the sequence. If
the expression is ``default``, then the element is left unchanged, and
no new variables are defined.
The ``variable_name`` is used to define a local variable and a repeat
variable. For each repetition, the local variable is set to the
current sequence element, and the repeat variable is set to an
iteration object.
Repeat variables
~~~~~~~~~~~~~~~~~
You use repeat variables to access information about the current
repetition (such as the repeat index). The repeat variable has the
same name as the local variable, but is only accessible through the
built-in variable named ``repeat``.
The following information is available from the repeat variable:
================== ==============
Attribute Description
================== ==============
``index`` Repetition number, starting from zero.
``number`` Repetition number, starting from one.
``even`` True for even-indexed repetitions (0, 2, 4, ...).
``odd`` True for odd-indexed repetitions (1, 3, 5, ...).
``parity`` For odd-indexed repetitions, this is 'odd', else 'even'.
``start`` True for the starting repetition (index 0).
``end`` True for the ending, or final, repetition.
``first`` True for the first item in a group - see note below
``last`` True for the last item in a group - see note below
``length`` Length of the sequence, which will be the total number of repetitions.
``letter`` Repetition number as a lower-case letter: "a" - "z", "aa" - "az", "ba" - "bz", ..., "za" - "zz", "aaa" - "aaz", and so forth.
``Letter`` Upper-case version of *letter*.
``roman`` Repetition number as a lower-case roman numeral: "i", "ii", "iii", "iv", "v", etc.
``Roman`` Upper-case version of *roman*.
================== ==============
You can access the contents of the repeat variable using either
dictionary- or attribute-style access, e.g. ``repeat['item'].start``
or ``repeat.item.start``.
.. note:: For legacy compatibility, the attributes ``odd``, ``even``, ``number``, ``letter``, ``Letter``, ``roman``, and ``Roman`` are callable (returning ``self``).
Note that ``first`` and ``last`` are intended for use with sorted
sequences. They try to divide the sequence into group of items with
the same value.
Examples
~~~~~~~~
Iterating over a sequence of strings::
Inserting a sequence of table rows, and using the repeat variable
to number the rows::
1
Widget
$1.50
Nested repeats::
1 * 1 = 1
Insert objects. Separates groups of objects by type by drawing a rule
between them::
Meta Type
Object ID
.. note:: the objects in the above example should already be sorted by
type.
``tal:replace``
^^^^^^^^^^^^^^^
Replaces an element.
Syntax
~~~~~~
``tal:replace`` syntax::
argument ::= ['structure'] expression
Description
~~~~~~~~~~~
The ``tal:replace`` statement replaces an element with dynamic
content. It replaces the statement element with either text or a
structure (unescaped markup). The body of the statement is an
expression with an optional type prefix. The value of the expression
is converted into an escaped string unless you provide the 'structure' prefix. Escaping consists of converting ``&`` to
``&``, ``<`` to ``<``, and ``>`` to ``>``.
.. note:: If the inserted object provides an ``__html__`` method, that method is called with the result inserted as structure. This feature is not implemented by ZPT.
If the expression evaluates to ``None``, the element is simply removed. If the value is ``default``, then the element is left unchanged.
Examples
~~~~~~~~
Inserting a title::
Title
Inserting HTML/XML::
.. _tales:
Expressions (TALES)
###################
The *Template Attribute Language Expression Syntax* (TALES) standard
describes expressions that supply :ref:`tal` and
:ref:`metal` with data. TALES is *one* possible expression
syntax for these languages, but they are not bound to this definition.
Similarly, TALES could be used in a context having nothing to do with
TAL or METAL.
TALES expressions are described below with any delimiter or quote
markup from higher language layers removed. Here is the basic
definition of TALES syntax::
Expression ::= [type_prefix ':'] String
type_prefix ::= Name
Here are some simple examples::
1 + 2
None
string:Hello, ${view.user_name}
The optional *type prefix* determines the semantics and syntax of the
*expression string* that follows it. A given implementation of TALES
can define any number of expression types, with whatever syntax you
like. It also determines which expression type is indicated by
omitting the prefix.
Types
-----
These are the available TALES expression types:
============= ==============
Prefix Description
============= ==============
``exists`` Evaluate the result inside an exception handler; if one of the exceptions ``AttributeError``, ``LookupError``, ``TypeError``, ``NameError``, or ``KeyError`` is raised during evaluation, the result is ``False``, otherwise ``True``. Note that the original result is discarded in any case.
``import`` Import a global symbol using dotted notation.
``load`` Load a template relative to the current template or absolute.
``not`` Negate the expression result
``python`` Evaluate a Python expression
``string`` Format a string
``structure`` Wraps the expression result as *structure*.
============= ==============
.. note:: The default expression type is ``python``.
.. warning:: The Zope reference engine defaults to a ``path``
expression type, which is closely tied to the Zope
framework. This expression is not implemented in
Chameleon (but it's available in a Zope framework
compatibility package).
There's a mechanism to allow fallback to alternative expressions, if
one should fail (raise an exception). The pipe character ('|') is used
to separate two expressions::
This mechanism applies only to the ``python`` expression type, and by
derivation ``string``.
.. _tales_built_in_names:
``python``
^^^^^^^^^^
Evaluates a Python expression.
Syntax
~~~~~~
Python expression syntax::
Any valid Python language expression
Description
~~~~~~~~~~~
Python expressions are executed natively within the translated
template source code. There is no built-in security apparatus.
``string``
^^^^^^^^^^
Syntax
~~~~~~
String expression syntax::
string_expression ::= ( plain_string | [ varsub ] )*
varsub ::= ( '$' Variable ) | ( '${ Expression }' )
plain_string ::= ( '$$' | non_dollar )*
non_dollar ::= any character except '$'
Description
~~~~~~~~~~~
String expressions interpret the expression string as text. If no
expression string is supplied the resulting string is *empty*. The
string can contain variable substitutions of the form ``$name`` or
``${expression}``, where ``name`` is a variable name, and ``expression`` is a TALES-expression. The escaped string value of the expression is inserted into the string.
.. note:: To prevent a ``$`` from being interpreted this
way, it must be escaped as ``$$``.
Examples
~~~~~~~~
Basic string formatting::
Spam and Eggs
total: 12
Including a dollar sign::
cost: $42.00
.. _import-expression:
``import``
^^^^^^^^^^
Imports a module global.
.. _structure-expression:
``structure``
^^^^^^^^^^^^^
Wraps the expression result as *structure*: The replacement text is
inserted into the document without escaping, allowing HTML/XML markup
to be inserted. This can break your page if the text contains
unanticipated markup (eg. text submitted via a web form), which is
the reason that it is not the default.
.. _load-expression:
``load``
^^^^^^^^
Loads a template instance.
Syntax
~~~~~~
Load expression syntax::
Relative or absolute file path
Description
~~~~~~~~~~~
The template will be loaded using the same template class as the
calling template.
Examples
~~~~~~~~
Loading a template and using it as a macro::
Built-in names
--------------
These are the names always available in the TALES expression namespace:
- ``default`` - special value used to specify that existing text or attributes should not be replaced. See the documentation for individual TAL statements for details on how they interpret *default*.
- ``repeat`` - the *repeat* variables; see :ref:`tal_repeat` for more
information.
- ``template`` - reference to the template which was first called; this symbol is carried over when using macros.
- ``macros`` - reference to the macros dictionary that corresponds to the current template.
.. _metal:
Macros (METAL)
##############
The *Macro Expansion Template Attribute Language* (METAL) standard is
a facility for HTML/XML macro preprocessing. It can be used in
conjunction with or independently of TAL and TALES.
Macros provide a way to define a chunk of presentation in one
template, and share it in others, so that changes to the macro are
immediately reflected in all of the places that share it.
Additionally, macros are always fully expanded, even in a template's
source text, so that the template appears very similar to its final
rendering.
A single Page Template can accomodate multiple macros.
Namespace
---------
The METAL namespace URI and recommended alias are currently defined
as::
xmlns:metal="http://xml.zope.org/namespaces/metal"
Just like the TAL namespace URI, this URI is not attached to a web
page; it's just a unique identifier. This identifier must be used in
all templates which use METAL.
Statements
----------
METAL defines a number of statements:
* ``metal:define-macro`` Define a macro.
* ``metal:use-macro`` Use a macro.
* ``metal:extend-macro`` Extend a macro.
* ``metal:define-slot`` Define a macro customization point.
* ``metal:fill-slot`` Customize a macro.
Although METAL does not define the syntax of expression non-terminals,
leaving that up to the implementation, a canonical expression syntax
for use in METAL arguments is described in TALES Specification.
``define-macro``
^^^^^^^^^^^^^^^^
Defines a macro.
Syntax
~~~~~~
``metal:define-macro`` syntax::
argument ::= Name
Description
~~~~~~~~~~~
The ``metal:define-macro`` statement defines a macro. The macro is named
by the statement expression, and is defined as the element and its
sub-tree.
Examples
~~~~~~~~
Simple macro definition::
Copyright 2011, Foobar Inc.
``define-slot``
^^^^^^^^^^^^^^^
Defines a macro customization point.
Syntax
~~~~~~
``metal:define-slot`` syntax::
argument ::= Name
Description
~~~~~~~~~~~
The ``metal:define-slot`` statement defines a macro customization
point or *slot*. When a macro is used, its slots can be replaced, in
order to customize the macro. Slot definitions provide default content
for the slot. You will get the default slot contents if you decide not
to customize the macro when using it.
The ``metal:define-slot`` statement must be used inside a
``metal:define-macro`` statement.
Slot names must be unique within a macro.
Examples
~~~~~~~~
Simple macro with slot::
Hello World
This example defines a macro with one slot named ``name``. When you use
this macro you can customize the ``b`` element by filling the ``name``
slot.
``fill-slot``
^^^^^^^^^^^^^
Customize a macro.
Syntax
~~~~~~
``metal:fill-slot`` syntax::
argument ::= Name
Description
~~~~~~~~~~~
The ``metal:fill-slot`` statement customizes a macro by replacing a
*slot* in the macro with the statement element (and its content).
The ``metal:fill-slot`` statement must be used inside a
``metal:use-macro`` statement.
Slot names must be unique within a macro.
If the named slot does not exist within the macro, the slot
contents will be silently dropped.
Examples
~~~~~~~~
Given this macro::
Hello World
You can fill the ``name`` slot like so::
Hello Kevin Bacon
``use-macro``
^^^^^^^^^^^^^
Use a macro.
Syntax
~~~~~~
``metal:use-macro`` syntax::
argument ::= expression
Description
~~~~~~~~~~~
The ``metal:use-macro`` statement replaces the statement element with
a macro. The statement expression describes a macro definition.
.. note:: In Chameleon the expression may point to a template instance; in this case it will be rendered in its entirety.
``extend-macro``
^^^^^^^^^^^^^^^^
Extends a macro.
Syntax
~~~~~~
``metal:extend-macro`` syntax::
argument ::= expression
Description
~~~~~~~~~~~
To extend an existing macro, choose a name for the macro and add a
define-macro attribute to a document element with the name as the
argument. Add an extend-macro attribute to the document element with
an expression referencing the base macro as the argument. The
extend-macro must be used in conjunction with define-macro, and must
not be used with use-macro. The element's subtree is the macro
body.
Examples
~~~~~~~~
::
You are here:
.. _i18n:
Translation (I18N)
##################
Translation of template contents and attributes is supported via the
``i18n`` namespace and message objects.
Messages
--------
The translation machinery defines a message as *any object* which is
not a string or a number and which does not provide an ``__html__``
method.
When any such object is inserted into the template, the translate
function is invoked first to see if it needs translation. The result
is always coerced to a native string before it's inserted into the
template.
Translation function
--------------------
The simplest way to hook into the translation machinery is to provide
a translation function to the template constructor or at
render-time. In either case it should be passed as the keyword
argument ``translate``.
The function has the following signature:
.. code-block:: python
def translate(msgid, domain=None, mapping=None, context=None, target_language=None, default=None):
...
The result should be a string or ``None``. If another type of object
is returned, it's automatically coerced into a string.
If `zope.i18n `_ is available,
the translation machinery defaults to using its translation
function. Note that this function requires messages to conform to the
message class from `zope.i18nmessageid
`_; specifically,
messages must have attributes ``domain``, ``mapping`` and
``default``. Example use:
.. code-block:: python
from zope.i18nmessageid import MessageFactory
_ = MessageFactory("food")
apple = _(u"Apple")
There's currently no further support for other translation frameworks.
Using Zope's translation framework
-----------------------------------
The translation function from ``zope.i18n`` relies on *translation
domains* to provide translations.
These are components that are registered for some translation domain
identifier and which implement a ``translate`` method that translates
messages for that domain.
.. note:: To register translation domain components, the Zope Component Architecture must be used (see `zope.component `_).
The easiest way to configure translation domains is to use the the
``registerTranslations`` ZCML-directive; this requires the use of the
`zope.configuration `_
package. This will set up translation domains and gettext catalogs
automatically:
.. code-block:: xml
The ``./locales`` directory must follow a particular directory
structure:
.. code-block:: bash
./locales/en/LC_MESSAGES
./locales/de/LC_MESSAGES
...
In each of the ``LC_MESSAGES`` directories, one `GNU gettext
`_ file in the ``.po``
format must be present per translation domain:
.. code-block:: po
# ./locales/de/LC_MESSAGES/food.po
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Apple"
msgstr "Apfel"
It may be necessary to compile the message catalog using the
``msgfmt`` utility. This will produce a ``.mo`` file.
Translation domains without gettext
-----------------------------------
The following example demonstrates how to manually set up and
configure a translation domain for which messages are provided
directly::
from zope import component
from zope.i18n.simpletranslationdomain import SimpleTranslationDomain
food = SimpleTranslationDomain("food", {
('de', u'Apple'): u'Apfel',
})
component.provideUtility(food, food.domain)
An example of a custom translation domain class::
from zope import interface
class TranslationDomain(object):
interface.implements(ITranslationDomain)
def translate(self, msgid, mapping=None, context=None,
target_language=None, default=None):
...
component.provideUtility(TranslationDomain(), name="custom")
This approach can be used to integrate other translation catalog
implementations.
.. highlight:: xml
Namespace
---------
The ``i18n`` namespace URI and recommended prefix are currently
defined as::
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
This is not a URL, but merely a unique identifier. Do not expect a
browser to resolve it successfully.
Statements
----------
The allowable ``i18n`` statements are:
- ``i18n:translate``
- ``i18n:domain``
- ``i18n:context``
- ``i18n:source``
- ``i18n:target``
- ``i18n:name``
- ``i18n:attributes``
- ``i18n:data``
- ``i18n:comment``
- ``i18n:ignore``
- ``i18n:ignore-attributes``
``i18n:translate``
^^^^^^^^^^^^^^^^^^
This attribute is used to mark units of text for translation. If this
attribute is specified with an empty string as the value, the message
ID is computed from the content of the element bearing this attribute.
Otherwise, the value of the element gives the message ID.
``i18n:domain``
^^^^^^^^^^^^^^^
The ``i18n:domain`` attribute is used to specify the domain to be used
to get the translation. If not specified, the translation services
will use a default domain. The value of the attribute is used
directly; it is not a TALES expression.
``i18n:context``
^^^^^^^^^^^^^^^
The ``i18n:context`` attribute is used to specify the context to be
used to get the translation. If not specified, the translation
services will use a default context. The context is generally use to
distinguish identical texts in different context (because in a
translation this may not be the case.) The value of the attribute is
used literally; it is not an expression.
``i18n:source``
^^^^^^^^^^^^^^^
The ``i18n:source`` attribute specifies the language of the text to be
translated. The default is ``nothing``, which means we don't provide
this information to the translation services.
``i18n:target``
^^^^^^^^^^^^^^^
.. warning:: This is currrently ignored.
The ``i18n:target`` attribute specifies the language of the
translation we want to get. If the value is ``default``, the language
negotiation services will be used to choose the destination language.
If the value is ``nothing``, no translation will be performed; this
can be used to suppress translation within a larger translated unit.
Any other value must be a language code.
The attribute value is a TALES expression; the result of evaluating
the expression is the language code or one of the reserved values.
.. note:: ``i18n:target`` is primarily used for hints to text
extraction tools and translation teams. If you had some text that
should only be translated to e.g. German, then it probably
shouldn't be wrapped in an ``i18n:translate`` span.
``i18n:name``
^^^^^^^^^^^^^
Name the content of the current element for use in interpolation
within translated content. This allows a replaceable component in
content to be re-ordered by translation. For example::
was born in
.
would cause this text to be passed to the translation service::
"${name} was born in ${country}."
``i18n:attributes``
^^^^^^^^^^^^^^^^^^^
This attribute will allow us to translate attributes of HTML tags,
such as the ``alt`` attribute in the ``img`` tag. The
``i18n:attributes`` attribute specifies a list of attributes to be
translated with optional message IDs for each; if multiple attribute
names are given, they must be separated by semicolons. Message IDs
used in this context must not include whitespace.
Note that the value of the particular attributes come either from the
HTML attribute value itself or from the data inserted by
``tal:attributes``.
If an attibute is to be both computed using ``tal:attributes`` and
translated, the translation service is passed the result of the TALES
expression for that attribute.
An example::
In this example, we let ``tal:attributes`` set the value of the ``alt``
attribute to the text "Stop by for a visit!". This text will be
passed to the translation service, which uses the result of language
negotiation to translate "Stop by for a visit!" into the requested
language. The example text in the template, "Visit us", will simply
be discarded.
Another example, with explicit message IDs::
Here, the message ID ``up-arrow-icon`` will be used to generate the
link to an icon image file, and the message ID 'up-arrow-alttext' will
be used for the "alt" text.
``i18n:data``
^^^^^^^^^^^^^
Since TAL always returns strings, we need a way in ZPT to translate
objects, one of the most obvious cases being ``datetime`` objects. The
``data`` attribute will allow us to specify such an object, and
``i18n:translate`` will provide us with a legal format string for that
object. If ``data`` is used, ``i18n:translate`` must be used to give
an explicit message ID, rather than relying on a message ID computed
from the content.
``i18n:comment``
^^^^^^^^^^^^^^^^
The ``i18n:comment`` attribute can be used to add extra comments for
translators. It is not used by Chameleon for processing, but will be
picked up by tools like `lingua `_.
An example:
News
``i18n:ignore``
^^^^^^^^^^^^^^^
The ``i18n:ignore`` attribute can be used to inform translation extraction tools
like `i18ndude `_ to not give a
warning/error on the given tag if there is no ``i18n:translate`` attribute.
An example:
News
``i18n:ignore-attributes``
^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``i18n:ignore-attributes``, just like ``i18n:ignore`` is expected to be
used by translation extraction tools like `i18ndude `_.
If ``i18n:ignore`` makes text within a tag to be ignored, ``i18n:ignore-attributes``
marks the given attributes as ignored.
An example:
Python website
Relation with TAL processing
----------------------------
The attributes defined in the ``i18n`` namespace modify the behavior
of the TAL interpreter for the ``tal:attributes``, ``tal:content``,
``tal:repeat``, and ``tal:replace`` attributes, but otherwise do not
affect TAL processing.
Since these attributes only affect TAL processing by causing
translations to occur at specific times, using these with a TAL
processor which does not support the ``i18n`` namespace degrades well;
the structural expectations for a template which uses the ``i18n``
support is no different from those for a page which does not. The
only difference is that translations will not be performed in a legacy
processor.
Relation with METAL processing
-------------------------------
When using translation with METAL macros, the internationalization
context is considered part of the specific documents that page
components are retrieved from rather than part of the combined page.
This makes the internationalization context lexical rather than
dynamic, making it easier for a site builder to understand the
behavior of each element with respect to internationalization.
Let's look at an example to see what this means::
Note heading goes here
Some longer explanation for the note goes here.
And the macro source::
January
Place for the application to add additional notes if desired.
Note that the macro is using a different domain than the application
(which it should be). With lexical scoping, no special markup needs
to be applied to cause the slot-filler in the application to be part
of the same domain as the rest of the application's page components.
If dynamic scoping were used, the internationalization context would
need to be re-established in the slot-filler.
Extracting translatable message
-------------------------------
Translators use `PO files
`_
when translating messages. To create and update PO files you need to
do two things: *extract* all messages from python and templates files
and store them in a ``.pot`` file, and for each language *update* its
``.po`` file. Chameleon facilitates this by providing extractors for
`Babel `_. To use this you need modify
``setup.py``. For example:
.. code-block:: python
from setuptools import setup
setup(name="mypackage",
install_requires = [
"Babel",
],
message_extractors = { "src": [
("**.py", "chameleon_python", None ),
("**.pt", "chameleon_xml", None ),
]},
)
This tells Babel to scan the ``src`` directory while using the
``chameleon_python`` extractor for all ``.py`` files and the
``chameleon_xml`` extractor for all ``.pt`` files.
You can now use Babel to manage your PO files:
.. code-block:: bash
python setup.py extract_messages --output-file=i18n/mydomain.pot
python setup.py update_catalog \
-l nl \
-i i18n/mydomain.pot \
-o i18n/nl/LC_MESSAGES/mydomain.po
python setup.py compile_catalog \
--directory i18n --locale nl
You can also configure default options in a ``setup.cfg`` file. For example::
[compile_catalog]
domain = mydomain
directory = i18n
[extract_messages]
copyright_holder = Acme Inc.
output_file = i18n/mydomain.pot
charset = UTF-8
[init_catalog]
domain = mydomain
input_file = i18n/mydomain.pot
output_dir = i18n
[update_catalog]
domain = mydomain
input_file = i18n/mydomain.pot
output_dir = i18n
previous = true
You can now use the Babel commands directly::
python setup.py extract_messages
python setup.py update_catalog
python setup.py compile_catalog
${...} operator
###############
The ``${...}`` notation is short-hand for text insertion. The
Python-expression inside the braces is evaluated and the result
included in the output (all inserted text is escaped by default):
.. code-block:: html
${content}
To escape this behavior, prefix the notation with a backslash
character: ``\${...}``.
Note that if an object implements the ``__html__`` method, the result
of this method will be inserted as-is (without XML escaping).
Code blocks
###########
The ```` notation allows you to embed Python code in
templates:
.. code-block:: html
Please input a number from the range ${", ".join(numbers)}.
The scope of name assignments is up to the nearest macro definition,
or the template, if macros are not used.
Note that code blocks can span multiple line and start on the next
line of where the processing instruction begins:
.. code-block:: html
You can use this to debug templates:
.. code-block:: html
Markup comments
###############
You can apply the "!" and "?" modifiers to change how comments are
processed:
Drop
````
Verbatim
````
That is, evaluation of ``${...}`` expressions is disabled if the
comment opens with the "?" character.
.. _new-features:
Language extensions
###################
Chameleon extends the *page template* language with a new expression
types and language features. Some take inspiration from `Genshi
`_.
*New expression types*
The :ref:`structure ` expression wraps an
expression result as *structure*::
${structure: body.text}
The :ref:`import ` expression imports module globals::
...
The :ref:`load ` expression loads templates
relative to the current template::
...
*Tuple unpacking*
The ``tal:define`` and ``tal:repeat`` statements support tuple
unpacking::
tal:define="(a, b, c) [1, 2, 3]"
Extended `iterable unpacking
`_ using the asterisk
character is not currently supported (even for versions of
Python that support it natively).
*Dictionary lookup as fallback after attribute error*
If attribute lookup (using the ``obj.`` syntax) raises an
``AttributeError`` exception, a secondary lookup is attempted
using dictionary lookup --- ``obj['']``.
Behind the scenes, this is done by rewriting all
attribute-lookups to a custom lookup call:
.. code-block:: python
def lookup_attr(obj, key):
try:
return getattr(obj, key)
except AttributeError as exc:
try:
get = obj.__getitem__
except AttributeError:
raise exc
try:
return get(key)
except KeyError:
raise exc
*Inline string substitution*
In element attributes and in the text or tail of an element,
string expression interpolation is available using the
``${...}`` syntax::
${title or item_id}
*Code blocks*
Using ```` notation, you can embed Python
statements in your templates:
.. code-block:: html
Please input a number from the range ${", ".join(numbers)}.
*Literal content*
While the ``tal:content`` and ``tal:repeat`` attributes both
support the ``structure`` keyword which inserts the content as
a literal (without XML-escape), an object may also provide an
``__html__`` method to the same effect.
The result of the method will be inserted as *structure*.
This is particularly useful for content which is substituted
using the expression operator: ``"${...}"`` since the
``structure`` keyword is not allowed here.
*Switch statement*
Two new attributes have been added: ``tal:switch`` and
``tal:case``. A case attribute works like a condition and only
allows content if the value matches that of the nearest parent
switch value.
Incompatibilities and differences
#################################
There are a number of incompatibilities and differences between the
Chameleon language implementation and the Zope reference
implementation (ZPT):
*Default expression*
The default expression type is Python.
*Template arguments*
Arguments passed by keyword to the render- or call method are
inserted directly into the template execution namespace. This is
different from ZPT where these are only available through the
``options`` dictionary.
Zope::
Chameleon::
*Special symbols*
The ``CONTEXTS`` symbol is not available.
The `z3c.pt `_ package works as a
compatibility layer. The template classes in this package provide a
implementation which is fully compatible with ZPT.
Chameleon-2.24/docs/requirements.txt 0000644 0001750 0000144 00000000020 12111137043 020162 0 ustar mborch users 0000000 0000000 Chameleon==2.11
Chameleon-2.24/src/ 0000755 0001750 0000012 00000000000 12614070273 014513 5 ustar mborch wheel 0000000 0000000 Chameleon-2.24/src/Chameleon.egg-info/ 0000755 0001750 0000012 00000000000 12614070273 020100 5 ustar mborch wheel 0000000 0000000 Chameleon-2.24/src/Chameleon.egg-info/PKG-INFO 0000644 0001750 0000144 00000137567 12614070272 021262 0 ustar mborch users 0000000 0000000 Metadata-Version: 1.1
Name: Chameleon
Version: 2.24
Summary: Fast HTML/XML Template Compiler.
Home-page: http://www.pagetemplates.org/
Author: Malthe Borch
Author-email: mborch@gmail.com
License: BSD-like (http://repoze.org/license.html)
Description: Overview
========
Chameleon is an HTML/XML template engine for `Python
`_. It uses the *page templates* language.
You can use it in any Python web application with just about any
version of Python (2.5 and up, including 3.x and `pypy
`_).
Visit the `website `_ for more information
or the `documentation `_.
License and Copyright
---------------------
This software is made available as-is under a BSD-like license [1]_
(see included copyright notice).
Notes
-----
.. [1] This software is licensed under the `Repoze
`_ license.
Changes
=======
2.24 (2015-10-28)
-----------------
- Fixed Python 3.5 compatibility.
- Fixed brown bag release.
2.23 (2015-10-26)
-----------------
- Added ``enable_data_attributes`` option that allows using HTML5 data
attributes as control attributes instead or in addition to XML
namespace attributes.
2.22 (2015-02-06)
-----------------
- Fix brown bag release.
2.21 (2015-02-06)
-----------------
- Added ``RenderError`` exception which indicates that an error
occurred during the evaluation of an expression.
- Clean up ``TemplateError`` exception implementation.
2.20 (2015-01-12)
-----------------
- Pass ``search_path`` to template class when loaded using
``TemplateLoader`` (or one of the derived classes).
[faassen]
2.19 (2015-01-06)
-----------------
- Fix logging deprecation.
- Fix environment-based configuration logging error.
2.18 (2014-11-03)
-----------------
- Fix minor compilation error.
2.17 (2014-11-03)
-----------------
- Add support for ``i18n:context``.
[wiggy]
- Add missing 'parity' repeat property.
[voxspox]
- Don't modify environment when getting variables from it.
[fschulze]
2.16 (2014-05-06)
-----------------
- If a repeat expression evaluates to ``None`` then it is now
equivalent to an empty set.
This changes a behavior introduced in 2.14.
This fixes issue #172.
- Remove fossil test dependency on deprecated ``distribute``.
- Add explicit support / testing for Python 3.3 / 3.4.
- Drop explicit support for Python 2.5 (out of maintenance, and no longer
supported by ``tox`` or ``Travis-CI``).
2.15 (2014-03-11)
-----------------
- Add Support for Python 3.4's ``NameConstant``.
[brakhane]
2.14 (2013-11-28)
-----------------
- Element repetition using the ``TAL`` namespace no longer includes
whitespace. This fixes issue #110.
- Use absolute import for ``chameleon.interfaces`` module. This fixes
issue #161.
2.13-1 (2013-10-24)
-------------------
- Fixing brown bag release.
2.13 (2013-10-21)
-----------------
Bugfixes:
- The template cache mechanism now includes additional configuration
settings as part of the cache key such as ``strict`` and
``trim_attribute_space``.
[ossmkitty]
- Fix cache issue where sometimes cached templates would not load
correctly.
[ossmkitty]
- In debug-mode, correctly remove temporary files when the module
loader is garbage-collected (on ``__del__``).
[graffic]
- Fix error message when duplicate i18n:name directives are used in a
translation.
- Using the three-argument form of ``getattr`` on a
``chameleon.tal.RepeatDict`` no longer raises ``KeyError``,
letting the default provided to ``getattr`` be used. This fixes
attempting to adapt a ``RepeatDict`` to a Zope interface under
PyPy.
2.12 (2013-03-26)
-----------------
Changes:
- When a ``tal:case`` condition succeeds, no other case now will.
Bugfixes:
- Implicit translation now correctly extracts and normalizes complete
sentences, instead of words.
[witsch]
- The ``default`` symbol in a ``tal:case`` condition now allows the
element only if no other case succeeds.
2.11 (2012-11-15)
-----------------
Bugfixes:
- An issue was resolved where a METAL statement was combined with a
``tal:on-error`` handler.
- Fix minor parser issue with incorrectly formatted processing
instructions.
- Provide proper error handling for Python inline code blocks.
Features:
- The simple translation function now supports the
``translationstring`` interface.
Optimizations:
- Minor optimization which correctly detects when an element has no
attributes.
2.10 (2012-10-12)
-----------------
Deprecations:
- The ``fast_translate`` function has been deprecated. Instead, the
default translation function is now always a function that simply
interpolates the mapping onto the message default or id.
The motivation is that since version 2.9, the ``context`` argument
is non-trivial: the ``econtext`` mapping is passed. This breaks an
expectation on the Zope platform that the ``context`` parameter is
the HTTP request. Previously, with Chameleon this parameter was
simply not provided and so that did not cause issues as such.
- The ``ast24`` module has been renamed to ``ast25``. This should help
clear up any confusion that Chameleon 2.x might be support a Python
interpreter less than version 2.5 (it does not).
Features:
- The ``ProxyExpr`` expression class (and hence the ``load:``
expression type) is now a TALES-expression. In practical terms, this
means that the expression type (which computes a string result using
the standard ``"${...}"`` interpolation syntax and proxies the
result through a function) now supports fallback using the pipe
operator (``"|"``). This fixes issue #128.
- An attempt to interpolate using the empty string as the expression
(i.e. ``${}``) now does nothing: the string ``${}`` is simply output
as is.
- Added support for adding, modifying, and removing attributes using a
dictionary expression in ``tal:attributes`` (analogous to Genshi's
``py:attrs`` directive)::
In the example above, ``name`` is an identifier, while ``value`` and
``attrs`` are Python expressions. However, ``attrs`` must evaluate
to a Python dictionary object (more concisely, the value must
implement the dictionary API-methods ``update()`` and ``items()``).
Optimizations:
- In order to cut down on the size of the compiled function objects,
some conversion and quoting statements have been put into
functions. In one measurement, the reduction was 35%. The benchmark
suite does *not* report of an increased render time (actually
slightly decreased).
Bugfixes:
- An exception is now raised if a trivial string is passed for
``metal:fill-slot``. This fixes issue #89.
- An empty string is now never translated. Not really a bug, but it's
been reported in as an issue (#92) because some translation
frameworks handle this case incorrectly.
- The template module loader (file cache) now correctly encodes
generated template source code as UTF-8. This fixes issue #125.
- Fixed issue where a closure might be reused unsafely in nested
template rendering.
- Fixed markup class ``__repr__`` method. This fixes issue #124.
- Added missing return statement to fix printing the non-abbreviated
filename in case of an exception.
[tomo]
2.9.2 (2012-06-06)
------------------
Bugfixes:
- Fixed a PyPy incompatibility.
- Fixed issue #109 which caused testing failures on some platforms.
2.9.1 (2012-06-01)
------------------
Bugfixes:
- Fixed issue #103. The ``tal:on-error`` statement now always adds an
explicit end-tag to the element, even with a substitution content of
nothing.
- Fixed issue #113. The ``tal:on-error`` statement now works correctly
also for dynamic attributes. That is, the fallback tag now includes
only static attributes.
- Fixed name error which prevented the benchmark from running
correctly.
Compatibility:
- Fixed deprecation warning on Python 3 for zope interface implements
declaration. This fixes issue #116.
2.9.0 (2012-05-31)
------------------
Features:
- The translation function now gets the ``econtext`` argument as the
value for ``context``. Note that historically, this was usually an
HTTP request which might provide language negotiation data through a
dictionary interface.
[alvinyue]
Bugfixes:
- Fixed import alias issue which would lead to a syntax error in
generated Python code. Fixes issue #114.
2.8.5 (2012-05-02)
------------------
Bugfixes:
- Fixed minor installation issues on Python 2.5 and 3.
[ppaez]
- Ensure output is unicode even when trivial (an empty string).
2.8.4 (2012-04-18)
------------------
Features:
- In exception output, long filenames are now truncated to 60
characters of output, preventing line wrap which makes it difficult
to scan the exception output.
Bugfixes:
- Include filename and location in exception output for exceptions
raised during compilation.
- If a trivial translation substitution variable is given (i.e. an
empty string), simply ignore it. This fixes issue #106.
2.8.3 (2012-04-16)
------------------
Features:
- Log template source on debug-level before cooking.
- The `target_language` argument, if given, is now available as a
variable in templates.
2.8.2 (2012-03-30)
------------------
Features:
- Temporary caches used in debug mode are cleaned up eagerly, rather
than waiting for process termination.
[mitchellrj]
Bugfixes:
- The `index`, `start` and `end` methods on the TAL repeat object are
now callable. This fixes an incompatibility with ZPT.
- The loader now correctly handles absolute paths on Windows.
[rdale]
2.8.1 (2012-03-29)
------------------
Features:
- The exception formatter now lists errors in 'wrapping order'. This
means that the innermost, and presumably most relevant exception is
shown last.
Bugfixes:
- The exception formatter now correctly recognizes nested errors and
does not rewrap the dynamically generated exception class.
- The exception formatter now correctly sets the ``__module__``
attribute to that of the original exception class.
2.8.0 (2012-02-29)
------------------
Features:
- Added support for code blocks using the `` processing
instruction syntax.
The scope is name assignments is up until the nearest macro
definition, or the template itself if macros are not used.
Bugfixes:
- Fall back to the exception class' ``__new__`` method to safely
create an exception object that is not implemented in Python.
- The exception formatter now keeps track of already formatted
exceptions, and ignores them from further output.
2.7.4 (2012-02-27)
------------------
- The error handler now invokes the ``__init__`` method of
``BaseException`` instead of the possibly overriden method (which
may take required arguments). This fixes issue #97.
[j23d, malthe]
2.7.3 (2012-01-16)
------------------
Bugfixes:
- The trim whitespace option now correctly trims actual whitespace to
a single character, appearing either to the left or to the right of
an element prefix or suffix string.
2.7.2 (2012-01-08)
------------------
Features:
- Added option ``trim_attribute_space`` that decides whether attribute
whitespace is stripped (at most down to a single space). This option
exists to provide compatibility with the reference
implementation. Fixes issue #85.
Bugfixes:
- Ignore unhashable builtins when generating a reverse builtin
map to quickly look up a builtin value.
[malthe]
- Apply translation mapping even when a translation function is not
available. This fixes issue #83.
[malthe]
- Fixed issue #80. The translation domain for a slot is defined by the
source document, i.e. the template providing the content for a slot
whether it be the default or provided through ``metal:fill-slot``.
[jcbrand]
- In certain circumstances, a Unicode non-breaking space character would cause
a define clause to fail to parse.
2.7.1 (2011-12-29)
------------------
Features:
- Enable expression interpolation in CDATA.
- The page template class now implements dictionary access to macros::
template[name]
This is a short-hand for::
template.macros[name]
Bugfixes:
- An invalid define clause would be silently ignored; we now raise a
language error exception. This fixes issue #79.
- Fixed regression where ``${...}`` interpolation expressions could
not span multiple lines. This fixes issue #77.
2.7.0 (2011-12-13)
------------------
Features:
- The ``load:`` expression now derives from the string expression such
that the ``${...}`` operator can be used for expression
interpolation.
- The ``load:`` expression now accepts asset specs; these are resolved
by the ``pkg_resources.resource_filename`` function::
:
An example from the test suite::
chameleon:tests/inputs/hello_world.pt
Bugfixes:
- If an attribute name for translation was not a valid Python
identifier, the compiler would generate invalid code. This has been
fixed, and the compiler now also throws an exception if an attribute
specification contains a comma. (Note that the only valid separator
character is the semicolon, when specifying attributes for
translation via the ``i18n:translate`` statement). This addresses
issue #76.
2.6.2 (2011-12-08)
------------------
Bugfixes:
- Fixed issue where ``tal:on-error`` would not respect
``tal:omit-tag`` or namespace elements which are omitted by default
(such as ````).
- Fixed issue where ``macros`` attribute would not be available on
file-based templates due to incorrect initialization.
- The ``TryExcept`` and ``TryFinally`` AST nodes are not available on
Python 3.3. These have been aliased to ``Try``. This fixes issue
#75.
Features:
- The TAL repeat item now makes a security declaration that grants
access to unprotected subobjects on the Zope 2 platform::
__allow_access_to_unprotected_subobjects__ = True
This is required for legacy compatibility and does not affect other
environments.
- The template object now has a method ``write(body)`` which
explicitly decodes and cooks a string input.
- Added configuration option ``loader_class`` which sets the class
used to create the template loader object.
The class (essentially a callable) is created at template
construction time.
2.6.1 (2011-11-30)
------------------
Bugfixes:
- Decode HTML entities in expression interpolation strings. This fixes
issue #74.
- Allow ``xml`` and ``xmlns`` attributes on TAL, I18N and METAL
namespace elements. This fixes issue #73.
2.6.0 (2011-11-24)
------------------
Features:
- Added support for implicit translation:
The ``implicit_i18n_translate`` option enables implicit translation
of text. The ``implicit_i18n_attributes`` enables implicit
translation of attributes. The latter must be a set and for an
attribute to be implicitly translated, its lowercase string value
must be included in the set.
- Added option ``strict`` (enabled by default) which decides whether
expressions are required to be valid at compile time. That is, if
not set, an exception is only raised for an invalid expression at
evaluation time.
- An expression error now results in an exception only if the
expression is attempted evaluated during a rendering.
- Added a configuration option ``prepend_relative_search_path`` which
decides whether the path relative to a file-based template is
prepended to the load search path. The default is ``True``.
- Added a configuration option ``search_path`` to the file-based
template class, which adds additional paths to the template load
instance bound to the ``load:`` expression. The option takes a
string path or an iterable yielding string paths. The default value
is the empty set.
Bugfixes:
- Exception instances now support pickle/unpickle.
- An attributes in i18n:attributes no longer needs to match an
existing or dynamic attribute in order to appear in the
element. This fixes issue #66.
2.5.3 (2011-10-23)
------------------
Bugfixes:
- Fixed an issue where a nested macro slot definition would fail even
though there existed a parent macro definition. This fixes issue
#69.
2.5.2 (2011-10-12)
------------------
Bugfixes:
- Fixed an issue where technically invalid input would result in a
compiler error.
Features:
- The markup class now inherits from the unicode string type such that
it's compatible with the string interface.
2.5.1 (2011-09-29)
------------------
Bugfixes:
- The symbol names "convert", "decode" and "translate" are now no
longer set as read-only *compiler internals*. This fixes issue #65.
- Fixed an issue where a macro extension chain nested two levels (a
template uses a macro that extends a macro) would lose the middle
slot definitions if slots were defined nested.
The compiler now throws an error if a nested slot definition is used
outside a macro extension context.
2.5.0 (2011-09-23)
------------------
Features:
- An expression type ``structure:`` is now available which wraps the
expression result as *structure* such that it is not escaped on
insertion, e.g.::
${structure: context.body}
This also means that the ``structure`` keyword for ``tal:content``
and ``tal:replace`` now has an alternative spelling via the
expression type ``structure:``.
- The string-based template constructor now accepts encoded input.
2.4.6 (2011-09-23)
------------------
Bugfixes:
- The ``tal:on-error`` statement should catch all exceptions.
- Fixed issue that would prevent escaping of interpolation expression
values appearing in text.
2.4.5 (2011-09-21)
------------------
Bugfixes:
- The ``tal:on-error`` handler should have a ``error`` variable
defined that has the value of the exception thrown.
- The ``tal:on-error`` statement is a substitution statement and
should support the "text" and "structure" insertion methods.
2.4.4 (2011-09-15)
------------------
Bugfixes:
- An encoding specified in the XML document preamble is now read and
used to decode the template input to unicode. This fixes issue #55.
- Encoded expression input on Python 3 is now correctly
decoded. Previously, the string representation output would be
included instead of an actually decoded string.
- Expression result conversion steps are now correctly included in
error handling such that the exception output points to the
expression location.
2.4.3 (2011-09-13)
------------------
Features:
- When an encoding is provided, pass the 'ignore' flag to avoid
decoding issues with bad input.
Bugfixes:
- Fixed pypy compatibility issue (introduced in previous release).
2.4.2 (2011-09-13)
------------------
Bugfixes:
- Fixed an issue in the compiler where an internal variable (such as a
translation default value) would be cached, resulting in variable
scope corruption (see issue #49).
2.4.1 (2011-09-08)
------------------
Bugfixes:
- Fixed an issue where a default value for an attribute would
sometimes spill over into another attribute.
- Fixed issue where the use of the ``default`` name in an attribute
interpolation expression would print the attribute value. This is
unexpected, because it's an expression, not a static text suitable
for output. An attribute value of ``default`` now correctly drops
the attribute.
2.4.0 (2011-08-22)
------------------
Features:
- Added an option ``boolean_attributes`` to evaluate and render a
provided set of attributes using a boolean logic: if the attribute
is a true value, the value will be the attribute name, otherwise the
attribute is dropped.
In the reference implementation, the following attributes are
configured as boolean values when the template is rendered in
HTML-mode::
"compact", "nowrap", "ismap", "declare", "noshade",
"checked", "disabled", "readonly", "multiple", "selected",
"noresize", "defer"
Note that in Chameleon, these attributes must be manually provided.
Bugfixes:
- The carriage return character (used on Windows platforms) would
incorrectly be included in Python comments.
It is now replaced with a line break.
This fixes issue #44.
2.3.8 (2011-08-19)
------------------
- Fixed import error that affected Python 2.5 only.
2.3.7 (2011-08-19)
------------------
Features:
- Added an option ``literal_false`` that disables the default behavior
of dropping an attribute for a value of ``False`` (in addition to
``None``). This modified behavior is the behavior exhibited in
reference implementation.
Bugfixes:
- Undo attribute special HTML attribute behavior (see previous
release).
This turned out not to be a compatible behavior; rather, boolean
values should simply be coerced to a string.
Meanwhile, the reference implementation does support an HTML mode in
which the special attribute behavior is exhibited.
We do not currently support this mode.
2.3.6 (2011-08-18)
------------------
Features:
- Certain HTML attribute names now have a special behavior for a
attribute value of ``True`` (or ``default`` if no default is
defined). For these attributes, this return value will result in the
name being printed as the value::
will be rendered as::
This behavior is compatible with the reference implementation.
2.3.5 (2011-08-18)
------------------
Features:
- Added support for the set operator (``{item, item, ...}``).
Bugfixes:
- If macro is defined on the same element as a translation name, this
no longer results in a "translation name not allowed outside
translation" error. This fixes issue #43.
- Attribute fallback to dictionary lookup now works on multiple items
(e.g. ``d1.d2.d2``). This fixes issue #42.
2.3.4 (2011-08-16)
------------------
Features:
- When inserting content in either attributes or text, a value of
``True`` (like ``False`` and ``None``) will result in no
action.
- Use statically assigned variables for ``"attrs"`` and
``"default"``. This change yields a performance improvement of
15-20%.
- The template loader class now accepts an optional argument
``default_extension`` which accepts a filename extension which will
be appended to the filename if there's not already an extension.
Bugfixes:
- The default symbol is now ``True`` for an attribute if the attribute
default is not provided. Note that the result is that the attribute
is dropped. This fixes issue #41.
- Fixed an issue where assignment to a variable ``"type"`` would
fail. This fixes issue #40.
- Fixed an issue where an (unsuccesful) assignment for a repeat loop
to a compiler internal name would not result in an error.
- If the translation function returns the identical object, manually
coerce it to string. This fixes a compatibility issue with
translation functions which do not convert non-string objects to a
string value, but simply return them unchanged.
2.3.3 (2011-08-15)
------------------
Features:
- The ``load:`` expression now passes the initial keyword arguments to
its template loader (e.g. ``auto_reload`` and ``encoding``).
- In the exception output, string variable values are now limited to a
limited output of characters, single line only.
Bugfixes:
- Fixed horizontal alignment of exception location info
(i.e. 'String:', 'Filename:' and 'Location:') such that they match
the template exception formatter.
2.3.2 (2011-08-11)
------------------
Bugfixes:
- Fixed issue where i18n:domain would not be inherited through macros
and slots. This fixes issue #37.
2.3.1 (2011-08-11)
------------------
Features:
- The ``Builtin`` node type may now be used to represent any Python
local or global name. This allows expression compilers to refer to
e.g. ``get`` or ``getitem``, or to explicit require a builtin object
such as one from the ``extra_builtins`` dictionary.
Bugfixes:
- Builtins which are not explicitly disallowed may now be redefined
and used as variables (e.g. ``nothing``).
- Fixed compiler issue with circular node annotation loop.
2.3 (2011-08-10)
----------------
Features:
- Added support for the following syntax to disable inline evaluation
in a comment:
Note that the initial question mark character (?) will be omitted
from output.
- The parser now accepts '<' and '>' in attributes. Note that this is
invalid markup. Previously, the '<' would not be accepted as a valid
attribute value, but this would result in an 'unexpected end tag'
error elsewhere. This fixes issue #38.
- The expression compiler now provides methods ``assign_text`` and
``assign_value`` such that a template engine might configure this
value conversion to support e.g. encoded strings.
Note that currently, the only client for the ``assign_text`` method
is the string expression type.
- Enable template loader for string-based template classes. Note that
the ``filename`` keyword argument may be provided on initialization
to identify the template source by filename. This fixes issue #36.
- Added ``extra_builtins`` option to the page template class. These
builtins are added to the default builtins dictionary at cook time
and may be provided at initialization using the ``extra_builtins``
keyword argument.
Bugfixes:
- If a translation domain is set for a fill slot, use this setting
instead of the macro template domain.
- The Python expression compiler now correctly decodes HTML entities
``'gt'`` and ``'lt'``. This fixes issue #32.
- The string expression compiler now correctly handles encoded text
(when support for encoded strings is enabled). This fixes issue #35.
- Fixed an issue where setting the ``filename`` attribute on a
file-based template would not automatically cause an invalidation.
- Exceptions raised by Chameleon can now be copied via
``copy.copy``. This fixes issue #36.
[leorochael]
- If copying the exception fails in the exception handler, simply
re-raise the original exception and log a warning.
2.2 (2011-07-28)
----------------
Features:
- Added new expression type ``load:`` that allows loading a
template. Both relative and absolute paths are supported. If the
path given is relative, then it will be resolved with respect to the
directory of the template.
- Added support for dynamic evaluation of expressions.
Note that this is to support legacy applications. It is not
currently wired into the provided template classes.
- Template classes now have a ``builtins`` attribute which may be used
to define built-in variables always available in the template
variable scope.
Incompatibilities:
- The file-based template class no longer accepts a parameter
``loader``. This parameter would be used to load a template from a
relative path, using a ``find(filename)`` method. This was however,
undocumented, and probably not very useful since we have the
``TemplateLoader`` mechanism already.
- The compiled template module now contains an ``initialize`` function
which takes values that map to the template builtins. The return
value of this function is a dictionary that contains the render
functions.
Bugfixes:
- The file-based template class no longer verifies the existance of a
template file (using ``os.lstat``). This now happens implicitly if
eager parsing is enabled, or otherwise when first needed (e.g. at
render time).
This is classified as a bug fix because the previous behavior was
probably not what you'd expect, especially if an application
initializes a lot of templates without needing to render them
immediately.
2.1.1 (2011-07-28)
------------------
Features:
- Improved exception display. The expression string is now shown in
the context of the original source (if available) with a marker
string indicating the location of the expression in the template
source.
Bugfixes:
- The ``structure`` insertion mode now correctly decodes entities for
any expression type (including ``string:``). This fixes issue #30.
- Don't show internal variables in the exception formatter variable
listing.
2.1 (2011-07-25)
----------------
Features:
- Expression interpolation (using the ``${...}`` operator and
previously also ``$identifier``) now requires braces everywhere
except inside the ``string:`` expression type.
This change is motivated by a number of legacy templates in which
the interpolation format without braces ``$identifier`` appears as
text.
2.0.2 (2011-07-25)
------------------
Bugfixes:
- Don't use dynamic variable scope for lambda-scoped variables (#27).
- Avoid duplication of exception class and message in traceback.
- Fixed issue where a ``metal:fill-slot`` would be ignored if a macro
was set to be used on the same element (#16).
2.0.1 (2011-07-23)
------------------
Bugfixes:
- Fixed issue where global variable definition from macro slots would
fail (they would instead be local). This also affects error
reporting from inside slots because this would be recorded
internally as a global.
- Fixed issue with template cache digest (used for filenames); modules
are now invalidated whenever any changes are made to the
distribution set available (packages on ``sys.path``).
- Fixed exception handler to better let exceptions propagate through
the renderer.
- The disk-based module compiler now mangles template source filenames
such that the output Python module is valid and at root level (dots
and hyphens are replaced by an underscore). This fixes issue #17.
- Fixed translations (i18n) on Python 2.5.
2.0 (2011-07-14)
----------------
- Point release.
2.0-rc14 (2011-07-13)
---------------------
Bugfixes:
- The tab character (``\t``) is now parsed correctly when used inside
tags.
Features:
- The ``RepeatDict`` class now works as a proxy behind a seperate
dictionary instance.
- Added template constructor option ``keep_body`` which is a flag
(also available as a class attribute) that controls whether to save
the template body input in the ``body`` attribute.
This is disabled by default, unless debug-mode is enabled.
- The page template loader class now accepts an optional ``formats``
argument which can be used to select an alternative template class.
2.0-rc13 (2011-07-07)
---------------------
Bugfixes:
- The backslash character (followed by optional whitespace and a line
break) was not correctly interpreted as a continuation for Python
expressions.
Features:
- The Python expression implementation is now more flexible for
external subclassing via a new ``parse`` method.
2.0-rc12 (2011-07-04)
---------------------
Bugfixes:
- Initial keyword arguments passed to a template now no longer "leak"
into the template variable space after a macro call.
- An unexpected end tag is now an unrecoverable error.
Features:
- Improve exception output.
2.0-rc11 (2011-05-26)
---------------------
Bugfixes:
- Fixed issue where variable names that begin with an underscore were
seemingly allowed, but their use resulted in a compiler error.
Features:
- Template variable names are now allowed to be prefixed with a single
underscore, but not two or more (reserved for internal use).
Examples of valid names::
item
ITEM
_item
camelCase
underscore_delimited
help
- Added support for Genshi's comment "drop" syntax::
Note the additional exclamation (!) character.
This fixes addresses issue #10.
2.0-rc10 (2011-05-24)
---------------------
Bugfixes:
- The ``tal:attributes`` statement now correctly operates
case-insensitive. The attribute name given in the statement will
replace an existing attribute with the same name, without respect to
case.
Features:
- Added ``meta:interpolation`` statement to control expression
interpolation setting.
Strings that disable the setting: ``"off"`` and ``"false"``.
Strings that enable the setting: ``"on"`` and ``"true"``.
- Expression interpolation now works inside XML comments.
2.0-rc9 (2011-05-05)
--------------------
Features:
- Better debugging support for string decode and conversion. If a
naive join fails, each element in the output will now be attempted
coerced to unicode to try and trigger the failure near to the bad
string.
2.0-rc8 (2011-04-11)
--------------------
Bugfixes:
- If a macro defines two slots with the same name, a caller will now
fill both with a single usage.
- If a valid of ``None`` is provided as the translation function
argument, we now fall back to the class default.
2.0-rc7 (2011-03-29)
--------------------
Bugfixes:
- Fixed issue with Python 2.5 compatibility AST. This affected at
least PyPy 1.4.
Features:
- The ``auto_reload`` setting now defaults to the class value; the
base template class gives a default value of
``chameleon.config.AUTO_RELOAD``. This change allows a subclass to
provide a custom default value (such as an application-specific
debug mode setting).
2.0-rc6 (2011-03-19)
--------------------
Features:
- Added support for ``target_language`` keyword argument to render
method. If provided, the argument will be curried onto the
translation function.
Bugfixes:
- The HTML entities 'lt', 'gt' and 'quot' appearing inside content
subtition expressions are now translated into their native character
values. This fixes an issue where you could not dynamically create
elements using the ``structure`` (which is possible in ZPT). The
need to create such structure stems from the lack of an expression
interpolation operator in ZPT.
- Fixed duplicate file pointer issue with test suite (affected Windows
platforms only). This fixes issue #9.
[oliora]
- Use already open file using ``os.fdopen`` when trying to write out
the module source. This fixes LP #731803.
2.0-rc5 (2011-03-07)
--------------------
Bugfixes:
- Fixed a number of issues concerning the escaping of attribute
values:
1) Static attribute values are now included as they appear in the
source.
This means that invalid attribute values such as ``"true &&
false"`` are now left alone. It's not the job of the template
engine to correct such markup, at least not in the default mode
of operation.
2) The string expression compiler no longer unescapes
values. Instead, this is left to each expression
compiler. Currently only the Python expression compiler unescapes
its input.
3) The dynamic escape code sequence now correctly only replaces
ampersands that are part of an HTML escape format.
Imports:
- The page template classes and the loader class can now be imported
directly from the ``chameleon`` module.
Features:
- If a custom template loader is not provided, relative paths are now
resolved using ``os.abspath`` (i.e. to the current working
directory).
- Absolute paths are normalized using ``os.path.normpath`` and
``os.path.expanduser``. This ensures that all paths are kept in
their "canonical" form.
2.0-rc4 (2011-03-03)
--------------------
Bugfixes:
- Fixed an issue where the output of an end-to-end string expression
would raise an exception if the expression evaluated to ``None`` (it
should simply output nothing).
- The ``convert`` function (which is configurable on the template
class level) now defaults to the ``translate`` function (at
run-time).
This fixes an issue where message objects were not translated (and
thus converted to a string) using the a provided ``translate``
function.
- Fixed string interpolation issue where an expression immediately
succeeded by a right curly bracket would not parse.
This fixes issue #5.
- Fixed error where ``tal:condition`` would be evaluated after
``tal:repeat``.
Features:
- Python expression is now a TALES expression. That means that the
pipe operator can be used to chain two or more expressions in a
try-except sequence.
This behavior was ported from the 1.x series. Note that while it's
still possible to use the pipe character ("|") in an expression, it
must now be escaped.
- The template cache can now be shared by multiple processes.
2.0-rc3 (2011-03-02)
--------------------
Bugfixes:
- Fixed ``atexit`` handler.
This fixes issue #3.
- If a cache directory is specified, it will now be used even when not
in debug mode.
- Allow "comment" attribute in the TAL namespace.
This fixes an issue in the sense that the reference engine allows
any attribute within the TAL namespace. However, only "comment" is
in common use.
- The template constructor now accepts a flag ``debug`` which puts the
template *instance* into debug-mode regardless of the global
setting.
This fixes issue #1.
Features:
- Added exception handler for exceptions raised while evaluating an
expression.
This handler raises (or attempts to) a new exception of the type
``RenderError``, with an additional base class of the original
exception class. The string value of the exception is a formatted
error message which includes the expression that caused the
exception.
If we are unable to create the exception class, the original
exception is re-raised.
2.0-rc2 (2011-02-28)
--------------------
- Fixed upload issue.
2.0-rc1 (2011-02-28)
--------------------
- Initial public release. See documentation for what's new in this
series.
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Chameleon-2.24/src/Chameleon.egg-info/SOURCES.txt 0000644 0001750 0000144 00000041756 12614070273 022044 0 ustar mborch users 0000000 0000000 .gitignore
.travis.yml
CHANGES.rst
COPYRIGHT.txt
LICENSE.txt
MANIFEST.in
Makefile
README.rst
setup.cfg
setup.py
tox.ini
benchmarks/bm_chameleon.py
benchmarks/bm_mako.py
benchmarks/util.py
docs/conf.py
docs/configuration.rst
docs/index.rst
docs/integration.rst
docs/library.rst
docs/reference.rst
docs/requirements.txt
src/Chameleon.egg-info/PKG-INFO
src/Chameleon.egg-info/SOURCES.txt
src/Chameleon.egg-info/dependency_links.txt
src/Chameleon.egg-info/not-zip-safe
src/Chameleon.egg-info/top_level.txt
src/chameleon/__init__.py
src/chameleon/ast25.py
src/chameleon/astutil.py
src/chameleon/benchmark.py
src/chameleon/codegen.py
src/chameleon/compiler.py
src/chameleon/config.py
src/chameleon/exc.py
src/chameleon/i18n.py
src/chameleon/interfaces.py
src/chameleon/loader.py
src/chameleon/metal.py
src/chameleon/namespaces.py
src/chameleon/nodes.py
src/chameleon/parser.py
src/chameleon/program.py
src/chameleon/py25.py
src/chameleon/py26.py
src/chameleon/tal.py
src/chameleon/tales.py
src/chameleon/template.py
src/chameleon/tokenize.py
src/chameleon/utils.py
src/chameleon/tests/__init__.py
src/chameleon/tests/test_doctests.py
src/chameleon/tests/test_exc.py
src/chameleon/tests/test_loader.py
src/chameleon/tests/test_parser.py
src/chameleon/tests/test_sniffing.py
src/chameleon/tests/test_templates.py
src/chameleon/tests/test_tokenizer.py
src/chameleon/tests/inputs/001-interpolation.txt
src/chameleon/tests/inputs/001-interpolation.txt.py
src/chameleon/tests/inputs/001-variable-scope.html
src/chameleon/tests/inputs/001-variable-scope.pt
src/chameleon/tests/inputs/001-variable-scope.pt.py
src/chameleon/tests/inputs/001.xml
src/chameleon/tests/inputs/002-repeat-scope.pt
src/chameleon/tests/inputs/002-repeat-scope.pt.py
src/chameleon/tests/inputs/002.xml
src/chameleon/tests/inputs/003-content.pt
src/chameleon/tests/inputs/003-content.pt.py
src/chameleon/tests/inputs/003.xml
src/chameleon/tests/inputs/004-attributes.pt
src/chameleon/tests/inputs/004-attributes.pt.py
src/chameleon/tests/inputs/004.xml
src/chameleon/tests/inputs/005-default.pt
src/chameleon/tests/inputs/005-default.pt.py
src/chameleon/tests/inputs/005.xml
src/chameleon/tests/inputs/006-attribute-interpolation.pt
src/chameleon/tests/inputs/006-attribute-interpolation.pt.py
src/chameleon/tests/inputs/006.xml
src/chameleon/tests/inputs/007-content-interpolation.pt
src/chameleon/tests/inputs/007-content-interpolation.pt.py
src/chameleon/tests/inputs/007.xml
src/chameleon/tests/inputs/008-builtins.pt
src/chameleon/tests/inputs/008-builtins.pt.py
src/chameleon/tests/inputs/008.xml
src/chameleon/tests/inputs/009-literals.pt
src/chameleon/tests/inputs/009-literals.pt.py
src/chameleon/tests/inputs/009.xml
src/chameleon/tests/inputs/010-structure.pt
src/chameleon/tests/inputs/010-structure.pt.py
src/chameleon/tests/inputs/010.xml
src/chameleon/tests/inputs/011-messages.pt
src/chameleon/tests/inputs/011-messages.pt-en.py
src/chameleon/tests/inputs/011-messages.pt.py
src/chameleon/tests/inputs/011.xml
src/chameleon/tests/inputs/012-translation.pt
src/chameleon/tests/inputs/012-translation.pt-en.py
src/chameleon/tests/inputs/012-translation.pt.py
src/chameleon/tests/inputs/012.xml
src/chameleon/tests/inputs/013-repeat-nested.pt
src/chameleon/tests/inputs/013-repeat-nested.pt.py
src/chameleon/tests/inputs/013.xml
src/chameleon/tests/inputs/014-repeat-nested-similar.pt
src/chameleon/tests/inputs/014-repeat-nested-similar.pt.py
src/chameleon/tests/inputs/014.xml
src/chameleon/tests/inputs/015-translation-nested.pt
src/chameleon/tests/inputs/015-translation-nested.pt-en.py
src/chameleon/tests/inputs/015-translation-nested.pt.py
src/chameleon/tests/inputs/015.xml
src/chameleon/tests/inputs/016-explicit-translation.pt
src/chameleon/tests/inputs/016-explicit-translation.pt-en.py
src/chameleon/tests/inputs/016-explicit-translation.pt.py
src/chameleon/tests/inputs/016.xml
src/chameleon/tests/inputs/017-omit-tag.pt
src/chameleon/tests/inputs/017-omit-tag.pt.py
src/chameleon/tests/inputs/017.xml
src/chameleon/tests/inputs/018-translation-nested-dynamic.pt
src/chameleon/tests/inputs/018-translation-nested-dynamic.pt-en.py
src/chameleon/tests/inputs/018-translation-nested-dynamic.pt.py
src/chameleon/tests/inputs/018.xml
src/chameleon/tests/inputs/019-replace.pt
src/chameleon/tests/inputs/019-replace.pt.py
src/chameleon/tests/inputs/019.xml
src/chameleon/tests/inputs/020-on-error.pt
src/chameleon/tests/inputs/020-on-error.pt.py
src/chameleon/tests/inputs/020.xml
src/chameleon/tests/inputs/021-translation-domain.pt
src/chameleon/tests/inputs/021-translation-domain.pt-en.py
src/chameleon/tests/inputs/021-translation-domain.pt.py
src/chameleon/tests/inputs/021.xml
src/chameleon/tests/inputs/022-switch.pt
src/chameleon/tests/inputs/022-switch.pt.py
src/chameleon/tests/inputs/022.xml
src/chameleon/tests/inputs/023-condition.pt
src/chameleon/tests/inputs/023-condition.pt.py
src/chameleon/tests/inputs/023.xml
src/chameleon/tests/inputs/024-namespace-elements.pt
src/chameleon/tests/inputs/024-namespace-elements.pt.py
src/chameleon/tests/inputs/024.xml
src/chameleon/tests/inputs/025-repeat-whitespace.pt
src/chameleon/tests/inputs/025-repeat-whitespace.pt.py
src/chameleon/tests/inputs/025.xml
src/chameleon/tests/inputs/026-repeat-variable.pt
src/chameleon/tests/inputs/026-repeat-variable.pt.py
src/chameleon/tests/inputs/026.xml
src/chameleon/tests/inputs/027-attribute-replacement.pt
src/chameleon/tests/inputs/027-attribute-replacement.pt.py
src/chameleon/tests/inputs/027.xml
src/chameleon/tests/inputs/028-attribute-toggle.pt
src/chameleon/tests/inputs/028-attribute-toggle.pt.py
src/chameleon/tests/inputs/028.xml
src/chameleon/tests/inputs/029-attribute-ordering.pt
src/chameleon/tests/inputs/029-attribute-ordering.pt.py
src/chameleon/tests/inputs/029.xml
src/chameleon/tests/inputs/030-repeat-tuples.pt
src/chameleon/tests/inputs/030-repeat-tuples.pt.py
src/chameleon/tests/inputs/030.xml
src/chameleon/tests/inputs/031-namespace-with-tal.pt
src/chameleon/tests/inputs/031-namespace-with-tal.pt.py
src/chameleon/tests/inputs/031.xml
src/chameleon/tests/inputs/032-master-template.pt
src/chameleon/tests/inputs/032-master-template.pt.py
src/chameleon/tests/inputs/032.xml
src/chameleon/tests/inputs/033-use-macro-trivial.pt
src/chameleon/tests/inputs/033-use-macro-trivial.pt.py
src/chameleon/tests/inputs/033.xml
src/chameleon/tests/inputs/034-use-template-as-macro.pt
src/chameleon/tests/inputs/034-use-template-as-macro.pt.py
src/chameleon/tests/inputs/034.xml
src/chameleon/tests/inputs/035-use-macro-with-fill-slot.pt
src/chameleon/tests/inputs/035-use-macro-with-fill-slot.pt.py
src/chameleon/tests/inputs/035.xml
src/chameleon/tests/inputs/036-use-macro-inherits-dynamic-scope.pt
src/chameleon/tests/inputs/036.xml
src/chameleon/tests/inputs/037-use-macro-local-variable-scope.pt
src/chameleon/tests/inputs/037.xml
src/chameleon/tests/inputs/038-use-macro-globals.pt
src/chameleon/tests/inputs/038.xml
src/chameleon/tests/inputs/039-globals.pt
src/chameleon/tests/inputs/039.xml
src/chameleon/tests/inputs/040-macro-using-template-symbol.pt
src/chameleon/tests/inputs/040.xml
src/chameleon/tests/inputs/041-translate-nested-names.pt
src/chameleon/tests/inputs/041.xml
src/chameleon/tests/inputs/042-use-macro-fill-footer.pt
src/chameleon/tests/inputs/042.xml
src/chameleon/tests/inputs/043-macro-nested-dynamic-vars.pt
src/chameleon/tests/inputs/043.xml
src/chameleon/tests/inputs/044-tuple-define.pt
src/chameleon/tests/inputs/044.xml
src/chameleon/tests/inputs/045-namespaces.pt
src/chameleon/tests/inputs/045.xml
src/chameleon/tests/inputs/046-extend-macro.pt
src/chameleon/tests/inputs/046.xml
src/chameleon/tests/inputs/047-use-extended-macro.pt
src/chameleon/tests/inputs/047.xml
src/chameleon/tests/inputs/048-use-extended-macro-fill-original.pt
src/chameleon/tests/inputs/048.xml
src/chameleon/tests/inputs/049-entities-in-attributes.pt
src/chameleon/tests/inputs/049.xml
src/chameleon/tests/inputs/050-define-macro-and-use-not-extend.pt
src/chameleon/tests/inputs/050.xml
src/chameleon/tests/inputs/051-use-non-extended-macro.pt
src/chameleon/tests/inputs/051.xml
src/chameleon/tests/inputs/052-i18n-domain-inside-filled-slot.pt
src/chameleon/tests/inputs/052.xml
src/chameleon/tests/inputs/053-special-characters-in-attributes.pt
src/chameleon/tests/inputs/053.xml
src/chameleon/tests/inputs/054-import-expression.pt
src/chameleon/tests/inputs/054.xml
src/chameleon/tests/inputs/055-attribute-fallback-to-dict-lookup.pt
src/chameleon/tests/inputs/055.xml
src/chameleon/tests/inputs/056-comment-attribute.pt
src/chameleon/tests/inputs/056.xml
src/chameleon/tests/inputs/057-order.pt
src/chameleon/tests/inputs/057.xml
src/chameleon/tests/inputs/058-script.pt
src/chameleon/tests/inputs/058.xml
src/chameleon/tests/inputs/059-embedded-javascript.pt
src/chameleon/tests/inputs/059.xml
src/chameleon/tests/inputs/060-macro-with-multiple-same-slots.pt
src/chameleon/tests/inputs/060.xml
src/chameleon/tests/inputs/061-fill-one-slot-but-two-defined.pt
src/chameleon/tests/inputs/061.xml
src/chameleon/tests/inputs/062-comments-and-expressions.pt
src/chameleon/tests/inputs/062.xml
src/chameleon/tests/inputs/063-continuation.pt
src/chameleon/tests/inputs/063.xml
src/chameleon/tests/inputs/064-tags-and-special-characters.pt
src/chameleon/tests/inputs/064.xml
src/chameleon/tests/inputs/065-use-macro-in-fill.pt
src/chameleon/tests/inputs/065.xml
src/chameleon/tests/inputs/066-load-expression.pt
src/chameleon/tests/inputs/066.xml
src/chameleon/tests/inputs/067-attribute-decode.pt
src/chameleon/tests/inputs/067.xml
src/chameleon/tests/inputs/068-less-than-greater-than-in-attributes.pt
src/chameleon/tests/inputs/068.xml
src/chameleon/tests/inputs/069-translation-domain-and-macro.pt
src/chameleon/tests/inputs/069.xml
src/chameleon/tests/inputs/070-translation-domain-and-use-macro.pt
src/chameleon/tests/inputs/070.xml
src/chameleon/tests/inputs/071-html-attribute-defaults.pt
src/chameleon/tests/inputs/071.xml
src/chameleon/tests/inputs/072-repeat-interpolation.pt
src/chameleon/tests/inputs/072.xml
src/chameleon/tests/inputs/073-utf8-encoded.pt
src/chameleon/tests/inputs/073.xml
src/chameleon/tests/inputs/074-encoded-template.pt
src/chameleon/tests/inputs/074.xml
src/chameleon/tests/inputs/075-nested-macros.pt
src/chameleon/tests/inputs/075.xml
src/chameleon/tests/inputs/076-nested-macro-override.pt
src/chameleon/tests/inputs/076.xml
src/chameleon/tests/inputs/077-i18n-attributes.pt
src/chameleon/tests/inputs/077.xml
src/chameleon/tests/inputs/078-tags-and-newlines.pt
src/chameleon/tests/inputs/078.xml
src/chameleon/tests/inputs/079-implicit-i18n.pt
src/chameleon/tests/inputs/079.xml
src/chameleon/tests/inputs/080-xmlns-namespace-on-tal.pt
src/chameleon/tests/inputs/080.xml
src/chameleon/tests/inputs/081-load-spec.pt
src/chameleon/tests/inputs/081.xml
src/chameleon/tests/inputs/082-load-spec-computed.pt
src/chameleon/tests/inputs/082.xml
src/chameleon/tests/inputs/083-template-dict-to-macro.pt
src/chameleon/tests/inputs/083.xml
src/chameleon/tests/inputs/084-interpolation-in-cdata.pt
src/chameleon/tests/inputs/084.xml
src/chameleon/tests/inputs/085-nested-translation.pt
src/chameleon/tests/inputs/085.xml
src/chameleon/tests/inputs/086-self-closing.pt
src/chameleon/tests/inputs/086.xml
src/chameleon/tests/inputs/087-code-blocks.pt
src/chameleon/tests/inputs/087.xml
src/chameleon/tests/inputs/088-python-newlines.pt
src/chameleon/tests/inputs/088.xml
src/chameleon/tests/inputs/089-load-fallback.pt
src/chameleon/tests/inputs/089.xml
src/chameleon/tests/inputs/090-tuple-expression.pt
src/chameleon/tests/inputs/090.xml
src/chameleon/tests/inputs/091-repeat-none.pt
src/chameleon/tests/inputs/091.xml
src/chameleon/tests/inputs/092.xml
src/chameleon/tests/inputs/093.xml
src/chameleon/tests/inputs/094.xml
src/chameleon/tests/inputs/095.xml
src/chameleon/tests/inputs/096.xml
src/chameleon/tests/inputs/097.xml
src/chameleon/tests/inputs/098.xml
src/chameleon/tests/inputs/099.xml
src/chameleon/tests/inputs/100.xml
src/chameleon/tests/inputs/101-unclosed-tags.html
src/chameleon/tests/inputs/101.xml
src/chameleon/tests/inputs/102-unquoted-attributes.html
src/chameleon/tests/inputs/102.xml
src/chameleon/tests/inputs/103-simple-attribute.html
src/chameleon/tests/inputs/103.xml
src/chameleon/tests/inputs/104.xml
src/chameleon/tests/inputs/105.xml
src/chameleon/tests/inputs/106.xml
src/chameleon/tests/inputs/107.xml
src/chameleon/tests/inputs/108.xml
src/chameleon/tests/inputs/109.xml
src/chameleon/tests/inputs/110.xml
src/chameleon/tests/inputs/111.xml
src/chameleon/tests/inputs/112.xml
src/chameleon/tests/inputs/113.xml
src/chameleon/tests/inputs/114.xml
src/chameleon/tests/inputs/115.xml
src/chameleon/tests/inputs/116.xml
src/chameleon/tests/inputs/117.xml
src/chameleon/tests/inputs/118.xml
src/chameleon/tests/inputs/119.xml
src/chameleon/tests/inputs/120-translation-context.pt
src/chameleon/tests/inputs/121-translation-comment.pt
src/chameleon/tests/inputs/122-translation-ignore.pt
src/chameleon/tests/inputs/123-html5-data-attributes.pt
src/chameleon/tests/inputs/greeting.pt
src/chameleon/tests/inputs/hello_world.pt
src/chameleon/tests/inputs/hello_world.txt
src/chameleon/tests/inputs/hello_world.txt.py
src/chameleon/tests/outputs/001.html
src/chameleon/tests/outputs/001.pt
src/chameleon/tests/outputs/001.txt
src/chameleon/tests/outputs/002.pt
src/chameleon/tests/outputs/003.pt
src/chameleon/tests/outputs/004.pt
src/chameleon/tests/outputs/005.pt
src/chameleon/tests/outputs/006.pt
src/chameleon/tests/outputs/007.pt
src/chameleon/tests/outputs/008.pt
src/chameleon/tests/outputs/009.pt
src/chameleon/tests/outputs/010.pt
src/chameleon/tests/outputs/011-en.pt
src/chameleon/tests/outputs/011.pt
src/chameleon/tests/outputs/012-en.pt
src/chameleon/tests/outputs/012.pt
src/chameleon/tests/outputs/013.pt
src/chameleon/tests/outputs/014.pt
src/chameleon/tests/outputs/015-en.pt
src/chameleon/tests/outputs/015.pt
src/chameleon/tests/outputs/016-en.pt
src/chameleon/tests/outputs/016.pt
src/chameleon/tests/outputs/017.pt
src/chameleon/tests/outputs/018-en.pt
src/chameleon/tests/outputs/018.pt
src/chameleon/tests/outputs/019.pt
src/chameleon/tests/outputs/020.pt
src/chameleon/tests/outputs/021-en.pt
src/chameleon/tests/outputs/021.pt
src/chameleon/tests/outputs/022.pt
src/chameleon/tests/outputs/023.pt
src/chameleon/tests/outputs/024.pt
src/chameleon/tests/outputs/025.pt
src/chameleon/tests/outputs/026.pt
src/chameleon/tests/outputs/027.pt
src/chameleon/tests/outputs/028.pt
src/chameleon/tests/outputs/029.pt
src/chameleon/tests/outputs/030.pt
src/chameleon/tests/outputs/031.pt
src/chameleon/tests/outputs/032.pt
src/chameleon/tests/outputs/033.pt
src/chameleon/tests/outputs/034.pt
src/chameleon/tests/outputs/035.pt
src/chameleon/tests/outputs/036.pt
src/chameleon/tests/outputs/037.pt
src/chameleon/tests/outputs/038.pt
src/chameleon/tests/outputs/039.pt
src/chameleon/tests/outputs/040.pt
src/chameleon/tests/outputs/041.pt
src/chameleon/tests/outputs/042.pt
src/chameleon/tests/outputs/043.pt
src/chameleon/tests/outputs/044.pt
src/chameleon/tests/outputs/045.pt
src/chameleon/tests/outputs/046.pt
src/chameleon/tests/outputs/047.pt
src/chameleon/tests/outputs/048.pt
src/chameleon/tests/outputs/049.pt
src/chameleon/tests/outputs/050.pt
src/chameleon/tests/outputs/051.pt
src/chameleon/tests/outputs/052.pt
src/chameleon/tests/outputs/053.pt
src/chameleon/tests/outputs/054.pt
src/chameleon/tests/outputs/055.pt
src/chameleon/tests/outputs/056.pt
src/chameleon/tests/outputs/057.pt
src/chameleon/tests/outputs/058.pt
src/chameleon/tests/outputs/059.pt
src/chameleon/tests/outputs/060.pt
src/chameleon/tests/outputs/061.pt
src/chameleon/tests/outputs/062.pt
src/chameleon/tests/outputs/063.pt
src/chameleon/tests/outputs/064.pt
src/chameleon/tests/outputs/065.pt
src/chameleon/tests/outputs/066.pt
src/chameleon/tests/outputs/067.pt
src/chameleon/tests/outputs/068.pt
src/chameleon/tests/outputs/069-en.pt
src/chameleon/tests/outputs/069.pt
src/chameleon/tests/outputs/070-en.pt
src/chameleon/tests/outputs/070.pt
src/chameleon/tests/outputs/071.pt
src/chameleon/tests/outputs/072.pt
src/chameleon/tests/outputs/073.pt
src/chameleon/tests/outputs/074.pt
src/chameleon/tests/outputs/075.pt
src/chameleon/tests/outputs/076.pt
src/chameleon/tests/outputs/077-en.pt
src/chameleon/tests/outputs/077.pt
src/chameleon/tests/outputs/078.pt
src/chameleon/tests/outputs/079-en.pt
src/chameleon/tests/outputs/079.pt
src/chameleon/tests/outputs/080.pt
src/chameleon/tests/outputs/081.pt
src/chameleon/tests/outputs/082.pt
src/chameleon/tests/outputs/083.pt
src/chameleon/tests/outputs/084.pt
src/chameleon/tests/outputs/085-en.pt
src/chameleon/tests/outputs/085.pt
src/chameleon/tests/outputs/086.pt
src/chameleon/tests/outputs/087.pt
src/chameleon/tests/outputs/088.pt
src/chameleon/tests/outputs/089.pt
src/chameleon/tests/outputs/090.pt
src/chameleon/tests/outputs/091.pt
src/chameleon/tests/outputs/101.html
src/chameleon/tests/outputs/102.html
src/chameleon/tests/outputs/103.html
src/chameleon/tests/outputs/120-en.pt
src/chameleon/tests/outputs/120.pt
src/chameleon/tests/outputs/121.pt
src/chameleon/tests/outputs/122.pt
src/chameleon/tests/outputs/123.pt
src/chameleon/tests/outputs/greeting.pt
src/chameleon/tests/outputs/hello_world.pt
src/chameleon/tests/outputs/hello_world.txt
src/chameleon/zpt/__init__.py
src/chameleon/zpt/loader.py
src/chameleon/zpt/program.py
src/chameleon/zpt/template.py Chameleon-2.24/src/Chameleon.egg-info/dependency_links.txt 0000644 0001750 0000144 00000000001 12614070272 024210 0 ustar mborch users 0000000 0000000
Chameleon-2.24/src/Chameleon.egg-info/not-zip-safe 0000644 0001750 0000144 00000000001 11520513763 022372 0 ustar mborch users 0000000 0000000
Chameleon-2.24/src/Chameleon.egg-info/top_level.txt 0000644 0001750 0000144 00000000012 12614070272 022665 0 ustar mborch users 0000000 0000000 chameleon
Chameleon-2.24/src/chameleon/ 0000755 0001750 0000012 00000000000 12614070273 016446 5 ustar mborch wheel 0000000 0000000 Chameleon-2.24/src/chameleon/tests/ 0000755 0001750 0000012 00000000000 12614070273 017610 5 ustar mborch wheel 0000000 0000000 Chameleon-2.24/src/chameleon/tests/inputs/ 0000755 0001750 0000012 00000000000 12614070273 021132 5 ustar mborch wheel 0000000 0000000 Chameleon-2.24/src/chameleon/tests/inputs/001-interpolation.txt 0000644 0001750 0000144 00000000026 11531710252 025114 0 ustar mborch users 0000000 0000000 ${''}<&>
Chameleon-2.24/src/chameleon/tests/inputs/001-interpolation.txt.py 0000600 0001750 0000144 00000003502 11547550677 025561 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
pass
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
# '" (1:2)> -> _content_139955154988272
try:
_content_139955154988272 = ''
except:
rcontext.setdefault('__error__', []).append((u"''", 1, 2, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is not None):
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = str(_content_139955154988272)
else:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except AttributeError:
_content_139955154988272 = convert(_content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272()
_content_139955154988272 = ('%s%s' % ((_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u'<&>\n' if (u'<&>\n' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/001-variable-scope.html 0000644 0001750 0000144 00000000163 11450127612 025252 0 ustar mborch users 0000000 0000000
${text}
$text
${text | 'Goodbye world!'}
Chameleon-2.24/src/chameleon/tests/inputs/001-variable-scope.pt 0000644 0001750 0000144 00000000317 11613337133 024734 0 ustar mborch users 0000000 0000000
${text}
bad
ok
Chameleon-2.24/src/chameleon/tests/inputs/001-variable-scope.pt.py 0000600 0001750 0000144 00000021443 11547550676 025375 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
pass
_static_35706576 = {}
_static_35782288 = {}
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_35341232 = get('attrs', _marker)
# name=None at 221fb50> -> _value
_value = _static_35782288
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_text_35704976 = get('text', _marker)
# -> _value
try:
_value = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 2, 25, '', _sys.exc_info()[1], ))
raise
econtext['text'] = _value
_backup_attrs_35343320 = get('attrs', _marker)
# name=None at 221f410> -> _value
_value = _static_35706576
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = getitem('text')
except:
rcontext.setdefault('__error__', []).append((u'text', 3, 6, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
# -> _content_139955154988272_65
try:
_content_139955154988272_65 = getitem('text')
except:
rcontext.setdefault('__error__', []).append((u'text', 4, 5, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272_65 is None):
pass
else:
if (_content_139955154988272_65 is False):
_content_139955154988272_65 = None
else:
_tt = type(_content_139955154988272_65)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272_65 = unicode(_content_139955154988272_65)
else:
try:
if (_tt is str):
_content_139955154988272_65 = decode(_content_139955154988272_65)
else:
if (_tt is not unicode):
try:
_content_139955154988272_65 = _content_139955154988272_65.__html__
except:
_content_139955154988272_65 = convert(_content_139955154988272_65)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272_65 = _content_139955154988272_65()
else:
if ((_content_139955154988272_65 is not None) and (re_needs_escape(_content_139955154988272_65) is not None)):
if ('&' in _content_139955154988272_65):
if (';' in _content_139955154988272_65):
_content_139955154988272_65 = re_amp.sub('&', _content_139955154988272_65)
else:
_content_139955154988272_65 = _content_139955154988272_65.replace('&', '&')
if ('<' in _content_139955154988272_65):
_content_139955154988272_65 = _content_139955154988272_65.replace('<', '<')
if ('>' in _content_139955154988272_65):
_content_139955154988272_65 = _content_139955154988272_65.replace('>', '>')
if ('\x00' in _content_139955154988272_65):
_content_139955154988272_65 = _content_139955154988272_65.replace('\x00', '"')
_content_139955154988272 = ('%s%s%s%s%s' % ((u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272_65 if (_content_139955154988272_65 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35343320 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35343320
if (_backup_text_35704976 is _marker):
del econtext['text']
else:
econtext['text'] = _backup_text_35704976
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
# -> _condition
try:
try:
_ignore = getitem('text')
except (AttributeError, LookupError, TypeError, NameError, KeyError, ):
_condition = 0
else:
_condition = 1
except:
rcontext.setdefault('__error__', []).append((u'exists: text', 6, 24, '', _sys.exc_info()[1], ))
raise
if _condition:
_content_139955154988272 = u'\n bad\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
# -> _condition
try:
try:
_ignore = getitem('text')
except (AttributeError, LookupError, TypeError, NameError, KeyError, ):
_condition = 0
else:
_condition = 1
_condition = not _condition
except:
rcontext.setdefault('__error__', []).append((u'not: exists: text', 9, 24, '', _sys.exc_info()[1], ))
raise
if _condition:
_content_139955154988272 = u'\n ok\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35341232 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35341232
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/001.xml 0000644 0001750 0000144 00000000074 11445675021 022223 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/002-repeat-scope.pt 0000644 0001750 0000144 00000000331 11474511104 024421 0 ustar mborch users 0000000 0000000
')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_char_35801040 = get('char', _marker)
# -> _iterator
try:
_iterator = ('!', '.', )
except:
rcontext.setdefault('__error__', []).append((u"('!', '.')", 4, 29, '', _sys.exc_info()[1], ))
raise
(_iterator, __index_35780944, ) = getitem('repeat')(u'char', _iterator)
econtext['char'] = None
for _item in _iterator:
econtext['char'] = _item
_backup_attrs_35899800 = get('attrs', _marker)
# name=None at 221fbd0> -> _value
_value = _static_35781456
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = getitem('text')
except:
rcontext.setdefault('__error__', []).append((u'text', 4, 43, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
# -> _content_139955154988272_113
try:
_content_139955154988272_113 = getitem('char')
except:
rcontext.setdefault('__error__', []).append((u'char', 4, 50, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272_113 is None):
pass
else:
if (_content_139955154988272_113 is False):
_content_139955154988272_113 = None
else:
_tt = type(_content_139955154988272_113)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272_113 = unicode(_content_139955154988272_113)
else:
try:
if (_tt is str):
_content_139955154988272_113 = decode(_content_139955154988272_113)
else:
if (_tt is not unicode):
try:
_content_139955154988272_113 = _content_139955154988272_113.__html__
except:
_content_139955154988272_113 = convert(_content_139955154988272_113)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272_113 = _content_139955154988272_113()
else:
if ((_content_139955154988272_113 is not None) and (re_needs_escape(_content_139955154988272_113) is not None)):
if ('&' in _content_139955154988272_113):
if (';' in _content_139955154988272_113):
_content_139955154988272_113 = re_amp.sub('&', _content_139955154988272_113)
else:
_content_139955154988272_113 = _content_139955154988272_113.replace('&', '&')
if ('<' in _content_139955154988272_113):
_content_139955154988272_113 = _content_139955154988272_113.replace('<', '<')
if ('>' in _content_139955154988272_113):
_content_139955154988272_113 = _content_139955154988272_113.replace('>', '>')
if ('\x00' in _content_139955154988272_113):
_content_139955154988272_113 = _content_139955154988272_113.replace('\x00', '"')
_content_139955154988272 = ('%s%s' % ((_content_139955154988272 if (_content_139955154988272 is not None) else ''), (_content_139955154988272_113 if (_content_139955154988272_113 is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35899800 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35899800
__index_35780944 -= 1
if (__index_35780944 > 0):
append('\n ')
if (_backup_char_35801040 is _marker):
del econtext['char']
else:
econtext['char'] = _backup_char_35801040
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'
')
if (_backup_attrs_35900664 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35900664
__index_35781840 -= 1
if (__index_35781840 > 0):
append('\n ')
if (_backup_text_35782352 is _marker):
del econtext['text']
else:
econtext['text'] = _backup_text_35782352
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
# -> _condition
try:
try:
_ignore = getitem('text')
except (AttributeError, LookupError, TypeError, NameError, KeyError, ):
_condition = 0
else:
_condition = 1
_condition = not _condition
except:
rcontext.setdefault('__error__', []).append((u'not: exists: text', 6, 26, '', _sys.exc_info()[1], ))
raise
if _condition:
_content_139955154988272 = u'ok'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35899944 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35899944
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35876448 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35876448
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/002.xml 0000644 0001750 0000144 00000000075 11445675021 022225 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/003-content.pt 0000644 0001750 0000144 00000000772 12473423125 023523 0 ustar mborch users 0000000 0000000
1
2
3
')
_backup_default_36723816 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35933712
try:
_cache_35933712 = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 3, 22, '', _sys.exc_info()[1], ))
raise
# value= at 2244d10> -> _condition
_expression = _cache_35933712
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35933712
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_36723816 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36723816
append(u'
')
if (_backup_attrs_36722808 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36722808
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36725608 = get('attrs', _marker)
# name=None at 222b050> -> _value
_value = _static_35829776
econtext['attrs'] = _value
#
')
_backup_default_36723960 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35932816
try:
_cache_35932816 = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 4, 22, '', _sys.exc_info()[1], ))
raise
# value= at 2244850> -> _condition
_expression = _cache_35932816
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35932816
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_36723960 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36723960
append(u'
')
if (_backup_attrs_36725608 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36725608
_content_139955154988272 = u'1\n 2'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36728632 = get('attrs', _marker)
# name=None at 222b6d0> -> _value
_value = _static_35829264
econtext['attrs'] = _value
#
')
_backup_default_36726760 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35828624
try:
_cache_35828624 = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 5, 22, '', _sys.exc_info()[1], ))
raise
# value= at 222b190> -> _condition
_expression = _cache_35828624
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35828624
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_36726760 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36726760
append(u'
')
if (_backup_attrs_36728632 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36728632
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35918048 = get('attrs', _marker)
# name=None at 222b110> -> _value
_value = _static_35830160
econtext['attrs'] = _value
#
')
_backup_default_35918624 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35828432
try:
_cache_35828432 = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 6, 22, '', _sys.exc_info()[1], ))
raise
# value= at 222bad0> -> _condition
_expression = _cache_35828432
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35828432
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35918624 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35918624
append(u'
')
if (_backup_attrs_35918048 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35918048
_content_139955154988272 = u'3\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36622920 = get('attrs', _marker)
# name=None at 222b750> -> _value
_value = _static_35831056
econtext['attrs'] = _value
#
')
_backup_default_35917904 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35830544
try:
_cache_35830544 = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 7, 22, '', _sys.exc_info()[1], ))
raise
# value= at 222ba10> -> _condition
_expression = _cache_35830544
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
_content_139955154988272 = u'4'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
else:
_content = _cache_35830544
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35917904 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35917904
append(u'
')
if (_backup_attrs_36622920 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36622920
_content_139955154988272 = u'5\n 6'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36625656 = get('attrs', _marker)
# name=None at 22243d0> -> _value
_value = _static_35800464
econtext['attrs'] = _value
#
')
_backup_default_36625512 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35799696
try:
_cache_35799696 = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 8, 22, '', _sys.exc_info()[1], ))
raise
# value= at 2224fd0> -> _condition
_expression = _cache_35799696
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35799696
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_36625512 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36625512
append(u'
')
if (_backup_attrs_36625656 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36625656
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36629968 = get('attrs', _marker)
# name=None at 22f82d0> -> _value
_value = _static_36668752
econtext['attrs'] = _value
#
')
_backup_default_36638016 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35801168
try:
_cache_35801168 = 1
except:
rcontext.setdefault('__error__', []).append((u'1', 9, 22, '', _sys.exc_info()[1], ))
raise
# value= at 2224990> -> _condition
_expression = _cache_35801168
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35801168
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_36638016 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36638016
append(u'
')
if (_backup_attrs_36629968 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36629968
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36645704 = get('attrs', _marker)
# name=None at 22f8750> -> _value
_value = _static_36669328
econtext['attrs'] = _value
#
')
_backup_default_36644696 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_36667600
try:
_cache_36667600 = 1.0
except:
rcontext.setdefault('__error__', []).append((u'1.0', 10, 22, '', _sys.exc_info()[1], ))
raise
# value= at 22f8490> -> _condition
_expression = _cache_36667600
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_36667600
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_36644696 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36644696
append(u'
')
if (_backup_attrs_36645704 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36645704
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35900664 = get('attrs', _marker)
# name=None at 22f8890> -> _value
_value = _static_36669776
econtext['attrs'] = _value
#
')
_backup_default_35898288 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_36671120
try:
_cache_36671120 = True
except:
rcontext.setdefault('__error__', []).append((u'True', 11, 22, '', _sys.exc_info()[1], ))
raise
# value= at 22f8f50> -> _condition
_expression = _cache_36671120
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_36671120
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35898288 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35898288
append(u'
')
if (_backup_attrs_35900664 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35900664
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36634424 = get('attrs', _marker)
# name=None at 2238290> -> _value
_value = _static_35883024
econtext['attrs'] = _value
#
')
_backup_default_35900232 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_36668816
try:
_cache_36668816 = False
except:
rcontext.setdefault('__error__', []).append((u'False', 12, 22, '', _sys.exc_info()[1], ))
raise
# value= at 22f8c50> -> _condition
_expression = _cache_36668816
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_36668816
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35900232 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35900232
append(u'
')
if (_backup_attrs_36634424 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36634424
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35898792 = get('attrs', _marker)
# name=None at 221ff90> -> _value
_value = _static_35780752
econtext['attrs'] = _value
#
')
_backup_default_36721512 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35708496
try:
_cache_35708496 = 0
except:
rcontext.setdefault('__error__', []).append((u'0', 13, 22, '', _sys.exc_info()[1], ))
raise
# value= at 220dd50> -> _condition
_expression = _cache_35708496
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35708496
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_36721512 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36721512
append(u'
')
if (_backup_attrs_35898792 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35898792
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35898504 = get('attrs', _marker)
# name=None at 223a050> -> _value
_value = _static_35889296
econtext['attrs'] = _value
#
')
_backup_default_35897784 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35781136
try:
_cache_35781136 = None
except:
rcontext.setdefault('__error__', []).append((u'None', 14, 22, '', _sys.exc_info()[1], ))
raise
# value= at 221f490> -> _condition
_expression = _cache_35781136
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35781136
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35897784 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35897784
append(u'
')
if (_backup_attrs_35898504 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35898504
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_default_35899440 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35890192
try:
_cache_35890192 = getitem('content')
except:
rcontext.setdefault('__error__', []).append((u'content', 15, 22, '', _sys.exc_info()[1], ))
raise
# value= at 223a4d0> -> _condition
_expression = _cache_35890192
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
_backup_attrs_35901024 = get('attrs', _marker)
# name=None at 223a290> -> _value
_value = _static_35889872
econtext['attrs'] = _value
# ')
if (_backup_attrs_35901024 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35901024
else:
_content = _cache_35890192
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35899440 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35899440
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_36718280 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36718280
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_36729128 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36729128
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/003.xml 0000644 0001750 0000144 00000000075 11445675021 022226 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/004-attributes.pt 0000644 0001750 0000144 00000002350 12035273027 024230 0 ustar mborch users 0000000 0000000
Chameleon-2.24/src/chameleon/tests/inputs/004-attributes.pt.py 0000600 0001750 0000144 00000072306 11547550676 024676 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
pass
_static_36671184 = {u'a': u'1', u'c': u'3', u'b': u'2', }
_static_35828944 = {}
_static_35829584 = {u'class': u'None', }
_static_35889552 = {u'a': u'1', u'c': u'3', u'b': u'2', }
_static_35801168 = {u'a': u'1', u'c': u'3', u'b': u'2', }
_static_35707920 = {u'a': u'1', u'c': u'3', u'b': u'2', }
_static_35800848 = {u'a': u'1', u'c': u'3', u'b': u'2', }
_static_35830736 = {u'class': u"'hello'", }
_static_35890768 = {u'class': u'hello', }
_static_36668176 = {u'a': u'1', u'c': u'3', u'b': u'2', }
_static_35828624 = {}
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_39099424 = get('attrs', _marker)
# name=None at 222b850> -> _value
_value = _static_35828944
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36624936 = get('attrs', _marker)
# name=None at 222b250> -> _value
_value = _static_35828624
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36627376 = get('attrs', _marker)
# name=None at 222b990> -> _value
_value = _static_35830736
econtext['attrs'] = _value
# -> _attr_class
try:
_attr_class = 'hello'
except:
rcontext.setdefault('__error__', []).append((u"'hello'", 3, 32, '', _sys.exc_info()[1], ))
raise
if (_attr_class is None):
pass
else:
if (_attr_class is False):
_attr_class = None
else:
_tt = type(_attr_class)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_class = unicode(_attr_class)
else:
try:
if (_tt is str):
_attr_class = decode(_attr_class)
else:
if (_tt is not unicode):
try:
_attr_class = _attr_class.__html__
except:
_attr_class = convert(_attr_class)
else:
raise RuntimeError
except RuntimeError:
_attr_class = _attr_class()
else:
if ((_attr_class is not None) and (re_needs_escape(_attr_class) is not None)):
if ('&' in _attr_class):
if (';' in _attr_class):
_attr_class = re_amp.sub('&', _attr_class)
else:
_attr_class = _attr_class.replace('&', '&')
if ('<' in _attr_class):
_attr_class = _attr_class.replace('<', '<')
if ('>' in _attr_class):
_attr_class = _attr_class.replace('>', '>')
if ('"' in _attr_class):
_attr_class = _attr_class.replace('"', '"')
if (_attr_class is not None):
append((u' class="%s"' % _attr_class))
if (_backup_default_36629176 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36629176
append(u' />')
if (_backup_attrs_36627376 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36627376
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36724032 = get('attrs', _marker)
# name=None at 222bf90> -> _value
_value = _static_35829584
econtext['attrs'] = _value
# -> _attr_class
try:
_attr_class = None
except:
rcontext.setdefault('__error__', []).append((u'None', 4, 32, '', _sys.exc_info()[1], ))
raise
if (_attr_class is None):
pass
else:
if (_attr_class is False):
_attr_class = None
else:
_tt = type(_attr_class)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_class = unicode(_attr_class)
else:
try:
if (_tt is str):
_attr_class = decode(_attr_class)
else:
if (_tt is not unicode):
try:
_attr_class = _attr_class.__html__
except:
_attr_class = convert(_attr_class)
else:
raise RuntimeError
except RuntimeError:
_attr_class = _attr_class()
else:
if ((_attr_class is not None) and (re_needs_escape(_attr_class) is not None)):
if ('&' in _attr_class):
if (';' in _attr_class):
_attr_class = re_amp.sub('&', _attr_class)
else:
_attr_class = _attr_class.replace('&', '&')
if ('<' in _attr_class):
_attr_class = _attr_class.replace('<', '<')
if ('>' in _attr_class):
_attr_class = _attr_class.replace('>', '>')
if ('"' in _attr_class):
_attr_class = _attr_class.replace('"', '"')
if (_attr_class is not None):
append((u' class="%s"' % _attr_class))
if (_backup_default_36724464 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36724464
append(u' />')
if (_backup_attrs_36724032 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36724032
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36721872 = get('attrs', _marker)
# name=None at 2224090> -> _value
_value = _static_35800848
econtext['attrs'] = _value
# -> _attr_a
try:
_attr_a = None
except:
rcontext.setdefault('__error__', []).append((u'None', 5, 46, '', _sys.exc_info()[1], ))
raise
if (_attr_a is None):
pass
else:
if (_attr_a is False):
_attr_a = None
else:
_tt = type(_attr_a)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_a = unicode(_attr_a)
else:
try:
if (_tt is str):
_attr_a = decode(_attr_a)
else:
if (_tt is not unicode):
try:
_attr_a = _attr_a.__html__
except:
_attr_a = convert(_attr_a)
else:
raise RuntimeError
except RuntimeError:
_attr_a = _attr_a()
else:
if ((_attr_a is not None) and (re_needs_escape(_attr_a) is not None)):
if ('&' in _attr_a):
if (';' in _attr_a):
_attr_a = re_amp.sub('&', _attr_a)
else:
_attr_a = _attr_a.replace('&', '&')
if ('<' in _attr_a):
_attr_a = _attr_a.replace('<', '<')
if ('>' in _attr_a):
_attr_a = _attr_a.replace('>', '>')
if (u'"' in _attr_a):
_attr_a = _attr_a.replace(u'"', '"')
if (_attr_a is not None):
append((u' a="%s"' % _attr_a))
if (_backup_default_36721584 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36721584
_attr_b = u'2'
if (_attr_b is not None):
append((u' b="%s"' % _attr_b))
_attr_c = u'3'
if (_attr_c is not None):
append((u' c="%s"' % _attr_c))
append(u' />')
if (_backup_attrs_36721872 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36721872
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36722376 = get('attrs', _marker)
# name=None at 2224050> -> _value
_value = _static_35801168
econtext['attrs'] = _value
# -> _attr_b
try:
_attr_b = None
except:
rcontext.setdefault('__error__', []).append((u'None', 6, 46, '', _sys.exc_info()[1], ))
raise
if (_attr_b is None):
pass
else:
if (_attr_b is False):
_attr_b = None
else:
_tt = type(_attr_b)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_b = unicode(_attr_b)
else:
try:
if (_tt is str):
_attr_b = decode(_attr_b)
else:
if (_tt is not unicode):
try:
_attr_b = _attr_b.__html__
except:
_attr_b = convert(_attr_b)
else:
raise RuntimeError
except RuntimeError:
_attr_b = _attr_b()
else:
if ((_attr_b is not None) and (re_needs_escape(_attr_b) is not None)):
if ('&' in _attr_b):
if (';' in _attr_b):
_attr_b = re_amp.sub('&', _attr_b)
else:
_attr_b = _attr_b.replace('&', '&')
if ('<' in _attr_b):
_attr_b = _attr_b.replace('<', '<')
if ('>' in _attr_b):
_attr_b = _attr_b.replace('>', '>')
if (u'"' in _attr_b):
_attr_b = _attr_b.replace(u'"', '"')
if (_attr_b is not None):
append((u' b="%s"' % _attr_b))
if (_backup_default_36722520 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36722520
_attr_c = u'3'
if (_attr_c is not None):
append((u' c="%s"' % _attr_c))
append(u' />')
if (_backup_attrs_36722376 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36722376
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36723312 = get('attrs', _marker)
# name=None at 22f8650> -> _value
_value = _static_36668176
econtext['attrs'] = _value
# -> _attr_c
try:
_attr_c = None
except:
rcontext.setdefault('__error__', []).append((u'None', 7, 46, '', _sys.exc_info()[1], ))
raise
if (_attr_c is None):
pass
else:
if (_attr_c is False):
_attr_c = None
else:
_tt = type(_attr_c)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_c = unicode(_attr_c)
else:
try:
if (_tt is str):
_attr_c = decode(_attr_c)
else:
if (_tt is not unicode):
try:
_attr_c = _attr_c.__html__
except:
_attr_c = convert(_attr_c)
else:
raise RuntimeError
except RuntimeError:
_attr_c = _attr_c()
else:
if ((_attr_c is not None) and (re_needs_escape(_attr_c) is not None)):
if ('&' in _attr_c):
if (';' in _attr_c):
_attr_c = re_amp.sub('&', _attr_c)
else:
_attr_c = _attr_c.replace('&', '&')
if ('<' in _attr_c):
_attr_c = _attr_c.replace('<', '<')
if ('>' in _attr_c):
_attr_c = _attr_c.replace('>', '>')
if (u'"' in _attr_c):
_attr_c = _attr_c.replace(u'"', '"')
if (_attr_c is not None):
append((u' c="%s"' % _attr_c))
if (_backup_default_36723240 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36723240
append(u' />')
if (_backup_attrs_36723312 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36723312
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36724248 = get('attrs', _marker)
# name=None at 22f8f90> -> _value
_value = _static_36671184
econtext['attrs'] = _value
# -> _attr_b
try:
_attr_b = None
except:
rcontext.setdefault('__error__', []).append((u'None', 8, 46, '', _sys.exc_info()[1], ))
raise
if (_attr_b is None):
pass
else:
if (_attr_b is False):
_attr_b = None
else:
_tt = type(_attr_b)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_b = unicode(_attr_b)
else:
try:
if (_tt is str):
_attr_b = decode(_attr_b)
else:
if (_tt is not unicode):
try:
_attr_b = _attr_b.__html__
except:
_attr_b = convert(_attr_b)
else:
raise RuntimeError
except RuntimeError:
_attr_b = _attr_b()
else:
if ((_attr_b is not None) and (re_needs_escape(_attr_b) is not None)):
if ('&' in _attr_b):
if (';' in _attr_b):
_attr_b = re_amp.sub('&', _attr_b)
else:
_attr_b = _attr_b.replace('&', '&')
if ('<' in _attr_b):
_attr_b = _attr_b.replace('<', '<')
if ('>' in _attr_b):
_attr_b = _attr_b.replace('>', '>')
if (u'"' in _attr_b):
_attr_b = _attr_b.replace(u'"', '"')
if (_attr_b is not None):
append((u' b="%s"' % _attr_b))
if (_backup_default_36723384 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36723384
_backup_default_36724680 = get('default', _marker)
_value = u'3'
econtext['default'] = _value
# -> _attr_c
try:
_attr_c = None
except:
rcontext.setdefault('__error__', []).append((u'None', 8, 53, '', _sys.exc_info()[1], ))
raise
if (_attr_c is None):
pass
else:
if (_attr_c is False):
_attr_c = None
else:
_tt = type(_attr_c)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_c = unicode(_attr_c)
else:
try:
if (_tt is str):
_attr_c = decode(_attr_c)
else:
if (_tt is not unicode):
try:
_attr_c = _attr_c.__html__
except:
_attr_c = convert(_attr_c)
else:
raise RuntimeError
except RuntimeError:
_attr_c = _attr_c()
else:
if ((_attr_c is not None) and (re_needs_escape(_attr_c) is not None)):
if ('&' in _attr_c):
if (';' in _attr_c):
_attr_c = re_amp.sub('&', _attr_c)
else:
_attr_c = _attr_c.replace('&', '&')
if ('<' in _attr_c):
_attr_c = _attr_c.replace('<', '<')
if ('>' in _attr_c):
_attr_c = _attr_c.replace('>', '>')
if (u'"' in _attr_c):
_attr_c = _attr_c.replace(u'"', '"')
if (_attr_c is not None):
append((u' c="%s"' % _attr_c))
if (_backup_default_36724680 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36724680
append(u' />')
if (_backup_attrs_36724248 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36724248
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38641744 = get('attrs', _marker)
# name=None at 220ddd0> -> _value
_value = _static_35707920
econtext['attrs'] = _value
# -> _attr_b
try:
_attr_b = u';'
except:
rcontext.setdefault('__error__', []).append((u'string:;', 9, 46, '', _sys.exc_info()[1], ))
raise
if (_attr_b is None):
pass
else:
if (_attr_b is False):
_attr_b = None
else:
_tt = type(_attr_b)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_b = unicode(_attr_b)
else:
try:
if (_tt is str):
_attr_b = decode(_attr_b)
else:
if (_tt is not unicode):
try:
_attr_b = _attr_b.__html__
except:
_attr_b = convert(_attr_b)
else:
raise RuntimeError
except RuntimeError:
_attr_b = _attr_b()
else:
if ((_attr_b is not None) and (re_needs_escape(_attr_b) is not None)):
if ('&' in _attr_b):
if (';' in _attr_b):
_attr_b = re_amp.sub('&', _attr_b)
else:
_attr_b = _attr_b.replace('&', '&')
if ('<' in _attr_b):
_attr_b = _attr_b.replace('<', '<')
if ('>' in _attr_b):
_attr_b = _attr_b.replace('>', '>')
if (u'"' in _attr_b):
_attr_b = _attr_b.replace(u'"', '"')
if (_attr_b is not None):
append((u' b="%s"' % _attr_b))
if (_backup_default_38642032 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_38642032
_attr_c = u'3'
if (_attr_c is not None):
append((u' c="%s"' % _attr_c))
append(u' />')
if (_backup_attrs_38641744 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38641744
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36721224 = get('attrs', _marker)
# name=None at 223a1d0> -> _value
_value = _static_35889552
econtext['attrs'] = _value
# -> _attr_b
try:
_attr_b = u'&'
except:
rcontext.setdefault('__error__', []).append((u'string:&', 10, 46, '', _sys.exc_info()[1], ))
raise
if (_attr_b is None):
pass
else:
if (_attr_b is False):
_attr_b = None
else:
_tt = type(_attr_b)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_b = unicode(_attr_b)
else:
try:
if (_tt is str):
_attr_b = decode(_attr_b)
else:
if (_tt is not unicode):
try:
_attr_b = _attr_b.__html__
except:
_attr_b = convert(_attr_b)
else:
raise RuntimeError
except RuntimeError:
_attr_b = _attr_b()
else:
if ((_attr_b is not None) and (re_needs_escape(_attr_b) is not None)):
if ('&' in _attr_b):
if (';' in _attr_b):
_attr_b = re_amp.sub('&', _attr_b)
else:
_attr_b = _attr_b.replace('&', '&')
if ('<' in _attr_b):
_attr_b = _attr_b.replace('<', '<')
if ('>' in _attr_b):
_attr_b = _attr_b.replace('>', '>')
if (u'"' in _attr_b):
_attr_b = _attr_b.replace(u'"', '"')
if (_attr_b is not None):
append((u' b="%s"' % _attr_b))
if (_backup_default_36721080 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36721080
_attr_c = u'3'
if (_attr_c is not None):
append((u' c="%s"' % _attr_c))
append(u' />')
if (_backup_attrs_36721224 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36721224
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38642176 = get('attrs', _marker)
# name=None at 223a250> -> _value
_value = _static_35890768
econtext['attrs'] = _value
# -> _attr_class
try:
_attr_class = 'goodbye'
except:
rcontext.setdefault('__error__', []).append((u"'goodbye'", 11, 46, '', _sys.exc_info()[1], ))
raise
if (_attr_class is None):
pass
else:
if (_attr_class is False):
_attr_class = None
else:
_tt = type(_attr_class)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_class = unicode(_attr_class)
else:
try:
if (_tt is str):
_attr_class = decode(_attr_class)
else:
if (_tt is not unicode):
try:
_attr_class = _attr_class.__html__
except:
_attr_class = convert(_attr_class)
else:
raise RuntimeError
except RuntimeError:
_attr_class = _attr_class()
else:
if ((_attr_class is not None) and (re_needs_escape(_attr_class) is not None)):
if ('&' in _attr_class):
if (';' in _attr_class):
_attr_class = re_amp.sub('&', _attr_class)
else:
_attr_class = _attr_class.replace('&', '&')
if ('<' in _attr_class):
_attr_class = _attr_class.replace('<', '<')
if ('>' in _attr_class):
_attr_class = _attr_class.replace('>', '>')
if (u'"' in _attr_class):
_attr_class = _attr_class.replace(u'"', '"')
if (_attr_class is not None):
append((u' class="%s"' % _attr_class))
if (_backup_default_38642104 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_38642104
append(u' />')
if (_backup_attrs_38642176 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38642176
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_36624936 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36624936
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_39099424 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39099424
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/004.xml 0000644 0001750 0000144 00000000146 11445675021 022226 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/005-default.pt 0000644 0001750 0000144 00000000542 11631410432 023462 0 ustar mborch users 0000000 0000000
DefaultDefaultDefault${'Computed default'}
Chameleon-2.24/src/chameleon/tests/inputs/005-default.pt.py 0000600 0001750 0000144 00000043237 11547550676 024136 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
from chameleon.utils import Placeholder as _Placeholder
import sys as _sys
pass
_static_35707984 = {}
_static_35803088 = {}
_static_36671184 = {}
_static_35779600 = {}
_static_36670416 = {u'class': u'default', }
_static_36668432 = {u'class': u'default', }
_static_35802384 = {}
_marker_default = _Placeholder()
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_38643400 = get('attrs', _marker)
# name=None at 2224a10> -> _value
_value = _static_35802384
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38494936 = get('attrs', _marker)
# name=None at 2224290> -> _value
_value = _static_35803088
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38642320 = get('attrs', _marker)
# name=None at 2224dd0> -> _value
_value = _static_36668432
econtext['attrs'] = _value
# -> _attr_class
try:
_attr_class = getitem('default')
except:
rcontext.setdefault('__error__', []).append((u'default', 3, 47, '', _sys.exc_info()[1], ))
raise
if (_attr_class is None):
pass
else:
if (_attr_class is False):
_attr_class = None
else:
_tt = type(_attr_class)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_class = unicode(_attr_class)
else:
try:
if (_tt is str):
_attr_class = decode(_attr_class)
else:
if (_tt is not unicode):
try:
_attr_class = _attr_class.__html__
except:
_attr_class = convert(_attr_class)
else:
raise RuntimeError
except RuntimeError:
_attr_class = _attr_class()
else:
if ((_attr_class is not None) and (re_needs_escape(_attr_class) is not None)):
if ('&' in _attr_class):
if (';' in _attr_class):
_attr_class = re_amp.sub('&', _attr_class)
else:
_attr_class = _attr_class.replace('&', '&')
if ('<' in _attr_class):
_attr_class = _attr_class.replace('<', '<')
if ('>' in _attr_class):
_attr_class = _attr_class.replace('>', '>')
if (u'"' in _attr_class):
_attr_class = _attr_class.replace(u'"', '"')
if (_attr_class is not None):
append((u' class="%s"' % _attr_class))
if (_backup_default_38494504 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_38494504
append(u' />')
if (_backup_attrs_38642320 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38642320
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38495800 = get('attrs', _marker)
# name=None at 22f8810> -> _value
_value = _static_36670416
econtext['attrs'] = _value
# -> _attr_class
try:
_attr_class = getitem('default')
except:
rcontext.setdefault('__error__', []).append((u'default', 4, 31, '', _sys.exc_info()[1], ))
raise
if (_attr_class is None):
pass
else:
if (_attr_class is False):
_attr_class = None
else:
_tt = type(_attr_class)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_class = unicode(_attr_class)
else:
try:
if (_tt is str):
_attr_class = decode(_attr_class)
else:
if (_tt is not unicode):
try:
_attr_class = _attr_class.__html__
except:
_attr_class = convert(_attr_class)
else:
raise RuntimeError
except RuntimeError:
_attr_class = _attr_class()
else:
if ((_attr_class is not None) and (re_needs_escape(_attr_class) is not None)):
if ('&' in _attr_class):
if (';' in _attr_class):
_attr_class = re_amp.sub('&', _attr_class)
else:
_attr_class = _attr_class.replace('&', '&')
if ('<' in _attr_class):
_attr_class = _attr_class.replace('<', '<')
if ('>' in _attr_class):
_attr_class = _attr_class.replace('>', '>')
if ('"' in _attr_class):
_attr_class = _attr_class.replace('"', '"')
if (_attr_class is not None):
append((u' class="%s"' % _attr_class))
if (_backup_default_38495728 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_38495728
append(u' />')
if (_backup_attrs_38495800 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38495800
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38571832 = get('attrs', _marker)
# name=None at 22f8f90> -> _value
_value = _static_36671184
econtext['attrs'] = _value
# ')
_backup_default_37019016 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_36670032
try:
_cache_36670032 = getitem('default')
except:
rcontext.setdefault('__error__', []).append((u'default', 5, 23, '', _sys.exc_info()[1], ))
raise
# value= at 22f89d0> -> _condition
_expression = _cache_36670032
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
_content_139955154988272 = u'Default'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
else:
_content = _cache_36670032
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_37019016 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_37019016
append(u'')
if (_backup_attrs_38571832 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38571832
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38604240 = get('attrs', _marker)
# name=None at 22f8e90> -> _value
_value = _static_35707984
econtext['attrs'] = _value
# ')
_backup_default_38601360 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_36670672
try:
_cache_36670672 = getitem('default')
except:
rcontext.setdefault('__error__', []).append((u'default', 6, 23, '', _sys.exc_info()[1], ))
raise
# value= at 22f8590> -> _condition
_expression = _cache_36670672
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38632624 = get('attrs', _marker)
# name=None at 221f490> -> _value
_value = _static_35779600
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'Computed default'
except:
rcontext.setdefault('__error__', []).append((u"'Computed default'", 7, 12, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38632624 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38632624
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
else:
_content = _cache_36670672
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_38601360 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_38601360
append(u'')
if (_backup_attrs_38604240 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38604240
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38494936 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38494936
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38643400 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38643400
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/005.xml 0000644 0001750 0000144 00000000150 11445675021 022222 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/006-attribute-interpolation.pt 0000644 0001750 0000144 00000000617 11637044266 026750 0 ustar mborch users 0000000 0000000
Chameleon-2.24/src/chameleon/tests/inputs/006-attribute-interpolation.pt.py 0000600 0001750 0000144 00000024156 11547550676 027402 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
pass
_static_36670736 = {u'src': u"${'#'}", u'alt': u'copyright (c) ${2010}', }
_static_36669072 = {u'class': u'ltr', }
_static_36669648 = {u'src': u'${None}', }
_static_36667984 = {}
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_36723672 = get('attrs', _marker)
# name=None at 22f8550> -> _value
_value = _static_36667984
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36648360 = get('attrs', _marker)
# name=None at 22f80d0> -> _value
_value = _static_36669072
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36648216 = get('attrs', _marker)
# name=None at 22f8d90> -> _value
_value = _static_36670736
econtext['attrs'] = _value
# -> _attr_src
# -> _attr_src
try:
_attr_src = '#'
except:
rcontext.setdefault('__error__', []).append((u"'#'", 3, 16, '', _sys.exc_info()[1], ))
raise
_attr_src = _attr_src
if (_attr_src is None):
pass
else:
if (_attr_src is False):
_attr_src = None
else:
_tt = type(_attr_src)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_src = unicode(_attr_src)
else:
try:
if (_tt is str):
_attr_src = decode(_attr_src)
else:
if (_tt is not unicode):
try:
_attr_src = _attr_src.__html__
except:
_attr_src = convert(_attr_src)
else:
raise RuntimeError
except RuntimeError:
_attr_src = _attr_src()
else:
if ((_attr_src is not None) and (re_needs_escape(_attr_src) is not None)):
if ('&' in _attr_src):
if (';' in _attr_src):
_attr_src = re_amp.sub('&', _attr_src)
else:
_attr_src = _attr_src.replace('&', '&')
if ('<' in _attr_src):
_attr_src = _attr_src.replace('<', '<')
if ('>' in _attr_src):
_attr_src = _attr_src.replace('>', '>')
if (u'"' in _attr_src):
_attr_src = _attr_src.replace(u'"', '"')
if (_attr_src is not None):
append((u' src="%s"' % _attr_src))
if (_backup_default_36648432 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36648432
_backup_default_39035896 = get('default', _marker)
_value = u'copyright (c) ${2010}'
econtext['default'] = _value
# -> _attr_alt
# -> _attr_alt
try:
_attr_alt = 2010
except:
rcontext.setdefault('__error__', []).append((u'2010', 3, 43, '', _sys.exc_info()[1], ))
raise
_attr_alt = ('%s%s' % ((u'copyright (c) ' if (u'copyright (c) ' is not None) else ''), (_attr_alt if (_attr_alt is not None) else ''), ))
if (_attr_alt is None):
pass
else:
if (_attr_alt is False):
_attr_alt = None
else:
_tt = type(_attr_alt)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_alt = unicode(_attr_alt)
else:
try:
if (_tt is str):
_attr_alt = decode(_attr_alt)
else:
if (_tt is not unicode):
try:
_attr_alt = _attr_alt.__html__
except:
_attr_alt = convert(_attr_alt)
else:
raise RuntimeError
except RuntimeError:
_attr_alt = _attr_alt()
else:
if ((_attr_alt is not None) and (re_needs_escape(_attr_alt) is not None)):
if ('&' in _attr_alt):
if (';' in _attr_alt):
_attr_alt = re_amp.sub('&', _attr_alt)
else:
_attr_alt = _attr_alt.replace('&', '&')
if ('<' in _attr_alt):
_attr_alt = _attr_alt.replace('<', '<')
if ('>' in _attr_alt):
_attr_alt = _attr_alt.replace('>', '>')
if (u'"' in _attr_alt):
_attr_alt = _attr_alt.replace(u'"', '"')
if (_attr_alt is not None):
append((u' alt="%s"' % _attr_alt))
if (_backup_default_39035896 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_39035896
append(u' />')
if (_backup_attrs_36648216 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36648216
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36650448 = get('attrs', _marker)
# name=None at 22f8590> -> _value
_value = _static_36669648
econtext['attrs'] = _value
# -> _attr_src
# -> _attr_src
try:
_attr_src = None
except:
rcontext.setdefault('__error__', []).append((u'None', 4, 16, '', _sys.exc_info()[1], ))
raise
_attr_src = _attr_src
if (_attr_src is None):
pass
else:
if (_attr_src is False):
_attr_src = None
else:
_tt = type(_attr_src)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_src = unicode(_attr_src)
else:
try:
if (_tt is str):
_attr_src = decode(_attr_src)
else:
if (_tt is not unicode):
try:
_attr_src = _attr_src.__html__
except:
_attr_src = convert(_attr_src)
else:
raise RuntimeError
except RuntimeError:
_attr_src = _attr_src()
else:
if ((_attr_src is not None) and (re_needs_escape(_attr_src) is not None)):
if ('&' in _attr_src):
if (';' in _attr_src):
_attr_src = re_amp.sub('&', _attr_src)
else:
_attr_src = _attr_src.replace('&', '&')
if ('<' in _attr_src):
_attr_src = _attr_src.replace('<', '<')
if ('>' in _attr_src):
_attr_src = _attr_src.replace('>', '>')
if (u'"' in _attr_src):
_attr_src = _attr_src.replace(u'"', '"')
if (_attr_src is not None):
append((u' src="%s"' % _attr_src))
if (_backup_default_36650232 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36650232
append(u' />')
if (_backup_attrs_36650448 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36650448
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_36648360 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36648360
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_36723672 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36723672
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/006.xml 0000644 0001750 0000144 00000000146 11445675021 022230 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/007-content-interpolation.pt 0000644 0001750 0000144 00000000500 12034551641 026377 0 ustar mborch users 0000000 0000000
${'Hello world!'}
${literal}
${structure: literal.s}
${"%stype 'str'%s" % (chr(60), chr(62))}
&&
${None}
${None or
'Hello world'}
$leftalone
${None}
${1 < 2 and 'Hello world' or None}
${} is ignored.
Chameleon-2.24/src/chameleon/tests/inputs/007-content-interpolation.pt.py 0000600 0001750 0000144 00000030707 11547550676 027051 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
pass
_static_36670096 = {}
_static_35829392 = {}
_static_35708624 = {}
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_37246736 = get('attrs', _marker)
# name=None at 221fb90> -> _value
_value = _static_35708624
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38435512 = get('attrs', _marker)
# name=None at 222bb50> -> _value
_value = _static_35829392
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 3, 6, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
# -> _content_139955154988272_42
try:
_content_139955154988272_42 = getitem('literal')
except:
rcontext.setdefault('__error__', []).append((u'literal', 4, 6, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272_42 is None):
pass
else:
if (_content_139955154988272_42 is False):
_content_139955154988272_42 = None
else:
_tt = type(_content_139955154988272_42)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272_42 = unicode(_content_139955154988272_42)
else:
try:
if (_tt is str):
_content_139955154988272_42 = decode(_content_139955154988272_42)
else:
if (_tt is not unicode):
try:
_content_139955154988272_42 = _content_139955154988272_42.__html__
except:
_content_139955154988272_42 = convert(_content_139955154988272_42)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272_42 = _content_139955154988272_42()
else:
if ((_content_139955154988272_42 is not None) and (re_needs_escape(_content_139955154988272_42) is not None)):
if ('&' in _content_139955154988272_42):
if (';' in _content_139955154988272_42):
_content_139955154988272_42 = re_amp.sub('&', _content_139955154988272_42)
else:
_content_139955154988272_42 = _content_139955154988272_42.replace('&', '&')
if ('<' in _content_139955154988272_42):
_content_139955154988272_42 = _content_139955154988272_42.replace('<', '<')
if ('>' in _content_139955154988272_42):
_content_139955154988272_42 = _content_139955154988272_42.replace('>', '>')
if ('\x00' in _content_139955154988272_42):
_content_139955154988272_42 = _content_139955154988272_42.replace('\x00', '"')
# -> _content_139955154988272_57
try:
_content_139955154988272_57 = None
except:
rcontext.setdefault('__error__', []).append((u'None', 5, 6, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272_57 is None):
pass
else:
if (_content_139955154988272_57 is False):
_content_139955154988272_57 = None
else:
_tt = type(_content_139955154988272_57)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272_57 = unicode(_content_139955154988272_57)
else:
try:
if (_tt is str):
_content_139955154988272_57 = decode(_content_139955154988272_57)
else:
if (_tt is not unicode):
try:
_content_139955154988272_57 = _content_139955154988272_57.__html__
except:
_content_139955154988272_57 = convert(_content_139955154988272_57)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272_57 = _content_139955154988272_57()
else:
if ((_content_139955154988272_57 is not None) and (re_needs_escape(_content_139955154988272_57) is not None)):
if ('&' in _content_139955154988272_57):
if (';' in _content_139955154988272_57):
_content_139955154988272_57 = re_amp.sub('&', _content_139955154988272_57)
else:
_content_139955154988272_57 = _content_139955154988272_57.replace('&', '&')
if ('<' in _content_139955154988272_57):
_content_139955154988272_57 = _content_139955154988272_57.replace('<', '<')
if ('>' in _content_139955154988272_57):
_content_139955154988272_57 = _content_139955154988272_57.replace('>', '>')
if ('\x00' in _content_139955154988272_57):
_content_139955154988272_57 = _content_139955154988272_57.replace('\x00', '"')
_content_139955154988272 = ('%s%s%s%s%s%s%s' % ((u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272_42 if (_content_139955154988272_42 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272_57 if (_content_139955154988272_57 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38446936 = get('attrs', _marker)
# name=None at 22f8810> -> _value
_value = _static_36670096
econtext['attrs'] = _value
#
')
# -> _content_139955154988272
try:
_content_139955154988272 = None
except:
rcontext.setdefault('__error__', []).append((u'None', 6, 11, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'
')
if (_backup_attrs_38446936 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38446936
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38435512 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38435512
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_37246736 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37246736
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/007.xml 0000644 0001750 0000144 00000000101 11445675021 022220 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/008-builtins.pt 0000644 0001750 0000144 00000000352 12034532566 023704 0 ustar mborch users 0000000 0000000
${attrs}
${nothing}
${attrs['class']}
${nothing}
Chameleon-2.24/src/chameleon/tests/inputs/008-builtins.pt.py 0000600 0001750 0000144 00000023577 11547550676 024353 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
pass
_static_35829392 = {}
_static_36669456 = {}
_static_36669712 = {u'class': u'static', }
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_35754928 = get('attrs', _marker)
# name=None at 222bb50> -> _value
_value = _static_35829392
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35872992 = get('attrs', _marker)
# name=None at 22f8210> -> _value
_value = _static_36669456
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = getitem('nothing')
except:
rcontext.setdefault('__error__', []).append((u'nothing', 3, 6, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = ('%s%s%s' % ((u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35755576 = get('attrs', _marker)
# name=None at 22f8f10> -> _value
_value = _static_36669712
econtext['attrs'] = _value
#
-> _attr_class
try:
_attr_class = u'dynamic'
except:
rcontext.setdefault('__error__', []).append((u'string:dynamic', 4, 31, '', _sys.exc_info()[1], ))
raise
if (_attr_class is None):
pass
else:
if (_attr_class is False):
_attr_class = None
else:
_tt = type(_attr_class)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_class = unicode(_attr_class)
else:
try:
if (_tt is str):
_attr_class = decode(_attr_class)
else:
if (_tt is not unicode):
try:
_attr_class = _attr_class.__html__
except:
_attr_class = convert(_attr_class)
else:
raise RuntimeError
except RuntimeError:
_attr_class = _attr_class()
else:
if ((_attr_class is not None) and (re_needs_escape(_attr_class) is not None)):
if ('&' in _attr_class):
if (';' in _attr_class):
_attr_class = re_amp.sub('&', _attr_class)
else:
_attr_class = _attr_class.replace('&', '&')
if ('<' in _attr_class):
_attr_class = _attr_class.replace('<', '<')
if ('>' in _attr_class):
_attr_class = _attr_class.replace('>', '>')
if (u'"' in _attr_class):
_attr_class = _attr_class.replace(u'"', '"')
if (_attr_class is not None):
append((u' class="%s"' % _attr_class))
if (_backup_default_35755720 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35755720
append(u'>')
# -> _content_139955154988272
try:
_content_139955154988272 = getitem('attrs')['class']
except:
rcontext.setdefault('__error__', []).append((u"attrs['class']", 5, 8, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = ('%s%s%s' % ((u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'
')
if (_backup_attrs_35755576 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35755576
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35872992 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35872992
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35754928 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35754928
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/008.xml 0000644 0001750 0000144 00000000125 11445675021 022227 0 ustar mborch users 0000000 0000000
]>
&<>"'
Chameleon-2.24/src/chameleon/tests/inputs/009-literals.pt 0000644 0001750 0000144 00000000061 11445675021 023667 0 ustar mborch users 0000000 0000000
${literal}
Chameleon-2.24/src/chameleon/tests/inputs/009-literals.pt.py 0000600 0001750 0000144 00000010723 11547550676 024327 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
pass
_static_36667792 = {}
_static_36669264 = {}
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_37031304 = get('attrs', _marker)
# name=None at 22f8a90> -> _value
_value = _static_36669264
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_37004352 = get('attrs', _marker)
# name=None at 22f8bd0> -> _value
_value = _static_36667792
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = getitem('literal')
except:
rcontext.setdefault('__error__', []).append((u'literal', 3, 6, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = ('%s%s%s' % ((u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_37004352 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37004352
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_37031304 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37031304
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/009.xml 0000644 0001750 0000144 00000000102 11445675021 022223 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/010-structure.pt 0000644 0001750 0000144 00000000475 11614001220 024067 0 ustar mborch users 0000000 0000000
Chameleon-2.24/src/chameleon/tests/inputs/010-structure.pt.py 0000600 0001750 0000144 00000034263 11547550676 024545 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
from chameleon.utils import Placeholder as _Placeholder
import sys as _sys
pass
_static_38579792 = {}
_static_38552272 = {}
_static_35801168 = {}
_static_38555600 = {}
_static_35799376 = {}
_static_38553168 = {}
_static_38553552 = {}
_marker_default = _Placeholder()
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_39070032 = get('attrs', _marker)
# name=None at 223a290> -> _value
_value = _static_38553168
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_39067944 = get('attrs', _marker)
# name=None at 24c4f90> -> _value
_value = _static_38555600
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_39069312 = get('attrs', _marker)
# name=None at 24c4b90> -> _value
_value = _static_38553552
econtext['attrs'] = _value
#
')
_backup_default_39069744 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38555024
try:
_cache_38555024 = u'1 < 2'
except:
rcontext.setdefault('__error__', []).append((u'string:1 < 2', 3, 27, '', _sys.exc_info()[1], ))
raise
# value= at 24c4950> -> _condition
_expression = _cache_38555024
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_38555024
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_39069744 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_39069744
append(u'
')
if (_backup_attrs_39069312 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39069312
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_39070608 = get('attrs', _marker)
# name=None at 24c4290> -> _value
_value = _static_38552272
econtext['attrs'] = _value
#
')
_backup_default_39044592 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38552400
try:
_cache_38552400 = u'2 < 3'
except:
rcontext.setdefault('__error__', []).append((u'string:2 < 3', 4, 32, '', _sys.exc_info()[1], ))
raise
# value= at 24c4250> -> _condition
_expression = _cache_38552400
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_38552400
if (_content is not None):
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = str(_content)
else:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except AttributeError:
_content = convert(_content)
else:
_content = _content()
if (_content is not None):
append(_content)
if (_backup_default_39044592 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_39044592
append(u'
')
if (_backup_attrs_39070608 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39070608
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_37107256 = get('attrs', _marker)
# name=None at 22241d0> -> _value
_value = _static_35801168
econtext['attrs'] = _value
#
')
_backup_default_35897424 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38551888
try:
_cache_38551888 = '<'
_cache_38551888 = ('%s%s%s' % ((u'3 ' if (u'3 ' is not None) else ''), (_cache_38551888 if (_cache_38551888 is not None) else ''), (u' 4' if (u' 4' is not None) else ''), ))
except:
rcontext.setdefault('__error__', []).append((u"string:3 ${'<'} 4", 5, 32, '', _sys.exc_info()[1], ))
raise
# value= at 24c40d0> -> _condition
_expression = _cache_38551888
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_38551888
if (_content is not None):
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = str(_content)
else:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except AttributeError:
_content = convert(_content)
else:
_content = _content()
if (_content is not None):
append(_content)
if (_backup_default_35897424 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35897424
append(u'
')
if (_backup_attrs_37107256 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37107256
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_39055304 = get('attrs', _marker)
# name=None at 2224dd0> -> _value
_value = _static_35799376
econtext['attrs'] = _value
#
')
_backup_default_39086560 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35801680
try:
_cache_35801680 = ('%d < %d' % (4, 5, ))
except:
rcontext.setdefault('__error__', []).append((u"'%d < %d' % (4, 5)", 6, 32, '', _sys.exc_info()[1], ))
raise
# value= at 2224ed0> -> _condition
_expression = _cache_35801680
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35801680
if (_content is not None):
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = str(_content)
else:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except AttributeError:
_content = convert(_content)
else:
_content = _content()
if (_content is not None):
append(_content)
if (_backup_default_39086560 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_39086560
append(u'
')
if (_backup_attrs_39055304 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39055304
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_default_39076928 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38578128
try:
_cache_38578128 = getitem('content')
except:
rcontext.setdefault('__error__', []).append((u'content', 7, 32, '', _sys.exc_info()[1], ))
raise
# value= at 24ca610> -> _condition
_expression = _cache_38578128
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
_backup_attrs_39051992 = get('attrs', _marker)
# name=None at 24cac10> -> _value
_value = _static_38579792
econtext['attrs'] = _value
# ')
if (_backup_attrs_39051992 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39051992
else:
_content = _cache_38578128
if (_content is not None):
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = str(_content)
else:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except AttributeError:
_content = convert(_content)
else:
_content = _content()
if (_content is not None):
append(_content)
if (_backup_default_39076928 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_39076928
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_39067944 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39067944
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_39070032 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39070032
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/010.xml 0000644 0001750 0000144 00000000147 11445675021 022224 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/011-messages.pt 0000644 0001750 0000144 00000000353 11445675021 023654 0 ustar mborch users 0000000 0000000
${message}
Chameleon-2.24/src/chameleon/tests/inputs/011-messages.pt-en.py 0000600 0001750 0000144 00000036702 11547550676 024715 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
from chameleon.utils import Placeholder as _Placeholder
import sys as _sys
pass
_static_38588816 = {}
_static_35799696 = {}
_static_38462608 = {}
_static_38590736 = {}
_static_38589968 = {}
_static_35802320 = {}
_marker_default = _Placeholder()
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_35342528 = get('attrs', _marker)
# name=None at 24cd410> -> _value
_value = _static_38590736
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35343752 = get('attrs', _marker)
# name=None at 24cd8d0> -> _value
_value = _static_38589968
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35343680 = get('attrs', _marker)
# name=None at 24cdfd0> -> _value
_value = _static_38588816
econtext['attrs'] = _value
#
')
_backup_default_35343392 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38588624
try:
_cache_38588624 = getitem('message')
except:
rcontext.setdefault('__error__', []).append((u'message', 3, 27, '', _sys.exc_info()[1], ))
raise
# value= at 24cd490> -> _condition
_expression = _cache_38588624
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_38588624
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35343392 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35343392
append(u'
')
if (_backup_attrs_35343680 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35343680
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35343176 = get('attrs', _marker)
# name=None at 24ae810> -> _value
_value = _static_38462608
econtext['attrs'] = _value
#
')
_backup_default_35344112 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38461520
try:
_cache_38461520 = getitem('message')
except:
rcontext.setdefault('__error__', []).append((u'message', 4, 32, '', _sys.exc_info()[1], ))
raise
# value= at 24ae210> -> _condition
_expression = _cache_38461520
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_38461520
if (_content is not None):
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = str(_content)
else:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except AttributeError:
_content = convert(_content)
else:
_content = _content()
if (_content is not None):
append(_content)
if (_backup_default_35344112 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35344112
append(u'
')
if (_backup_attrs_35343176 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35343176
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38452616 = get('attrs', _marker)
# name=None at 2224050> -> _value
_value = _static_35799696
econtext['attrs'] = _value
#
')
_backup_default_35340656 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38464720
try:
_cache_38464720 = getitem('message')
_cache_38464720 = _cache_38464720
except:
rcontext.setdefault('__error__', []).append((u'string:${message}', 5, 27, '', _sys.exc_info()[1], ))
raise
# value= at 24ae990> -> _condition
_expression = _cache_38464720
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_38464720
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35340656 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35340656
append(u'
')
if (_backup_attrs_38452616 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38452616
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_37030800 = get('attrs', _marker)
# name=None at 22244d0> -> _value
_value = _static_35802320
econtext['attrs'] = _value
#
')
_backup_default_35875584 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35802448
try:
_cache_35802448 = getitem('message')
_cache_35802448 = _cache_35802448
except:
rcontext.setdefault('__error__', []).append((u'string:${message}', 6, 32, '', _sys.exc_info()[1], ))
raise
# value= at 2224090> -> _condition
_expression = _cache_35802448
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35802448
if (_content is not None):
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = str(_content)
else:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except AttributeError:
_content = convert(_content)
else:
_content = _content()
if (_content is not None):
append(_content)
if (_backup_default_35875584 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35875584
append(u'
')
if (_backup_attrs_37030800 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37030800
# -> _content_139955154988272
try:
_content_139955154988272 = getitem('message')
except:
rcontext.setdefault('__error__', []).append((u'message', 7, 6, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = ('%s%s%s' % ((u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35343752 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35343752
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35342528 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35342528
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/011-messages.pt.py 0000600 0001750 0000144 00000036702 11547550676 024315 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
from chameleon.utils import Placeholder as _Placeholder
import sys as _sys
pass
_static_38464336 = {}
_static_38462992 = {}
_static_35800464 = {}
_static_38589648 = {}
_static_35799184 = {}
_static_38591312 = {}
_marker_default = _Placeholder()
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_38435944 = get('attrs', _marker)
# name=None at 2224e10> -> _value
_value = _static_35800464
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35756224 = get('attrs', _marker)
# name=None at 22243d0> -> _value
_value = _static_35799184
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35757952 = get('attrs', _marker)
# name=None at 24cde50> -> _value
_value = _static_38591312
econtext['attrs'] = _value
#
')
_backup_default_35754928 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_35800272
try:
_cache_35800272 = getitem('message')
except:
rcontext.setdefault('__error__', []).append((u'message', 3, 27, '', _sys.exc_info()[1], ))
raise
# value= at 2317810> -> _condition
_expression = _cache_35800272
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_35800272
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35754928 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35754928
append(u'
')
if (_backup_attrs_35757952 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35757952
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35754136 = get('attrs', _marker)
# name=None at 24cd390> -> _value
_value = _static_38589648
econtext['attrs'] = _value
#
')
_backup_default_35755144 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38591632
try:
_cache_38591632 = getitem('message')
except:
rcontext.setdefault('__error__', []).append((u'message', 4, 32, '', _sys.exc_info()[1], ))
raise
# value= at 24cde90> -> _condition
_expression = _cache_38591632
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_38591632
if (_content is not None):
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = str(_content)
else:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except AttributeError:
_content = convert(_content)
else:
_content = _content()
if (_content is not None):
append(_content)
if (_backup_default_35755144 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35755144
append(u'
')
if (_backup_attrs_35754136 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35754136
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35756728 = get('attrs', _marker)
# name=None at 24aead0> -> _value
_value = _static_38464336
econtext['attrs'] = _value
#
')
_backup_default_35756008 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38592208
try:
_cache_38592208 = getitem('message')
_cache_38592208 = _cache_38592208
except:
rcontext.setdefault('__error__', []).append((u'string:${message}', 5, 27, '', _sys.exc_info()[1], ))
raise
# value= at 222bd50> -> _condition
_expression = _cache_38592208
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_38592208
if (_content is None):
pass
else:
if (_content is False):
_content = None
else:
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = unicode(_content)
else:
try:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except:
_content = convert(_content)
else:
raise RuntimeError
except RuntimeError:
_content = _content()
else:
if ((_content is not None) and (re_needs_escape(_content) is not None)):
if ('&' in _content):
if (';' in _content):
_content = re_amp.sub('&', _content)
else:
_content = _content.replace('&', '&')
if ('<' in _content):
_content = _content.replace('<', '<')
if ('>' in _content):
_content = _content.replace('>', '>')
if ('\x00' in _content):
_content = _content.replace('\x00', '"')
if (_content is not None):
append(_content)
if (_backup_default_35756008 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35756008
append(u'
')
if (_backup_attrs_35756728 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35756728
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_39036616 = get('attrs', _marker)
# name=None at 24ae490> -> _value
_value = _static_38462992
econtext['attrs'] = _value
#
')
_backup_default_37197080 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38465488
try:
_cache_38465488 = getitem('message')
_cache_38465488 = _cache_38465488
except:
rcontext.setdefault('__error__', []).append((u'string:${message}', 6, 32, '', _sys.exc_info()[1], ))
raise
# value= at 24ae190> -> _condition
_expression = _cache_38465488
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
pass
else:
_content = _cache_38465488
if (_content is not None):
_tt = type(_content)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content = str(_content)
else:
if (_tt is str):
_content = decode(_content)
else:
if (_tt is not unicode):
try:
_content = _content.__html__
except AttributeError:
_content = convert(_content)
else:
_content = _content()
if (_content is not None):
append(_content)
if (_backup_default_37197080 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_37197080
append(u'
')
if (_backup_attrs_39036616 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39036616
# -> _content_139955154988272
try:
_content_139955154988272 = getitem('message')
except:
rcontext.setdefault('__error__', []).append((u'message', 7, 6, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = ('%s%s%s' % ((u'\n ' if (u'\n ' is not None) else ''), (_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u'\n ' if (u'\n ' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35756224 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35756224
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38435944 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38435944
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/011.xml 0000644 0001750 0000144 00000000200 11445675021 022213 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/012-translation.pt 0000644 0001750 0000144 00000001067 12035501123 024372 0 ustar mborch users 0000000 0000000
')
_stream_35884752 = _DebuggingOutputStream()
_append_35884752 = _stream_35884752.append
_content_139955154988272 = u'\n Hello world!\n '
if (_content_139955154988272 is not None):
_append_35884752(_content_139955154988272)
_msgid_35884752 = re_whitespace(''.join(_stream_35884752)).strip()
append(translate(_msgid_35884752, mapping=None, default=_msgid_35884752, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_38624936 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38624936
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38619904 = get('attrs', _marker)
# name=None at 23171d0> -> _value
_value = _static_35331024
econtext['attrs'] = _value
#
')
_stream_36796624 = _DebuggingOutputStream()
_append_36796624 = _stream_36796624.append
_content_139955154988272 = u'\n Hello world!\n '
if (_content_139955154988272 is not None):
_append_36796624(_content_139955154988272)
_msgid_36796624 = re_whitespace(''.join(_stream_36796624)).strip()
append(translate(u'hello_world', mapping=None, default=_msgid_36796624, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_38619904 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38619904
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38620264 = get('attrs', _marker)
# name=None at 24b4d10> -> _value
_value = _static_38489936
econtext['attrs'] = _value
#
')
_stream_38487504 = _DebuggingOutputStream()
_append_38487504 = _stream_38487504.append
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
_append_38487504(_content_139955154988272)
_backup_attrs_38617888 = get('attrs', _marker)
# name=None at 24b4e10> -> _value
_value = _static_38488272
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'Hello world!'
if (_content_139955154988272 is not None):
_append_38487504(_content_139955154988272)
_append_38487504(u'')
if (_backup_attrs_38617888 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38617888
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
_append_38487504(_content_139955154988272)
_msgid_38487504 = re_whitespace(''.join(_stream_38487504)).strip()
append(translate(_msgid_38487504, mapping=None, default=_msgid_38487504, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_38620264 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38620264
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38616672 = get('attrs', _marker)
# name=None at 24b4890> -> _value
_value = _static_38488016
econtext['attrs'] = _value
#
')
_stream_35215016_first = ''
_stream_35215016_second = ''
_stream_38487888 = _DebuggingOutputStream()
_append_38487888 = _stream_38487888.append
_content_139955154988272 = u'\n Hello '
if (_content_139955154988272 is not None):
_append_38487888(_content_139955154988272)
_stream_35215016_first = _DebuggingOutputStream()
_append_35215016_first = _stream_35215016_first.append
_backup_attrs_39096120 = get('attrs', _marker)
# name=None at 24b42d0> -> _value
_value = _static_38487632
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'world'
except:
rcontext.setdefault('__error__', []).append((u"'world'", 13, 36, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215016_first(_content_139955154988272)
_append_35215016_first(u'')
if (_backup_attrs_39096120 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39096120
_append_38487888(u'${first}')
_stream_35215016_first = ''.join(_stream_35215016_first)
_content_139955154988272 = u'!\n Goodbye '
if (_content_139955154988272 is not None):
_append_38487888(_content_139955154988272)
_stream_35215016_second = _DebuggingOutputStream()
_append_35215016_second = _stream_35215016_second.append
_backup_attrs_39090152 = get('attrs', _marker)
# name=None at 24b4150> -> _value
_value = _static_38487184
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'planet'
except:
rcontext.setdefault('__error__', []).append((u"'planet'", 14, 39, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215016_second(_content_139955154988272)
_append_35215016_second(u'')
if (_backup_attrs_39090152 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39090152
_append_38487888(u'${second}')
_stream_35215016_second = ''.join(_stream_35215016_second)
_content_139955154988272 = u'!\n '
if (_content_139955154988272 is not None):
_append_38487888(_content_139955154988272)
_msgid_38487888 = re_whitespace(''.join(_stream_38487888)).strip()
append(translate(_msgid_38487888, mapping={u'second': _stream_35215016_second, u'first': _stream_35215016_first, }, default=_msgid_38487888, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_38616672 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38616672
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_39091376 = get('attrs', _marker)
# name=None at 24ca850> -> _value
_value = _static_38579984
econtext['attrs'] = _value
#
')
_stream_35215016_first = ''
_stream_35215016_second = ''
_stream_38486672 = _DebuggingOutputStream()
_append_38486672 = _stream_38486672.append
_content_139955154988272 = u'\n Hello '
if (_content_139955154988272 is not None):
_append_38486672(_content_139955154988272)
_stream_35215016_first = _DebuggingOutputStream()
_append_35215016_first = _stream_35215016_first.append
_backup_attrs_39080520 = get('attrs', _marker)
# name=None at 24cafd0> -> _value
_value = _static_38576848
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'world'
except:
rcontext.setdefault('__error__', []).append((u"'world'", 17, 36, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215016_first(_content_139955154988272)
_append_35215016_first(u'')
if (_backup_attrs_39080520 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39080520
_append_38486672(u'${first}')
_stream_35215016_first = ''.join(_stream_35215016_first)
_content_139955154988272 = u'!\n Goodbye '
if (_content_139955154988272 is not None):
_append_38486672(_content_139955154988272)
_stream_35215016_second = _DebuggingOutputStream()
_append_35215016_second = _stream_35215016_second.append
_backup_attrs_39080592 = get('attrs', _marker)
# name=None at 24ca110> -> _value
_value = _static_38579536
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'planet'
except:
rcontext.setdefault('__error__', []).append((u"'planet'", 18, 39, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215016_second(_content_139955154988272)
_append_35215016_second(u'')
if (_backup_attrs_39080592 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39080592
_append_38486672(u'${second}')
_stream_35215016_second = ''.join(_stream_35215016_second)
_content_139955154988272 = u'!\n '
if (_content_139955154988272 is not None):
_append_38486672(_content_139955154988272)
_msgid_38486672 = re_whitespace(''.join(_stream_38486672)).strip()
append(translate(u'hello_goodbye', mapping={u'second': _stream_35215016_second, u'first': _stream_35215016_first, }, default=_msgid_38486672, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_39091376 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39091376
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38625792 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38625792
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38523248 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38523248
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/012-translation.pt.py 0000600 0001750 0000144 00000052342 11547550677 025044 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
from chameleon.utils import DebuggingOutputStream as _DebuggingOutputStream
pass
_static_38489680 = {}
_static_38487248 = {}
_static_38578448 = {}
_static_38486544 = {}
_static_35828816 = {}
_static_38488720 = {}
_static_36670992 = {}
_static_38579280 = {}
_static_35884240 = {}
_static_38486480 = {}
_static_38578832 = {}
_static_38486800 = {}
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_38432352 = get('attrs', _marker)
# name=None at 222bfd0> -> _value
_value = _static_35828816
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38429976 = get('attrs', _marker)
# name=None at 24b4a50> -> _value
_value = _static_38486800
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38429832 = get('attrs', _marker)
# name=None at 24b45d0> -> _value
_value = _static_38487248
econtext['attrs'] = _value
#
')
_stream_38489104 = _DebuggingOutputStream()
_append_38489104 = _stream_38489104.append
_content_139955154988272 = u'\n Hello world!\n '
if (_content_139955154988272 is not None):
_append_38489104(_content_139955154988272)
_msgid_38489104 = re_whitespace(''.join(_stream_38489104)).strip()
append(translate(_msgid_38489104, mapping=None, default=_msgid_38489104, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_38429832 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38429832
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38412088 = get('attrs', _marker)
# name=None at 24b4510> -> _value
_value = _static_38486544
econtext['attrs'] = _value
#
')
_stream_38487760 = _DebuggingOutputStream()
_append_38487760 = _stream_38487760.append
_content_139955154988272 = u'\n Hello world!\n '
if (_content_139955154988272 is not None):
_append_38487760(_content_139955154988272)
_msgid_38487760 = re_whitespace(''.join(_stream_38487760)).strip()
append(translate(u'hello_world', mapping=None, default=_msgid_38487760, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_38412088 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38412088
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38411152 = get('attrs', _marker)
# name=None at 24b4950> -> _value
_value = _static_38489680
econtext['attrs'] = _value
#
')
_stream_38487888 = _DebuggingOutputStream()
_append_38487888 = _stream_38487888.append
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
_append_38487888(_content_139955154988272)
_backup_attrs_38409280 = get('attrs', _marker)
# name=None at 24b4f10> -> _value
_value = _static_38488720
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'Hello world!'
if (_content_139955154988272 is not None):
_append_38487888(_content_139955154988272)
_append_38487888(u'')
if (_backup_attrs_38409280 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38409280
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
_append_38487888(_content_139955154988272)
_msgid_38487888 = re_whitespace(''.join(_stream_38487888)).strip()
append(translate(_msgid_38487888, mapping=None, default=_msgid_38487888, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_38411152 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38411152
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38408848 = get('attrs', _marker)
# name=None at 24b4350> -> _value
_value = _static_38486480
econtext['attrs'] = _value
#
')
_stream_35215016_first = ''
_stream_35215016_second = ''
_stream_38489040 = _DebuggingOutputStream()
_append_38489040 = _stream_38489040.append
_content_139955154988272 = u'\n Hello '
if (_content_139955154988272 is not None):
_append_38489040(_content_139955154988272)
_stream_35215016_first = _DebuggingOutputStream()
_append_35215016_first = _stream_35215016_first.append
_backup_attrs_38460520 = get('attrs', _marker)
# name=None at 24ca050> -> _value
_value = _static_38579280
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'world'
except:
rcontext.setdefault('__error__', []).append((u"'world'", 13, 36, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215016_first(_content_139955154988272)
_append_35215016_first(u'')
if (_backup_attrs_38460520 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38460520
_append_38489040(u'${first}')
_stream_35215016_first = ''.join(_stream_35215016_first)
_content_139955154988272 = u'!\n Goodbye '
if (_content_139955154988272 is not None):
_append_38489040(_content_139955154988272)
_stream_35215016_second = _DebuggingOutputStream()
_append_35215016_second = _stream_35215016_second.append
_backup_attrs_38461384 = get('attrs', _marker)
# name=None at 24cae10> -> _value
_value = _static_38578448
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'planet'
except:
rcontext.setdefault('__error__', []).append((u"'planet'", 14, 39, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215016_second(_content_139955154988272)
_append_35215016_second(u'')
if (_backup_attrs_38461384 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38461384
_append_38489040(u'${second}')
_stream_35215016_second = ''.join(_stream_35215016_second)
_content_139955154988272 = u'!\n '
if (_content_139955154988272 is not None):
_append_38489040(_content_139955154988272)
_msgid_38489040 = re_whitespace(''.join(_stream_38489040)).strip()
append(translate(_msgid_38489040, mapping={u'second': _stream_35215016_second, u'first': _stream_35215016_first, }, default=_msgid_38489040, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_38408848 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38408848
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38459368 = get('attrs', _marker)
# name=None at 24ca6d0> -> _value
_value = _static_38578832
econtext['attrs'] = _value
#
')
_stream_35215016_first = ''
_stream_35215016_second = ''
_stream_38578576 = _DebuggingOutputStream()
_append_38578576 = _stream_38578576.append
_content_139955154988272 = u'\n Hello '
if (_content_139955154988272 is not None):
_append_38578576(_content_139955154988272)
_stream_35215016_first = _DebuggingOutputStream()
_append_35215016_first = _stream_35215016_first.append
_backup_attrs_37105888 = get('attrs', _marker)
# name=None at 2238f90> -> _value
_value = _static_35884240
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'world'
except:
rcontext.setdefault('__error__', []).append((u"'world'", 17, 36, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215016_first(_content_139955154988272)
_append_35215016_first(u'')
if (_backup_attrs_37105888 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37105888
_append_38578576(u'${first}')
_stream_35215016_first = ''.join(_stream_35215016_first)
_content_139955154988272 = u'!\n Goodbye '
if (_content_139955154988272 is not None):
_append_38578576(_content_139955154988272)
_stream_35215016_second = _DebuggingOutputStream()
_append_35215016_second = _stream_35215016_second.append
_backup_attrs_37108840 = get('attrs', _marker)
# name=None at 22f8510> -> _value
_value = _static_36670992
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 'planet'
except:
rcontext.setdefault('__error__', []).append((u"'planet'", 18, 39, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215016_second(_content_139955154988272)
_append_35215016_second(u'')
if (_backup_attrs_37108840 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37108840
_append_38578576(u'${second}')
_stream_35215016_second = ''.join(_stream_35215016_second)
_content_139955154988272 = u'!\n '
if (_content_139955154988272 is not None):
_append_38578576(_content_139955154988272)
_msgid_38578576 = re_whitespace(''.join(_stream_38578576)).strip()
append(translate(u'hello_goodbye', mapping={u'second': _stream_35215016_second, u'first': _stream_35215016_first, }, default=_msgid_38578576, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_38459368 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38459368
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38429976 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38429976
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38432352 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38432352
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/012.xml 0000644 0001750 0000144 00000000144 11445675021 022223 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/013-repeat-nested.pt 0000644 0001750 0000144 00000000255 11445675021 024610 0 ustar mborch users 0000000 0000000
')
# -> _content_139955154988272
try:
_content_139955154988272 = getitem('i')
except:
rcontext.setdefault('__error__', []).append((u'i', 6, 13, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
# -> _content_139955154988272_110
try:
_content_139955154988272_110 = getitem('j')
except:
rcontext.setdefault('__error__', []).append((u'j', 6, 18, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272_110 is None):
pass
else:
if (_content_139955154988272_110 is False):
_content_139955154988272_110 = None
else:
_tt = type(_content_139955154988272_110)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272_110 = unicode(_content_139955154988272_110)
else:
try:
if (_tt is str):
_content_139955154988272_110 = decode(_content_139955154988272_110)
else:
if (_tt is not unicode):
try:
_content_139955154988272_110 = _content_139955154988272_110.__html__
except:
_content_139955154988272_110 = convert(_content_139955154988272_110)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272_110 = _content_139955154988272_110()
else:
if ((_content_139955154988272_110 is not None) and (re_needs_escape(_content_139955154988272_110) is not None)):
if ('&' in _content_139955154988272_110):
if (';' in _content_139955154988272_110):
_content_139955154988272_110 = re_amp.sub('&', _content_139955154988272_110)
else:
_content_139955154988272_110 = _content_139955154988272_110.replace('&', '&')
if ('<' in _content_139955154988272_110):
_content_139955154988272_110 = _content_139955154988272_110.replace('<', '<')
if ('>' in _content_139955154988272_110):
_content_139955154988272_110 = _content_139955154988272_110.replace('>', '>')
if ('\x00' in _content_139955154988272_110):
_content_139955154988272_110 = _content_139955154988272_110.replace('\x00', '"')
_content_139955154988272 = ('%s%s%s%s%s' % ((u'\n [' if (u'\n [' is not None) else ''), (_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u',' if (u',' is not None) else ''), (_content_139955154988272_110 if (_content_139955154988272_110 is not None) else ''), (u']\n ' if (u']\n ' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'
')
if (_backup_attrs_38450744 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38450744
__index_35883600 -= 1
if (__index_35883600 > 0):
append('\n ')
if (_backup_j_34805456 is _marker):
del econtext['j']
else:
econtext['j'] = _backup_j_34805456
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'
')
if (_backup_attrs_38450384 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38450384
__index_35889808 -= 1
if (__index_35889808 > 0):
append('\n ')
if (_backup_i_38402704 is _marker):
del econtext['i']
else:
econtext['i'] = _backup_i_38402704
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'
')
if (_backup_attrs_38451104 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38451104
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38449232 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38449232
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_35898288 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35898288
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/013.xml 0000644 0001750 0000144 00000000174 11445675021 022227 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/014-repeat-nested-similar.pt 0000644 0001750 0000144 00000000202 11445675021 026237 0 ustar mborch users 0000000 0000000
[${i},${j}]
Chameleon-2.24/src/chameleon/tests/inputs/014-repeat-nested-similar.pt.py 0000600 0001750 0000144 00000025001 11547550677 026676 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
pass
_static_36670928 = {}
_static_35883856 = {}
_static_38579280 = {}
_static_38578448 = {}
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_38460808 = get('attrs', _marker)
# name=None at 2238f90> -> _value
_value = _static_35883856
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38457496 = get('attrs', _marker)
# name=None at 22f8610> -> _value
_value = _static_36670928
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_i_38402704 = get('i', _marker)
# -> _iterator
try:
_iterator = (3, 4, )
except:
rcontext.setdefault('__error__', []).append((u'(3,4)', 3, 24, '', _sys.exc_info()[1], ))
raise
(_iterator, __index_38579664, ) = getitem('repeat')(u'i', _iterator)
econtext['i'] = None
for _item in _iterator:
econtext['i'] = _item
_backup_attrs_38524328 = get('attrs', _marker)
# name=None at 24ca050> -> _value
_value = _static_38579280
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_j_35779152 = get('j', _marker)
# -> _iterator
try:
_iterator = (3, 4, )
except:
rcontext.setdefault('__error__', []).append((u'(3,4)', 4, 26, '', _sys.exc_info()[1], ))
raise
(_iterator, __index_38578064, ) = getitem('repeat')(u'j', _iterator)
econtext['j'] = None
for _item in _iterator:
econtext['j'] = _item
_backup_attrs_38460304 = get('attrs', _marker)
# name=None at 24cad10> -> _value
_value = _static_38578448
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = getitem('i')
except:
rcontext.setdefault('__error__', []).append((u'i', 4, 36, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
# -> _content_139955154988272_87
try:
_content_139955154988272_87 = getitem('j')
except:
rcontext.setdefault('__error__', []).append((u'j', 4, 41, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272_87 is None):
pass
else:
if (_content_139955154988272_87 is False):
_content_139955154988272_87 = None
else:
_tt = type(_content_139955154988272_87)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272_87 = unicode(_content_139955154988272_87)
else:
try:
if (_tt is str):
_content_139955154988272_87 = decode(_content_139955154988272_87)
else:
if (_tt is not unicode):
try:
_content_139955154988272_87 = _content_139955154988272_87.__html__
except:
_content_139955154988272_87 = convert(_content_139955154988272_87)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272_87 = _content_139955154988272_87()
else:
if ((_content_139955154988272_87 is not None) and (re_needs_escape(_content_139955154988272_87) is not None)):
if ('&' in _content_139955154988272_87):
if (';' in _content_139955154988272_87):
_content_139955154988272_87 = re_amp.sub('&', _content_139955154988272_87)
else:
_content_139955154988272_87 = _content_139955154988272_87.replace('&', '&')
if ('<' in _content_139955154988272_87):
_content_139955154988272_87 = _content_139955154988272_87.replace('<', '<')
if ('>' in _content_139955154988272_87):
_content_139955154988272_87 = _content_139955154988272_87.replace('>', '>')
if ('\x00' in _content_139955154988272_87):
_content_139955154988272_87 = _content_139955154988272_87.replace('\x00', '"')
_content_139955154988272 = ('%s%s%s%s%s' % ((u'[' if (u'[' is not None) else ''), (_content_139955154988272 if (_content_139955154988272 is not None) else ''), (u',' if (u',' is not None) else ''), (_content_139955154988272_87 if (_content_139955154988272_87 is not None) else ''), (u']' if (u']' is not None) else ''), ))
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38460304 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38460304
__index_38578064 -= 1
if (__index_38578064 > 0):
append('\n ')
if (_backup_j_35779152 is _marker):
del econtext['j']
else:
econtext['j'] = _backup_j_35779152
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38524328 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38524328
__index_38579664 -= 1
if (__index_38579664 > 0):
append('\n ')
if (_backup_i_38402704 is _marker):
del econtext['i']
else:
econtext['i'] = _backup_i_38402704
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38457496 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38457496
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38460808 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38460808
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/014.xml 0000644 0001750 0000144 00000000226 11445675021 022226 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/015-translation-nested.pt 0000644 0001750 0000144 00000000312 11445675021 025662 0 ustar mborch users 0000000 0000000
')
_stream_35215016_price = ''
_stream_38577872 = _DebuggingOutputStream()
_append_38577872 = _stream_38577872.append
_content_139955154988272 = u'\n Price:\n '
if (_content_139955154988272 is not None):
_append_38577872(_content_139955154988272)
_stream_35215016_price = _DebuggingOutputStream()
_append_35215016_price = _stream_35215016_price.append
_backup_attrs_39124432 = get('attrs', _marker)
# name=None at 24b4d50> -> _value
_value = _static_38488592
econtext['attrs'] = _value
# ')
_stream_35215248_amount = ''
_stream_38576464 = _DebuggingOutputStream()
_append_38576464 = _stream_38576464.append
_content_139955154988272 = u'\n Per kilo '
if (_content_139955154988272 is not None):
_append_38576464(_content_139955154988272)
_stream_35215248_amount = _DebuggingOutputStream()
_append_35215248_amount = _stream_35215248_amount.append
_backup_attrs_38958432 = get('attrs', _marker)
# name=None at 24a5bd0> -> _value
_value = _static_38428304
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 12.5
except:
rcontext.setdefault('__error__', []).append((u'12.5', 6, 42, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215248_amount(_content_139955154988272)
_append_35215248_amount(u'')
if (_backup_attrs_38958432 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38958432
_append_38576464(u'${amount}')
_stream_35215248_amount = ''.join(_stream_35215248_amount)
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
_append_38576464(_content_139955154988272)
_msgid_38576464 = re_whitespace(''.join(_stream_38576464)).strip()
_append_35215016_price(translate(_msgid_38576464, mapping={u'amount': _stream_35215248_amount, }, default=_msgid_38576464, domain=_i18n_domain))
_append_35215016_price(u'')
if (_backup_attrs_39124432 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39124432
_append_38577872(u'${price}')
_stream_35215016_price = ''.join(_stream_35215016_price)
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
_append_38577872(_content_139955154988272)
_msgid_38577872 = re_whitespace(''.join(_stream_38577872)).strip()
append(translate(_msgid_38577872, mapping={u'price': _stream_35215016_price, }, default=_msgid_38577872, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_39079448 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_39079448
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38430264 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38430264
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38960088 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38960088
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/015-translation-nested.pt.py 0000600 0001750 0000144 00000017374 11547550677 026335 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
import sys as _sys
from chameleon.utils import DebuggingOutputStream as _DebuggingOutputStream
pass
_static_38579280 = {}
_static_38425872 = {}
_static_38427536 = {}
_static_36668688 = {}
_static_38576400 = {}
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_38408776 = get('attrs', _marker)
# name=None at 24a59d0> -> _value
_value = _static_38425872
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36681056 = get('attrs', _marker)
# name=None at 24a5490> -> _value
_value = _static_38427536
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_37011112 = get('attrs', _marker)
# name=None at 24ca050> -> _value
_value = _static_38579280
econtext['attrs'] = _value
#
')
_stream_35215016_price = ''
_stream_38579984 = _DebuggingOutputStream()
_append_38579984 = _stream_38579984.append
_content_139955154988272 = u'\n Price:\n '
if (_content_139955154988272 is not None):
_append_38579984(_content_139955154988272)
_stream_35215016_price = _DebuggingOutputStream()
_append_35215016_price = _stream_35215016_price.append
_backup_attrs_38411512 = get('attrs', _marker)
# name=None at 24cad90> -> _value
_value = _static_38576400
econtext['attrs'] = _value
# ')
_stream_35215248_amount = ''
_stream_38578448 = _DebuggingOutputStream()
_append_38578448 = _stream_38578448.append
_content_139955154988272 = u'\n Per kilo '
if (_content_139955154988272 is not None):
_append_38578448(_content_139955154988272)
_stream_35215248_amount = _DebuggingOutputStream()
_append_35215248_amount = _stream_35215248_amount.append
_backup_attrs_37011184 = get('attrs', _marker)
# name=None at 24cacd0> -> _value
_value = _static_36668688
econtext['attrs'] = _value
# ')
# -> _content_139955154988272
try:
_content_139955154988272 = 12.5
except:
rcontext.setdefault('__error__', []).append((u'12.5', 6, 42, '', _sys.exc_info()[1], ))
raise
if (_content_139955154988272 is None):
pass
else:
if (_content_139955154988272 is False):
_content_139955154988272 = None
else:
_tt = type(_content_139955154988272)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_content_139955154988272 = unicode(_content_139955154988272)
else:
try:
if (_tt is str):
_content_139955154988272 = decode(_content_139955154988272)
else:
if (_tt is not unicode):
try:
_content_139955154988272 = _content_139955154988272.__html__
except:
_content_139955154988272 = convert(_content_139955154988272)
else:
raise RuntimeError
except RuntimeError:
_content_139955154988272 = _content_139955154988272()
else:
if ((_content_139955154988272 is not None) and (re_needs_escape(_content_139955154988272) is not None)):
if ('&' in _content_139955154988272):
if (';' in _content_139955154988272):
_content_139955154988272 = re_amp.sub('&', _content_139955154988272)
else:
_content_139955154988272 = _content_139955154988272.replace('&', '&')
if ('<' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('<', '<')
if ('>' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('>', '>')
if ('\x00' in _content_139955154988272):
_content_139955154988272 = _content_139955154988272.replace('\x00', '"')
_content_139955154988272 = _content_139955154988272
if (_content_139955154988272 is not None):
_append_35215248_amount(_content_139955154988272)
_append_35215248_amount(u'')
if (_backup_attrs_37011184 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37011184
_append_38578448(u'${amount}')
_stream_35215248_amount = ''.join(_stream_35215248_amount)
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
_append_38578448(_content_139955154988272)
_msgid_38578448 = re_whitespace(''.join(_stream_38578448)).strip()
_append_35215016_price(translate(_msgid_38578448, mapping={u'amount': _stream_35215248_amount, }, default=_msgid_38578448, domain=_i18n_domain))
_append_35215016_price(u'')
if (_backup_attrs_38411512 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38411512
_append_38579984(u'${price}')
_stream_35215016_price = ''.join(_stream_35215016_price)
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
_append_38579984(_content_139955154988272)
_msgid_38579984 = re_whitespace(''.join(_stream_38579984)).strip()
append(translate(_msgid_38579984, mapping={u'price': _stream_35215016_price, }, default=_msgid_38579984, domain=_i18n_domain))
append(u'
')
if (_backup_attrs_37011112 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37011112
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_36681056 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36681056
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_38408776 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38408776
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/015.xml 0000644 0001750 0000144 00000000226 11445675021 022227 0 ustar mborch users 0000000 0000000
]>
Chameleon-2.24/src/chameleon/tests/inputs/016-explicit-translation.pt 0000644 0001750 0000144 00000000626 11445675021 026232 0 ustar mborch users 0000000 0000000
')
_backup_default_36732008 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38578448
try:
_cache_38578448 = u'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u'string:Hello world!', 3, 40, '', _sys.exc_info()[1], ))
raise
# value= at 24cacd0> -> _condition
_expression = _cache_38578448
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
_content_139955154988272 = u'\n Hello world!\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
else:
_content = _cache_38578448
_content = translate(_content, default=None, domain=_i18n_domain)
if (_content is not None):
append(_content)
if (_backup_default_36732008 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36732008
append(u'
')
if (_backup_attrs_35804152 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35804152
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36729776 = get('attrs', _marker)
# name=None at 24a5b90> -> _value
_value = _static_38425616
econtext['attrs'] = _value
# at 24a5a90> -> _attr_alt
# -> _attr_alt
# -> _attr_alt
try:
_attr_alt = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 6, 16, '', _sys.exc_info()[1], ))
raise
_attr_alt = _attr_alt
_attr_alt = translate(_attr_alt, default=_attr_alt, domain=_i18n_domain)
if (_attr_alt is None):
pass
else:
if (_attr_alt is False):
_attr_alt = None
else:
_tt = type(_attr_alt)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_alt = unicode(_attr_alt)
else:
try:
if (_tt is str):
_attr_alt = decode(_attr_alt)
else:
if (_tt is not unicode):
try:
_attr_alt = _attr_alt.__html__
except:
_attr_alt = convert(_attr_alt)
else:
raise RuntimeError
except RuntimeError:
_attr_alt = _attr_alt()
else:
if ((_attr_alt is not None) and (re_needs_escape(_attr_alt) is not None)):
if ('&' in _attr_alt):
if (';' in _attr_alt):
_attr_alt = re_amp.sub('&', _attr_alt)
else:
_attr_alt = _attr_alt.replace('&', '&')
if ('<' in _attr_alt):
_attr_alt = _attr_alt.replace('<', '<')
if ('>' in _attr_alt):
_attr_alt = _attr_alt.replace('>', '>')
if (u'"' in _attr_alt):
_attr_alt = _attr_alt.replace(u'"', '"')
if (_attr_alt is not None):
append((u' alt="%s"' % _attr_alt))
if (_backup_default_36729128 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36729128
append(u' />')
if (_backup_attrs_36729776 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36729776
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35874000 = get('attrs', _marker)
# name=None at 234ce10> -> _value
_value = _static_37011728
econtext['attrs'] = _value
# at 234c9d0> -> _attr_alt
# -> _attr_alt
# -> _attr_alt
try:
_attr_alt = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 7, 16, '', _sys.exc_info()[1], ))
raise
_attr_alt = _attr_alt
_attr_alt = translate(u'hello_world', default=_attr_alt, domain=_i18n_domain)
if (_attr_alt is None):
pass
else:
if (_attr_alt is False):
_attr_alt = None
else:
_tt = type(_attr_alt)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_alt = unicode(_attr_alt)
else:
try:
if (_tt is str):
_attr_alt = decode(_attr_alt)
else:
if (_tt is not unicode):
try:
_attr_alt = _attr_alt.__html__
except:
_attr_alt = convert(_attr_alt)
else:
raise RuntimeError
except RuntimeError:
_attr_alt = _attr_alt()
else:
if ((_attr_alt is not None) and (re_needs_escape(_attr_alt) is not None)):
if ('&' in _attr_alt):
if (';' in _attr_alt):
_attr_alt = re_amp.sub('&', _attr_alt)
else:
_attr_alt = _attr_alt.replace('&', '&')
if ('<' in _attr_alt):
_attr_alt = _attr_alt.replace('<', '<')
if ('>' in _attr_alt):
_attr_alt = _attr_alt.replace('>', '>')
if (u'"' in _attr_alt):
_attr_alt = _attr_alt.replace(u'"', '"')
if (_attr_alt is not None):
append((u' alt="%s"' % _attr_alt))
if (_backup_default_35876808 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35876808
append(u' />')
if (_backup_attrs_35874000 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35874000
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35875152 = get('attrs', _marker)
# name=None at 24aebd0> -> _value
_value = _static_38465488
econtext['attrs'] = _value
# at 24aead0> -> _attr_alt
# -> _attr_alt
try:
_attr_alt = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 8, 29, '', _sys.exc_info()[1], ))
raise
_attr_alt = translate(_attr_alt, default=_attr_alt, domain=_i18n_domain)
if (_attr_alt is None):
pass
else:
if (_attr_alt is False):
_attr_alt = None
else:
_tt = type(_attr_alt)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_alt = unicode(_attr_alt)
else:
try:
if (_tt is str):
_attr_alt = decode(_attr_alt)
else:
if (_tt is not unicode):
try:
_attr_alt = _attr_alt.__html__
except:
_attr_alt = convert(_attr_alt)
else:
raise RuntimeError
except RuntimeError:
_attr_alt = _attr_alt()
else:
if ((_attr_alt is not None) and (re_needs_escape(_attr_alt) is not None)):
if ('&' in _attr_alt):
if (';' in _attr_alt):
_attr_alt = re_amp.sub('&', _attr_alt)
else:
_attr_alt = _attr_alt.replace('&', '&')
if ('<' in _attr_alt):
_attr_alt = _attr_alt.replace('<', '<')
if ('>' in _attr_alt):
_attr_alt = _attr_alt.replace('>', '>')
if ('"' in _attr_alt):
_attr_alt = _attr_alt.replace('"', '"')
if (_attr_alt is not None):
append((u' alt="%s"' % _attr_alt))
if (_backup_default_35874072 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35874072
append(u' />')
if (_backup_attrs_35875152 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35875152
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_35872848 = get('attrs', _marker)
# name=None at 24ae910> -> _value
_value = _static_38463824
econtext['attrs'] = _value
# at 24ae890> -> _attr_alt
# -> _attr_alt
try:
_attr_alt = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 9, 29, '', _sys.exc_info()[1], ))
raise
_attr_alt = translate(u'hello_world', default=_attr_alt, domain=_i18n_domain)
if (_attr_alt is None):
pass
else:
if (_attr_alt is False):
_attr_alt = None
else:
_tt = type(_attr_alt)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_alt = unicode(_attr_alt)
else:
try:
if (_tt is str):
_attr_alt = decode(_attr_alt)
else:
if (_tt is not unicode):
try:
_attr_alt = _attr_alt.__html__
except:
_attr_alt = convert(_attr_alt)
else:
raise RuntimeError
except RuntimeError:
_attr_alt = _attr_alt()
else:
if ((_attr_alt is not None) and (re_needs_escape(_attr_alt) is not None)):
if ('&' in _attr_alt):
if (';' in _attr_alt):
_attr_alt = re_amp.sub('&', _attr_alt)
else:
_attr_alt = _attr_alt.replace('&', '&')
if ('<' in _attr_alt):
_attr_alt = _attr_alt.replace('<', '<')
if ('>' in _attr_alt):
_attr_alt = _attr_alt.replace('>', '>')
if ('"' in _attr_alt):
_attr_alt = _attr_alt.replace('"', '"')
if (_attr_alt is not None):
append((u' alt="%s"' % _attr_alt))
if (_backup_default_35873208 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_35873208
append(u' />')
if (_backup_attrs_35872848 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_35872848
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_36729920 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36729920
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
append(u'')
if (_backup_attrs_36729560 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36729560
_content_139955154988272 = u'\n'
if (_content_139955154988272 is not None):
append(_content_139955154988272)
pass Chameleon-2.24/src/chameleon/tests/inputs/016-explicit-translation.pt.py 0000600 0001750 0000144 00000037541 11547550677 026673 0 ustar mborch users 0000000 0000000 # -*- coding: utf-8 -*-
pass
from chameleon.utils import Placeholder as _Placeholder
import sys as _sys
pass
_static_38461520 = {u'alt': u"'Hello world!'", }
_static_38577424 = {}
_static_38427984 = {}
_static_38578896 = {u'alt': u"${'Hello world!'}", }
_static_38401104 = {u'alt': u"'Hello world!'", }
_static_38462480 = {u'alt': u"${'Hello world!'}", }
_static_38428112 = {}
_marker_default = _Placeholder()
import re
import functools
_marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def render(stream, econtext, rcontext):
append = stream.append
getitem = econtext.__getitem__
get = econtext.get
_i18n_domain = None
re_amp = g_re_amp
re_needs_escape = g_re_needs_escape
decode = getitem('decode')
convert = getitem('convert')
translate = getitem('translate')
_backup_attrs_37150016 = get('attrs', _marker)
# name=None at 24a59d0> -> _value
_value = _static_38428112
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36785184 = get('attrs', _marker)
# name=None at 24a5a50> -> _value
_value = _static_38427984
econtext['attrs'] = _value
# ')
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_38523176 = get('attrs', _marker)
# name=None at 24ca9d0> -> _value
_value = _static_38577424
econtext['attrs'] = _value
#
')
_backup_default_36784176 = get('default', _marker)
# -> _value
_value = _marker_default
econtext['default'] = _value
# -> _cache_38578576
try:
_cache_38578576 = u'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u'string:Hello world!', 3, 40, '', _sys.exc_info()[1], ))
raise
# value= at 24ca110> -> _condition
_expression = _cache_38578576
# -> _value
_value = _marker_default
_condition = (_expression is _value)
if _condition:
_content_139955154988272 = u'\n Hello world!\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
else:
_content = _cache_38578576
_content = translate(_content, default=None, domain=_i18n_domain)
if (_content is not None):
append(_content)
if (_backup_default_36784176 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36784176
append(u'
')
if (_backup_attrs_38523176 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_38523176
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_36793448 = get('attrs', _marker)
# name=None at 24cae90> -> _value
_value = _static_38578896
econtext['attrs'] = _value
# at 24ae190> -> _attr_alt
# -> _attr_alt
# -> _attr_alt
try:
_attr_alt = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 6, 16, '', _sys.exc_info()[1], ))
raise
_attr_alt = _attr_alt
_attr_alt = translate(_attr_alt, default=_attr_alt, domain=_i18n_domain)
if (_attr_alt is None):
pass
else:
if (_attr_alt is False):
_attr_alt = None
else:
_tt = type(_attr_alt)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_alt = unicode(_attr_alt)
else:
try:
if (_tt is str):
_attr_alt = decode(_attr_alt)
else:
if (_tt is not unicode):
try:
_attr_alt = _attr_alt.__html__
except:
_attr_alt = convert(_attr_alt)
else:
raise RuntimeError
except RuntimeError:
_attr_alt = _attr_alt()
else:
if ((_attr_alt is not None) and (re_needs_escape(_attr_alt) is not None)):
if ('&' in _attr_alt):
if (';' in _attr_alt):
_attr_alt = re_amp.sub('&', _attr_alt)
else:
_attr_alt = _attr_alt.replace('&', '&')
if ('<' in _attr_alt):
_attr_alt = _attr_alt.replace('<', '<')
if ('>' in _attr_alt):
_attr_alt = _attr_alt.replace('>', '>')
if (u'"' in _attr_alt):
_attr_alt = _attr_alt.replace(u'"', '"')
if (_attr_alt is not None):
append((u' alt="%s"' % _attr_alt))
if (_backup_default_36792152 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_36792152
append(u' />')
if (_backup_attrs_36793448 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_36793448
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_37151448 = get('attrs', _marker)
# name=None at 24ae310> -> _value
_value = _static_38462480
econtext['attrs'] = _value
# at 24aecd0> -> _attr_alt
# -> _attr_alt
# -> _attr_alt
try:
_attr_alt = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 7, 16, '', _sys.exc_info()[1], ))
raise
_attr_alt = _attr_alt
_attr_alt = translate(u'hello_world', default=_attr_alt, domain=_i18n_domain)
if (_attr_alt is None):
pass
else:
if (_attr_alt is False):
_attr_alt = None
else:
_tt = type(_attr_alt)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_alt = unicode(_attr_alt)
else:
try:
if (_tt is str):
_attr_alt = decode(_attr_alt)
else:
if (_tt is not unicode):
try:
_attr_alt = _attr_alt.__html__
except:
_attr_alt = convert(_attr_alt)
else:
raise RuntimeError
except RuntimeError:
_attr_alt = _attr_alt()
else:
if ((_attr_alt is not None) and (re_needs_escape(_attr_alt) is not None)):
if ('&' in _attr_alt):
if (';' in _attr_alt):
_attr_alt = re_amp.sub('&', _attr_alt)
else:
_attr_alt = _attr_alt.replace('&', '&')
if ('<' in _attr_alt):
_attr_alt = _attr_alt.replace('<', '<')
if ('>' in _attr_alt):
_attr_alt = _attr_alt.replace('>', '>')
if (u'"' in _attr_alt):
_attr_alt = _attr_alt.replace(u'"', '"')
if (_attr_alt is not None):
append((u' alt="%s"' % _attr_alt))
if (_backup_default_37154184 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_37154184
append(u' />')
if (_backup_attrs_37151448 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37151448
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_37152528 = get('attrs', _marker)
# name=None at 24ae210> -> _value
_value = _static_38461520
econtext['attrs'] = _value
# at 24ae750> -> _attr_alt
# -> _attr_alt
try:
_attr_alt = 'Hello world!'
except:
rcontext.setdefault('__error__', []).append((u"'Hello world!'", 8, 29, '', _sys.exc_info()[1], ))
raise
_attr_alt = translate(_attr_alt, default=_attr_alt, domain=_i18n_domain)
if (_attr_alt is None):
pass
else:
if (_attr_alt is False):
_attr_alt = None
else:
_tt = type(_attr_alt)
if ((_tt is int) or (_tt is float) or (_tt is long)):
_attr_alt = unicode(_attr_alt)
else:
try:
if (_tt is str):
_attr_alt = decode(_attr_alt)
else:
if (_tt is not unicode):
try:
_attr_alt = _attr_alt.__html__
except:
_attr_alt = convert(_attr_alt)
else:
raise RuntimeError
except RuntimeError:
_attr_alt = _attr_alt()
else:
if ((_attr_alt is not None) and (re_needs_escape(_attr_alt) is not None)):
if ('&' in _attr_alt):
if (';' in _attr_alt):
_attr_alt = re_amp.sub('&', _attr_alt)
else:
_attr_alt = _attr_alt.replace('&', '&')
if ('<' in _attr_alt):
_attr_alt = _attr_alt.replace('<', '<')
if ('>' in _attr_alt):
_attr_alt = _attr_alt.replace('>', '>')
if ('"' in _attr_alt):
_attr_alt = _attr_alt.replace('"', '"')
if (_attr_alt is not None):
append((u' alt="%s"' % _attr_alt))
if (_backup_default_37151520 is _marker):
del econtext['default']
else:
econtext['default'] = _backup_default_37151520
append(u' />')
if (_backup_attrs_37152528 is _marker):
del econtext['attrs']
else:
econtext['attrs'] = _backup_attrs_37152528
_content_139955154988272 = u'\n '
if (_content_139955154988272 is not None):
append(_content_139955154988272)
_backup_attrs_37151088 = get('attrs', _marker)
#