code stringlengths 1 1.49M | vector listlengths 0 7.38k | snippet listlengths 0 7.38k |
|---|---|---|
# -*- coding: utf-8 -*-
"""
jinja2.tests
~~~~~~~~~~~~
Jinja test functions. Used with the "is" operator.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import re
from jinja2.runtime import Undefined
try:
from collections import Mapping as MappingType
... | [
[
8,
0,
0.0373,
0.0559,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0683,
0.0062,
0,
0.66,
0.0435,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.0745,
0.0062,
0,
0.66... | [
"\"\"\"\n jinja2.tests\n ~~~~~~~~~~~~\n\n Jinja test functions. Used with the \"is\" operator.\n\n :copyright: (c) 2010 by the Jinja Team.\n :license: BSD, see LICENSE for more details.",
"import re",
"from jinja2.runtime import Undefined",
"try:\n from collections import Mapping as MappingT... |
# -*- coding: utf-8 -*-
"""
jinja2.optimizer
~~~~~~~~~~~~~~~~
The jinja optimizer is currently trying to constant fold a few expressions
and modify the AST in place so that it should be easier to evaluate it.
Because the AST does not contain all the scoping information and the
compiler has to ... | [
[
8,
0,
0.1471,
0.25,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2794,
0.0147,
0,
0.66,
0.25,
436,
0,
1,
0,
0,
436,
0,
0
],
[
1,
0,
0.2941,
0.0147,
0,
0.66,
... | [
"\"\"\"\n jinja2.optimizer\n ~~~~~~~~~~~~~~~~\n\n The jinja optimizer is currently trying to constant fold a few expressions\n and modify the AST in place so that it should be easier to evaluate it.\n\n Because the AST does not contain all the scoping information and the",
"from jinja2 import nodes... |
# -*- coding: utf-8 -*-
"""
jinja.constants
~~~~~~~~~~~~~~~
Various constants.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
#: list of lorem ipsum words used by the lipsum() helper function
LOREM_IPSUM_WORDS = u'''\
a ac accumsan ad adipiscing aenean a... | [
[
8,
0,
0.1875,
0.2812,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.7188,
0.5938,
0,
0.66,
1,
350,
1,
0,
0,
0,
0,
3,
0
]
] | [
"\"\"\"\n jinja.constants\n ~~~~~~~~~~~~~~~\n\n Various constants.\n\n :copyright: (c) 2010 by the Jinja Team.\n :license: BSD, see LICENSE for more details.",
"LOREM_IPSUM_WORDS = u'''\\\na ac accumsan ad adipiscing aenean aliquam aliquet amet ante aptent arcu at\nauctor augue bibendum blandit cla... |
# -*- coding: utf-8 -*-
"""
jinja2.sandbox
~~~~~~~~~~~~~~
Adds a sandbox layer to Jinja as it was the default behavior in the old
Jinja 1 releases. This sandbox is slightly different from Jinja 1 as the
default behavior is easier to use.
The behavior can be changed by subclassing the environm... | [
[
8,
0,
0.0222,
0.036,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0416,
0.0028,
0,
0.66,
0.0435,
616,
0,
1,
0,
0,
616,
0,
0
],
[
1,
0,
0.0443,
0.0028,
0,
0.66,... | [
"\"\"\"\n jinja2.sandbox\n ~~~~~~~~~~~~~~\n\n Adds a sandbox layer to Jinja as it was the default behavior in the old\n Jinja 1 releases. This sandbox is slightly different from Jinja 1 as the\n default behavior is easier to use.",
"import operator",
"from jinja2.environment import Environment",... |
import gc
import unittest
from jinja2._markupsafe import Markup, escape, escape_silent
class MarkupTestCase(unittest.TestCase):
def test_markup_operations(self):
# adding two strings should escape the unsafe one
unsafe = '<script type="application/x-some-script">alert("foo");</script>'
sa... | [
[
1,
0,
0.0125,
0.0125,
0,
0.66,
0,
92,
0,
1,
0,
0,
92,
0,
0
],
[
1,
0,
0.025,
0.0125,
0,
0.66,
0.1667,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0375,
0.0125,
0,
0.66,... | [
"import gc",
"import unittest",
"from jinja2._markupsafe import Markup, escape, escape_silent",
"class MarkupTestCase(unittest.TestCase):\n\n def test_markup_operations(self):\n # adding two strings should escape the unsafe one\n unsafe = '<script type=\"application/x-some-script\">alert(\"fo... |
# -*- coding: utf-8 -*-
"""
markupsafe._constants
~~~~~~~~~~~~~~~~~~~~~
Highlevel implementation of the Markup string.
:copyright: (c) 2010 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
HTML_ENTITIES = {
'AElig': 198,
'Aacute': 193,
'Acirc': 194,
'Agrave': 1... | [
[
8,
0,
0.0225,
0.0337,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.5243,
0.9551,
0,
0.66,
1,
955,
0,
0,
0,
0,
0,
6,
0
]
] | [
"\"\"\"\n markupsafe._constants\n ~~~~~~~~~~~~~~~~~~~~~\n\n Highlevel implementation of the Markup string.\n\n :copyright: (c) 2010 by Armin Ronacher.\n :license: BSD, see LICENSE for more details.",
"HTML_ENTITIES = {\n 'AElig': 198,\n 'Aacute': 193,\n 'Acirc': 194,\n 'Agrave': 192,\n ... |
# -*- coding: utf-8 -*-
"""
jinja2._markupsafe._bundle
~~~~~~~~~~~~~~~~~~~~~~~~~~
This script pulls in markupsafe from a source folder and
bundles it with Jinja2. It does not pull in the speedups
module though.
:copyright: Copyright 2010 by the Jinja team, see AUTHORS.
:license: BSD, see ... | [
[
8,
0,
0.1429,
0.2245,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2653,
0.0204,
0,
0.66,
0.1667,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.2857,
0.0204,
0,
0.66... | [
"\"\"\"\n jinja2._markupsafe._bundle\n ~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n This script pulls in markupsafe from a source folder and\n bundles it with Jinja2. It does not pull in the speedups\n module though.",
"import sys",
"import os",
"import re",
"def rewrite_imports(lines):\n for idx, line... |
# -*- coding: utf-8 -*-
"""
markupsafe
~~~~~~~~~~
Implements a Markup string.
:copyright: (c) 2010 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
import re
from itertools import imap
__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent']
_striptags_re = re.compile... | [
[
8,
0,
0.0267,
0.04,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0489,
0.0044,
0,
0.66,
0.1111,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.0533,
0.0044,
0,
0.66,
... | [
"\"\"\"\n markupsafe\n ~~~~~~~~~~\n\n Implements a Markup string.\n\n :copyright: (c) 2010 by Armin Ronacher.\n :license: BSD, see LICENSE for more details.",
"import re",
"from itertools import imap",
"__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent']",
"_striptags_re = re.comp... |
# -*- coding: utf-8 -*-
"""
markupsafe._native
~~~~~~~~~~~~~~~~~~
Native Python implementation the C module is not compiled.
:copyright: (c) 2010 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
from jinja2._markupsafe import Markup
def escape(s):
"""Convert the characters... | [
[
8,
0,
0.1333,
0.2,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2444,
0.0222,
0,
0.66,
0.25,
409,
0,
1,
0,
0,
409,
0,
0
],
[
2,
0,
0.4556,
0.3111,
0,
0.66,
... | [
"\"\"\"\n markupsafe._native\n ~~~~~~~~~~~~~~~~~~\n\n Native Python implementation the C module is not compiled.\n\n :copyright: (c) 2010 by Armin Ronacher.\n :license: BSD, see LICENSE for more details.",
"from jinja2._markupsafe import Markup",
"def escape(s):\n \"\"\"Convert the characters ... |
# -*- coding: utf-8 -*-
"""
jinja2.loaders
~~~~~~~~~~~~~~
Jinja loader classes.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import os
import sys
import weakref
from types import ModuleType
from os import path
try:
from hashlib import sha1
except Imp... | [
[
8,
0,
0.0133,
0.02,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0244,
0.0022,
0,
0.66,
0.0556,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0267,
0.0022,
0,
0.66,
... | [
"\"\"\"\n jinja2.loaders\n ~~~~~~~~~~~~~~\n\n Jinja loader classes.\n\n :copyright: (c) 2010 by the Jinja Team.\n :license: BSD, see LICENSE for more details.",
"import os",
"import sys",
"import weakref",
"from types import ModuleType",
"from os import path",
"try:\n from hashlib impo... |
# -*- coding: utf-8 -*-
"""
jinja2.exceptions
~~~~~~~~~~~~~~~~~
Jinja exceptions.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
class TemplateError(Exception):
"""Baseclass for all template errors."""
def __init__(self, message=None):
i... | [
[
8,
0,
0.042,
0.0629,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
3,
0,
0.1364,
0.0979,
0,
0.66,
0.1111,
179,
0,
2,
0,
0,
645,
0,
4
],
[
8,
1,
0.0979,
0.007,
1,
0.14,
... | [
"\"\"\"\n jinja2.exceptions\n ~~~~~~~~~~~~~~~~~\n\n Jinja exceptions.\n\n :copyright: (c) 2010 by the Jinja Team.\n :license: BSD, see LICENSE for more details.",
"class TemplateError(Exception):\n \"\"\"Baseclass for all template errors.\"\"\"\n\n def __init__(self, message=None):\n i... |
# -*- coding: utf-8 -*-
"""
jinja2
~~~~~~
Jinja2 is a template engine written in pure Python. It provides a
Django inspired non-XML syntax but supports inline expressions and
an optional sandboxed environment.
Nutshell
--------
Here a small example of a Jinja2 template::
{% ... | [
[
8,
0,
0.2174,
0.3913,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.4203,
0.0145,
0,
0.66,
0.1,
959,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.4348,
0.0145,
0,
0.66,
... | [
"\"\"\"\n jinja2\n ~~~~~~\n\n Jinja2 is a template engine written in pure Python. It provides a\n Django inspired non-XML syntax but supports inline expressions and\n an optional sandboxed environment.",
"__docformat__ = 'restructuredtext en'",
"__version__ = '2.6'",
"from jinja2.environment i... |
# -*- coding: utf-8 -*-
"""
jinja2.filters
~~~~~~~~~~~~~~
Bundled jinja filters.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import re
import math
from random import choice
from operator import itemgetter
from itertools import imap, groupby
from jinja2.... | [
[
8,
0,
0.0075,
0.0113,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0138,
0.0013,
0,
0.66,
0.0192,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.015,
0.0013,
0,
0.66,... | [
"\"\"\"\n jinja2.filters\n ~~~~~~~~~~~~~~\n\n Bundled jinja filters.\n\n :copyright: (c) 2010 by the Jinja Team.\n :license: BSD, see LICENSE for more details.",
"import re",
"import math",
"from random import choice",
"from operator import itemgetter",
"from itertools import imap, groupby"... |
# -*- coding: utf-8 -*-
"""
jinja2.defaults
~~~~~~~~~~~~~~~
Jinja default filters and tags.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
from jinja2.utils import generate_lorem_ipsum, Cycler, Joiner
# defaults for the parser / lexer
BLOCK_START_STRING ... | [
[
8,
0,
0.15,
0.225,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.275,
0.025,
0,
0.66,
0.0667,
677,
0,
3,
0,
0,
677,
0,
0
],
[
14,
0,
0.375,
0.025,
0,
0.66,
... | [
"\"\"\"\n jinja2.defaults\n ~~~~~~~~~~~~~~~\n\n Jinja default filters and tags.\n\n :copyright: (c) 2010 by the Jinja Team.\n :license: BSD, see LICENSE for more details.",
"from jinja2.utils import generate_lorem_ipsum, Cycler, Joiner",
"BLOCK_START_STRING = '{%'",
"BLOCK_END_STRING = '%}'",
... |
# -*- coding: utf-8 -*-
"""
jinja2._stringdefs
~~~~~~~~~~~~~~~~~~
Strings of all Unicode characters of a certain category.
Used for matching in Unicode-aware languages. Run to regenerate.
Inspired by chartypes_create.py from the MoinMoin project, original
implementation from Pygments.
:co... | [
[
8,
0,
0.0615,
0.1,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.1231,
0.0077,
0,
0.66,
0.0278,
924,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.1385,
0.0077,
0,
0.66,
... | [
"\"\"\"\n jinja2._stringdefs\n ~~~~~~~~~~~~~~~~~~\n\n Strings of all Unicode characters of a certain category.\n Used for matching in Unicode-aware languages. Run to regenerate.\n\n Inspired by chartypes_create.py from the MoinMoin project, original",
"Cc = u'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x0... |
# -*- coding: utf-8 -*-
"""
jinja2.parser
~~~~~~~~~~~~~
Implements the template parser.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
from jinja2 import nodes
from jinja2.exceptions import TemplateSyntaxError, TemplateAssertionError
from jinja2.utils impo... | [
[
8,
0,
0.0067,
0.01,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0123,
0.0011,
0,
0.66,
0.1429,
436,
0,
1,
0,
0,
436,
0,
0
],
[
1,
0,
0.0134,
0.0011,
0,
0.66,
... | [
"\"\"\"\n jinja2.parser\n ~~~~~~~~~~~~~\n\n Implements the template parser.\n\n :copyright: (c) 2010 by the Jinja Team.\n :license: BSD, see LICENSE for more details.",
"from jinja2 import nodes",
"from jinja2.exceptions import TemplateSyntaxError, TemplateAssertionError",
"from jinja2.utils im... |
# -*- coding: utf-8 -*-
"""
jinja2.visitor
~~~~~~~~~~~~~~
This module implements a visitor for the nodes.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD.
"""
from jinja2.nodes import Node
class NodeVisitor(object):
"""Walks the abstract syntax tree and call visitor functions for every... | [
[
8,
0,
0.069,
0.1034,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1264,
0.0115,
0,
0.66,
0.3333,
990,
0,
1,
0,
0,
990,
0,
0
],
[
3,
0,
0.3333,
0.3563,
0,
0.66,... | [
"\"\"\"\n jinja2.visitor\n ~~~~~~~~~~~~~~\n\n This module implements a visitor for the nodes.\n\n :copyright: (c) 2010 by the Jinja Team.\n :license: BSD.",
"from jinja2.nodes import Node",
"class NodeVisitor(object):\n \"\"\"Walks the abstract syntax tree and call visitor functions for every\... |
from jinja2 import Environment
env = Environment(extensions=['jinja2.ext.i18n'])
env.globals['gettext'] = {
'Hello %(user)s!': 'Hallo %(user)s!'
}.__getitem__
env.globals['ngettext'] = lambda s, p, n: {
'%(count)s user': '%(count)d Benutzer',
'%(count)s users': '%(count)d Benutzer'
}[n == 1 and s or p]
pri... | [
[
1,
0,
0.5,
0.5,
0,
0.66,
0,
436,
0,
1,
0,
0,
436,
0,
0
]
] | [
"from jinja2 import Environment"
] |
from jinja2 import Environment
from jinja2.loaders import FileSystemLoader
env = Environment(loader=FileSystemLoader('templates'))
tmpl = env.get_template('broken.html')
print tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1])
| [
[
1,
0,
0.1429,
0.1429,
0,
0.66,
0,
436,
0,
1,
0,
0,
436,
0,
0
],
[
1,
0,
0.2857,
0.1429,
0,
0.66,
0.25,
456,
0,
1,
0,
0,
456,
0,
0
],
[
14,
0,
0.5714,
0.1429,
0,
0... | [
"from jinja2 import Environment",
"from jinja2.loaders import FileSystemLoader",
"env = Environment(loader=FileSystemLoader('templates'))",
"tmpl = env.get_template('broken.html')",
"print(tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1]))"
] |
from __pypy__ import tproxy
def make_proxy(obj, proxy):
if tproxy is None:
return proxy
def operation_handler(operation, *args, **kwargs):
if operation in ('__getattribute__', '__getattr__'):
return getattr(proxy, args[0])
elif operation == '__setattr__':
proxy.... | [
[
1,
0,
0.0714,
0.0714,
0,
0.66,
0,
683,
0,
1,
0,
0,
683,
0,
0
],
[
2,
0,
0.6429,
0.7857,
0,
0.66,
1,
764,
0,
2,
1,
0,
0,
0,
6
],
[
4,
1,
0.3929,
0.1429,
1,
0.16,
... | [
"from __pypy__ import tproxy",
"def make_proxy(obj, proxy):\n if tproxy is None:\n return proxy\n def operation_handler(operation, *args, **kwargs):\n if operation in ('__getattribute__', '__getattr__'):\n return getattr(proxy, args[0])\n elif operation == '__setattr__':\n ... |
from jinja2 import Environment
from jinja2.loaders import DictLoader
env = Environment(loader=DictLoader({
'child.html': u'''\
{% extends master_layout or 'master.html' %}
{% include helpers = 'helpers.html' %}
{% macro get_the_answer() %}42{% endmacro %}
{% title = 'Hello World' %}
{% block body %}
{{ get_the_ans... | [
[
1,
0,
0.037,
0.037,
0,
0.66,
0,
436,
0,
1,
0,
0,
436,
0,
0
],
[
1,
0,
0.0741,
0.037,
0,
0.66,
0.25,
456,
0,
1,
0,
0,
456,
0,
0
],
[
14,
0,
0.5,
0.7407,
0,
0.66,
... | [
"from jinja2 import Environment",
"from jinja2.loaders import DictLoader",
"env = Environment(loader=DictLoader({\n'child.html': u'''\\\n{% extends master_layout or 'master.html' %}\n{% include helpers = 'helpers.html' %}\n{% macro get_the_answer() %}42{% endmacro %}\n{% title = 'Hello World' %}\n{% block body ... |
from jinja2 import Environment
env = Environment(line_statement_prefix="#", variable_start_string="${", variable_end_string="}")
print env.from_string("""\
<ul>
# for item in range(10)
<li class="${loop.cycle('odd', 'even')}">${item}</li>
# endfor
</ul>\
""").render()
| [
[
1,
0,
0.3333,
0.3333,
0,
0.66,
0,
436,
0,
1,
0,
0,
436,
0,
0
]
] | [
"from jinja2 import Environment"
] |
from jinja2 import Environment
from jinja2.loaders import DictLoader
env = Environment(loader=DictLoader({
'a': '''[A[{% block body %}{% endblock %}]]''',
'b': '''{% extends 'a' %}{% block body %}[B]{% endblock %}''',
'c': '''{% extends 'b' %}{% block body %}###{{ super() }}###{% endblock %}'''
}))
print env.get_te... | [
[
1,
0,
0.0833,
0.0833,
0,
0.66,
0,
436,
0,
1,
0,
0,
436,
0,
0
],
[
1,
0,
0.1667,
0.0833,
0,
0.66,
0.3333,
456,
0,
1,
0,
0,
456,
0,
0
],
[
14,
0,
0.5833,
0.4167,
0,
... | [
"from jinja2 import Environment",
"from jinja2.loaders import DictLoader",
"env = Environment(loader=DictLoader({\n'a': '''[A[{% block body %}{% endblock %}]]''',\n'b': '''{% extends 'a' %}{% block body %}[B]{% endblock %}''',\n'c': '''{% extends 'b' %}{% block body %}###{{ super() }}###{% endblock %}'''\n}))",... |
# -*- coding: utf-8 -*-
"""
RealWorldish Benchmark
~~~~~~~~~~~~~~~~~~~~~~
A more real-world benchmark of Jinja2. Like the other benchmark in the
Jinja2 repository this has no real-world usefulnes (despite the name).
Just go away and ignore it. NOW!
:copyright: (c) 2009 by the Jinja Team.
... | [
[
8,
0,
0.0625,
0.0982,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1161,
0.0089,
0,
0.66,
0.0312,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.125,
0.0089,
0,
0.66,... | [
"\"\"\"\n RealWorldish Benchmark\n ~~~~~~~~~~~~~~~~~~~~~~\n\n A more real-world benchmark of Jinja2. Like the other benchmark in the\n Jinja2 repository this has no real-world usefulnes (despite the name).\n Just go away and ignore it. NOW!",
"import sys",
"from os.path import join, dirname, ab... |
# -*- coding: utf-8 -*-
from rwbench import ROOT
from os.path import join
from django.conf import settings
settings.configure(
TEMPLATE_DIRS=(join(ROOT, 'django'),),
TEMPLATE_LOADERS=(
('django.template.loaders.cached.Loader', (
'django.template.loaders.filesystem.Loader',
)),
)
... | [
[
1,
0,
0.0148,
0.0074,
0,
0.66,
0,
384,
0,
1,
0,
0,
384,
0,
0
],
[
1,
0,
0.0222,
0.0074,
0,
0.66,
0.0588,
79,
0,
1,
0,
0,
79,
0,
0
],
[
1,
0,
0.0296,
0.0074,
0,
0.... | [
"from rwbench import ROOT",
"from os.path import join",
"from django.conf import settings",
"settings.configure(\n TEMPLATE_DIRS=(join(ROOT, 'django'),),\n TEMPLATE_LOADERS=(\n ('django.template.loaders.cached.Loader', (\n 'django.template.loaders.filesystem.Loader',\n )),\n ... |
try:
from cProfile import Profile
except ImportError:
from profile import Profile
from pstats import Stats
from jinja2 import Environment as JinjaEnvironment
context = {
'page_title': 'mitsuhiko\'s benchmark',
'table': [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10) for x in range(1000)]
}
source = ""... | [
[
7,
0,
0.0481,
0.0769,
0,
0.66,
0,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
1,
0.0385,
0.0192,
1,
0.05,
0,
686,
0,
1,
0,
0,
686,
0,
0
],
[
1,
1,
0.0769,
0.0192,
1,
0.05,
... | [
"try:\n from cProfile import Profile\nexcept ImportError:\n from profile import Profile",
" from cProfile import Profile",
" from profile import Profile",
"from pstats import Stats",
"from jinja2 import Environment as JinjaEnvironment",
"context = {\n 'page_title': 'mitsuhiko\\'s benchmark'... |
"""\
This benchmark compares some python templating engines with Jinja 2 so
that we get a picture of how fast Jinja 2 is for a semi real world
template. If a template engine is not installed the test is skipped.\
"""
import sys
import cgi
from timeit import Timer
from jinja2 import Environment as JinjaEnvi... | [
[
8,
0,
0.0069,
0.0115,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0139,
0.0023,
0,
0.66,
0.05,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.0162,
0.0023,
0,
0.66,
... | [
"\"\"\"\\\n This benchmark compares some python templating engines with Jinja 2 so\n that we get a picture of how fast Jinja 2 is for a semi real world\n template. If a template engine is not installed the test is skipped.\\\n\"\"\"",
"import sys",
"import cgi",
"from timeit import Timer",
"from j... |
from setuptools import setup, find_packages
import os
import re
import sys
extra = {}
if sys.version_info >= (3, 0):
extra.update(
use_2to3=True,
)
v = open(os.path.join(os.path.dirname(__file__), 'mako', '__init__.py'))
VERSION = re.compile(r".*__version__ = '(.*?)'", re.S).match(v.read()).group(1)
v... | [
[
1,
0,
0.0147,
0.0147,
0,
0.66,
0,
182,
0,
2,
0,
0,
182,
0,
0
],
[
1,
0,
0.0294,
0.0147,
0,
0.66,
0.1111,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0441,
0.0147,
0,
... | [
"from setuptools import setup, find_packages",
"import os",
"import re",
"import sys",
"extra = {}",
"if sys.version_info >= (3, 0):\n extra.update(\n use_2to3=True,\n )",
" extra.update(\n use_2to3=True,\n )",
"v = open(os.path.join(os.path.dirname(__file__), 'mako', '__init... |
#!python
"""Bootstrap distribute installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from distribute_setup import use_setuptools
use_setuptools()
If you want to require a specific version of se... | [
[
8,
0,
0.0175,
0.0289,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.033,
0.0021,
0,
0.66,
0.027,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0351,
0.0021,
0,
0.66,
... | [
"\"\"\"Bootstrap distribute installation\n\nIf you want to use setuptools in your package's setup.py, just include this\nfile in the same directory with it, and add this to the top of your setup.py::\n\n from distribute_setup import use_setuptools\n use_setuptools()",
"import os",
"import sys",
"import ... |
#!/usr/bin/env python
def render(data):
from mako.template import Template
from mako.lookup import TemplateLookup
lookup = TemplateLookup(["."])
return Template(data, lookup=lookup).render()
def main(argv=None):
from os.path import isfile
from sys import stdin
if argv is None:
im... | [
[
2,
0,
0.1447,
0.1579,
0,
0.66,
0,
24,
0,
1,
1,
0,
0,
0,
3
],
[
1,
1,
0.1053,
0.0263,
1,
0.55,
0,
539,
0,
1,
0,
0,
539,
0,
0
],
[
1,
1,
0.1316,
0.0263,
1,
0.55,
... | [
"def render(data):\n from mako.template import Template\n from mako.lookup import TemplateLookup\n\n lookup = TemplateLookup([\".\"])\n return Template(data, lookup=lookup).render()",
" from mako.template import Template",
" from mako.lookup import TemplateLookup",
" lookup = TemplateLook... |
# mako/pygen.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""utilities for generating and formatting literal Python code."""
import re, string
from StringIO ... | [
[
8,
0,
0.0246,
0.0035,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0316,
0.0035,
0,
0.66,
0.2,
540,
0,
2,
0,
0,
540,
0,
0
],
[
1,
0,
0.0351,
0.0035,
0,
0.66,
... | [
"\"\"\"utilities for generating and formatting literal Python code.\"\"\"",
"import re, string",
"from StringIO import StringIO",
"from mako import exceptions",
"class PythonPrinter(object):\n def __init__(self, stream):\n # indentation counter\n self.indent = 0\n \n # a stack storin... |
# mako/lookup.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import os, stat, posixpath, re
from mako import exceptions, util
from mako.template import Template... | [
[
1,
0,
0.0211,
0.003,
0,
0.66,
0,
688,
0,
4,
0,
0,
688,
0,
0
],
[
1,
0,
0.0242,
0.003,
0,
0.66,
0.2,
682,
0,
2,
0,
0,
682,
0,
0
],
[
1,
0,
0.0272,
0.003,
0,
0.66,
... | [
"import os, stat, posixpath, re",
"from mako import exceptions, util",
"from mako.template import Template",
"try:\n import threading\nexcept:\n import dummy_threading as threading",
" import threading",
" import dummy_threading as threading",
"class TemplateCollection(object):\n \"\"\"Re... |
# mako/parsetree.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""defines the parse tree components for Mako templates."""
from mako import exceptions, ast, u... | [
[
8,
0,
0.0124,
0.0018,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0159,
0.0018,
0,
0.66,
0.05,
682,
0,
4,
0,
0,
682,
0,
0
],
[
1,
0,
0.0177,
0.0018,
0,
0.66,
... | [
"\"\"\"defines the parse tree components for Mako templates.\"\"\"",
"from mako import exceptions, ast, util, filters",
"import re",
"class Node(object):\n \"\"\"base class for a Node in the parse tree.\"\"\"\n def __init__(self, source, lineno, pos, filename):\n self.source = source\n sel... |
# ext/autohandler.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""adds autohandler functionality to Mako templates.
requires that the TemplateLookup class is... | [
[
8,
0,
0.2538,
0.3077,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.4308,
0.0154,
0,
0.66,
0.3333,
204,
0,
3,
0,
0,
204,
0,
0
],
[
2,
0,
0.6615,
0.4154,
0,
0.66... | [
"\"\"\"adds autohandler functionality to Mako templates.\n\nrequires that the TemplateLookup class is used with templates.\n\nusage:\n\n<%!\n from mako.ext.autohandler import autohandler",
"import posixpath, os, re",
"def autohandler(template, context, name='autohandler'):\n lookup = context.lookup\n _... |
# ext/preprocessors.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""preprocessing functions, used with the 'preprocessor'
argument on Template, TemplateLooku... | [
[
8,
0,
0.375,
0.1,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.5,
0.05,
0,
0.66,
0.5,
540,
0,
1,
0,
0,
540,
0,
0
],
[
2,
0,
0.775,
0.4,
0,
0.66,
1,
722... | [
"\"\"\"preprocessing functions, used with the 'preprocessor' \nargument on Template, TemplateLookup\"\"\"",
"import re",
"def convert_comments(text):\n \"\"\"preprocess old style comments.\n \n example:\n \n from mako.ext.preprocessors import convert_comments\n t = Template(..., preprocessor=preproc... |
# ext/babelplugin.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""gettext message extraction via Babel: http://babel.edgewall.org/"""
from StringIO import Str... | [
[
8,
0,
0.0543,
0.0078,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.062,
0.0078,
0,
0.66,
0.1667,
609,
0,
1,
0,
0,
609,
0,
0
],
[
1,
0,
0.0775,
0.0078,
0,
0.66,... | [
"\"\"\"gettext message extraction via Babel: http://babel.edgewall.org/\"\"\"",
"from StringIO import StringIO",
"from babel.messages.extract import extract_python",
"from mako import lexer, parsetree",
"def extract(fileobj, keywords, comment_tags, options):\n \"\"\"Extract messages from Mako templates.\... |
# ext/pygmentplugin.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import re
try:
set
except NameError:
from sets import Set as set
from pygments.lexer... | [
[
1,
0,
0.0654,
0.0093,
0,
0.66,
0,
540,
0,
1,
0,
0,
540,
0,
0
],
[
7,
0,
0.0888,
0.0374,
0,
0.66,
0.0909,
0,
0,
1,
0,
0,
0,
0,
0
],
[
8,
1,
0.0841,
0.0093,
1,
0.71... | [
"import re",
"try:\n set\nexcept NameError:\n from sets import Set as set",
" set",
" from sets import Set as set",
"from pygments.lexers.web import \\\n HtmlLexer, XmlLexer, JavascriptLexer, CssLexer",
"from pygments.lexers.agile import PythonLexer",
"from pygments.lexer import Lexer, D... |
# ext/turbogears.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import re, inspect
from mako.lookup import TemplateLookup
from mako.template import Template
cl... | [
[
1,
0,
0.125,
0.0179,
0,
0.66,
0,
540,
0,
2,
0,
0,
540,
0,
0
],
[
1,
0,
0.1429,
0.0179,
0,
0.66,
0.3333,
258,
0,
1,
0,
0,
258,
0,
0
],
[
1,
0,
0.1607,
0.0179,
0,
0... | [
"import re, inspect",
"from mako.lookup import TemplateLookup",
"from mako.template import Template",
"class TGPlugin(object):\n \"\"\"TurboGears compatible Template Plugin.\"\"\"\n\n def __init__(self, extra_vars_func=None, options=None, extension='mak'):\n self.extra_vars_func = extra_vars_func... |
# mako/codegen.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""provides functionality for rendering a parsetree constructing into module source code."""
impo... | [
[
8,
0,
0.0067,
0.001,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0086,
0.001,
0,
0.66,
0.1111,
654,
0,
1,
0,
0,
654,
0,
0
],
[
1,
0,
0.0095,
0.001,
0,
0.66,
... | [
"\"\"\"provides functionality for rendering a parsetree constructing into module source code.\"\"\"",
"import time",
"import re",
"from mako.pygen import PythonPrinter",
"from mako import util, ast, parsetree, filters, exceptions",
"MAGIC_NUMBER = 6",
"def compile(node, \n uri, \n ... |
# mako/ast.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""utilities for analyzing expressions and blocks of Python
code, as well as generating Python from A... | [
[
8,
0,
0.0524,
0.014,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0699,
0.007,
0,
0.66,
0.1429,
682,
0,
3,
0,
0,
682,
0,
0
],
[
1,
0,
0.0769,
0.007,
0,
0.66,
... | [
"\"\"\"utilities for analyzing expressions and blocks of Python \ncode, as well as generating Python from AST nodes\"\"\"",
"from mako import exceptions, pyparser, util",
"import re",
"class PythonCode(object):\n \"\"\"represents information about a string containing Python code\"\"\"\n def __init__(sel... |
# mako/exceptions.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""exception classes"""
import traceback, sys, re
from mako import util
class MakoException(E... | [
[
8,
0,
0.0228,
0.0033,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0293,
0.0033,
0,
0.66,
0.0769,
423,
0,
3,
0,
0,
423,
0,
0
],
[
1,
0,
0.0326,
0.0033,
0,
0.66... | [
"\"\"\"exception classes\"\"\"",
"import traceback, sys, re",
"from mako import util",
"class MakoException(Exception):\n pass",
"class RuntimeException(MakoException):\n pass",
"def _format_filepos(lineno, pos, filename):\n if filename is None:\n return \" at line: %d char: %d\" % (lineno... |
# mako/__init__.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
__version__ = '0.4.1'
| [
[
14,
0,
0.8889,
0.1111,
0,
0.66,
0,
162,
1,
0,
0,
0,
0,
3,
0
]
] | [
"__version__ = '0.4.1'"
] |
# mako/template.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""Provides the Template class, a facade for parsing, generating and executing
template strings, ... | [
[
8,
0,
0.014,
0.0037,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0187,
0.0019,
0,
0.66,
0.0909,
824,
0,
1,
0,
0,
824,
0,
0
],
[
1,
0,
0.0205,
0.0019,
0,
0.66,... | [
"\"\"\"Provides the Template class, a facade for parsing, generating and executing\ntemplate strings, as well as template runtime operations.\"\"\"",
"from mako.lexer import Lexer",
"from mako import runtime, util, exceptions, codegen",
"import imp, os, re, shutil, stat, sys, tempfile, time, types, weakref",
... |
# mako/filters.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import re, urllib, htmlentitydefs, codecs
from StringIO import StringIO
from mako import util
xm... | [
[
1,
0,
0.0426,
0.0053,
0,
0.66,
0,
540,
0,
4,
0,
0,
540,
0,
0
],
[
1,
0,
0.0479,
0.0053,
0,
0.66,
0.0435,
609,
0,
1,
0,
0,
609,
0,
0
],
[
1,
0,
0.0532,
0.0053,
0,
... | [
"import re, urllib, htmlentitydefs, codecs",
"from StringIO import StringIO",
"from mako import util",
"xml_escapes = {\n '&' : '&',\n '>' : '>', \n '<' : '<', \n '\"' : '"', # also " in html-only\n \"'\" : ''' # also ' in html-only \n}",
"def legacy_html_esca... |
# mako/_ast_util.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""
ast
~~~
The `ast` module helps Python applications to process trees of the Pyth... | [
[
8,
0,
0.0232,
0.031,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0393,
0.0012,
0,
0.66,
0.0385,
709,
0,
1,
0,
0,
709,
0,
0
],
[
14,
0,
0.0447,
0.0048,
0,
0.66... | [
"\"\"\"\n ast\n ~~~\n\n The `ast` module helps Python applications to process trees of the Python\n abstract syntax grammar. The abstract syntax itself might change with\n each Python release; this module helps to find out programmatically what\n the current grammar looks like and allows modifica... |
# mako/cache.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from mako import exceptions
cache = None
class BeakerMissing(object):
def get_cache(self, name... | [
[
1,
0,
0.0565,
0.0081,
0,
0.66,
0,
682,
0,
1,
0,
0,
682,
0,
0
],
[
14,
0,
0.0726,
0.0081,
0,
0.66,
0.3333,
419,
1,
0,
0,
0,
0,
9,
0
],
[
3,
0,
0.0968,
0.0242,
0,
0... | [
"from mako import exceptions",
"cache = None",
"class BeakerMissing(object):\n def get_cache(self, name, **kwargs):\n raise exceptions.RuntimeException(\"the Beaker package is required to use cache functionality.\")",
" def get_cache(self, name, **kwargs):\n raise exceptions.RuntimeExcepti... |
# basic.py - basic benchmarks adapted from Genshi
# Copyright (C) 2006 Edgewall Software
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the ... | [
[
1,
0,
0.1925,
0.0062,
0,
0.66,
0,
934,
0,
1,
0,
0,
934,
0,
0
],
[
1,
0,
0.1988,
0.0062,
0,
0.66,
0.0714,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.205,
0.0062,
0,
0... | [
"from cgi import escape",
"import os",
"from StringIO import StringIO",
"import sys",
"import timeit",
"__all__ = ['mako', 'mako_inheritance', 'cheetah', 'django', 'myghty', 'genshi', 'kid']",
"def genshi(dirname, verbose=False):\n from genshi.template import TemplateLoader\n loader = TemplateLoad... |
from django.template import Library, Node, resolve_variable
from django.utils.html import escape
register = Library()
def greeting(name):
return 'Hello, %s!' % escape(name)
greeting = register.simple_tag(greeting)
| [
[
1,
0,
0.125,
0.125,
0,
0.66,
0,
213,
0,
3,
0,
0,
213,
0,
0
],
[
1,
0,
0.25,
0.125,
0,
0.66,
0.25,
535,
0,
1,
0,
0,
535,
0,
0
],
[
14,
0,
0.5,
0.125,
0,
0.66,
... | [
"from django.template import Library, Node, resolve_variable",
"from django.utils.html import escape",
"register = Library()",
"def greeting(name):\n return 'Hello, %s!' % escape(name)",
" return 'Hello, %s!' % escape(name)",
"greeting = register.simple_tag(greeting)"
] |
#!/usr/bin/python
import cgi, re, os, posixpath, mimetypes
from mako.lookup import TemplateLookup
from mako import exceptions
root = './'
port = 8000
error_style = 'html' # select 'text' for plaintext error reporting
lookup = TemplateLookup(directories=[root + 'templates', root + 'htdocs'], filesystem_checks=True, m... | [
[
1,
0,
0.0385,
0.0128,
0,
0.66,
0,
934,
0,
5,
0,
0,
934,
0,
0
],
[
1,
0,
0.0513,
0.0128,
0,
0.66,
0.0833,
258,
0,
1,
0,
0,
258,
0,
0
],
[
1,
0,
0.0641,
0.0128,
0,
... | [
"import cgi, re, os, posixpath, mimetypes",
"from mako.lookup import TemplateLookup",
"from mako import exceptions",
"root = './'",
"port = 8000",
"error_style = 'html' # select 'text' for plaintext error reporting",
"lookup = TemplateLookup(directories=[root + 'templates', root + 'htdocs'], filesystem_... |
from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 5
_modified_time = 1267565427.7968459
_template_filename='/Users/classic/dev/mako/test/templates/modtest.html'
_template_uri='/modtest.html'
_template_cache=cache.Cache(__name__, _m... | [
[
1,
0,
0.04,
0.04,
0,
0.66,
0,
682,
0,
3,
0,
0,
682,
0,
0
],
[
14,
0,
0.08,
0.04,
0,
0.66,
0.0909,
67,
7,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.12,
0.04,
0,
0.66,
0.1... | [
"from mako import runtime, filters, cache",
"UNDEFINED = runtime.UNDEFINED",
"__M_dict_builtin = dict",
"__M_locals_builtin = locals",
"_magic_number = 5",
"_modified_time = 1267565427.7968459",
"_template_filename='/Users/classic/dev/mako/test/templates/modtest.html'",
"_template_uri='/modtest.html'"... |
from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 5
_modified_time = 1267565427.799504
_template_filename='/Users/classic/dev/mako/test/templates/subdir/modtest.html'
_template_uri='/subdir/modtest.html'
_template_cache=cache.Cache... | [
[
1,
0,
0.04,
0.04,
0,
0.66,
0,
682,
0,
3,
0,
0,
682,
0,
0
],
[
14,
0,
0.08,
0.04,
0,
0.66,
0.0909,
67,
7,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.12,
0.04,
0,
0.66,
0.1... | [
"from mako import runtime, filters, cache",
"UNDEFINED = runtime.UNDEFINED",
"__M_dict_builtin = dict",
"__M_locals_builtin = locals",
"_magic_number = 5",
"_modified_time = 1267565427.799504",
"_template_filename='/Users/classic/dev/mako/test/templates/subdir/modtest.html'",
"_template_uri='/subdir/m... |
def foo1(context):
context.write("this is foo1.")
return ''
def foo2(context, x):
context.write("this is foo2, x is " + x)
return '' | [
[
2,
0,
0.2857,
0.4286,
0,
0.66,
0,
331,
0,
1,
1,
0,
0,
0,
1
],
[
8,
1,
0.2857,
0.1429,
1,
0.18,
0,
837,
3,
1,
0,
0,
0,
0,
1
],
[
13,
1,
0.4286,
0.1429,
1,
0.18,
... | [
"def foo1(context):\n context.write(\"this is foo1.\")\n return ''",
" context.write(\"this is foo1.\")",
" return ''",
"def foo2(context, x):\n context.write(\"this is foo2, x is \" + x)\n return ''",
" context.write(\"this is foo2, x is \" + x)",
" return ''"
] |
import re
def flatten_result(result):
return re.sub(r'[\s\r\n]+', ' ', result).strip()
def result_lines(result):
return [x.strip() for x in re.split(r'\r?\n', re.sub(r' +', ' ', result)) if x.strip() != ''] | [
[
1,
0,
0.1429,
0.1429,
0,
0.66,
0,
540,
0,
1,
0,
0,
540,
0,
0
],
[
2,
0,
0.5,
0.2857,
0,
0.66,
0.5,
977,
0,
1,
1,
0,
0,
0,
2
],
[
13,
1,
0.5714,
0.1429,
1,
0.86,
... | [
"import re",
"def flatten_result(result):\n return re.sub(r'[\\s\\r\\n]+', ' ', result).strip()",
" return re.sub(r'[\\s\\r\\n]+', ' ', result).strip()",
"def result_lines(result):\n return [x.strip() for x in re.split(r'\\r?\\n', re.sub(r' +', ' ', result)) if x.strip() != '']",
" return [x.str... |
import unittest
import doctest
def test_suite():
flags = doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE
return unittest.TestSuite((
doctest.DocFileSuite('test_request.txt', optionflags=flags),
doctest.DocFileSuite('test_response.txt', optionflags=flags),
doctest.DocFileSuite('test_dec.tx... | [
[
1,
0,
0.0588,
0.0588,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.1176,
0.0588,
0,
0.66,
0.3333,
614,
0,
1,
0,
0,
614,
0,
0
],
[
2,
0,
0.5294,
0.6471,
0,
0.... | [
"import unittest",
"import doctest",
"def test_suite():\n flags = doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE\n return unittest.TestSuite((\n doctest.DocFileSuite('test_request.txt', optionflags=flags),\n doctest.DocFileSuite('test_response.txt', optionflags=flags),\n doctest.DocFil... |
# -*- coding: utf-8 -*-
from webob import __version__
extensions = ['sphinx.ext.autodoc']
source_suffix = '.txt' # The suffix of source filenames.
master_doc = 'index' # The master toctree document.
project = 'WebOb'
copyright = '2011, Ian Bicking and contributors'
version = release = __version__
exclude_patterns =... | [
[
1,
0,
0.0811,
0.027,
0,
0.66,
0,
787,
0,
1,
0,
0,
787,
0,
0
],
[
14,
0,
0.1351,
0.027,
0,
0.66,
0.1,
866,
0,
0,
0,
0,
0,
5,
0
],
[
14,
0,
0.1892,
0.027,
0,
0.66,
... | [
"from webob import __version__",
"extensions = ['sphinx.ext.autodoc']",
"source_suffix = '.txt' # The suffix of source filenames.",
"master_doc = 'index' # The master toctree document.",
"project = 'WebOb'",
"copyright = '2011, Ian Bicking and contributors'",
"version = release = __version__",
"exclud... |
from collections import MutableMapping
from webob.compat import (
iteritems_,
string_types,
)
from webob.multidict import MultiDict
__all__ = ['ResponseHeaders', 'EnvironHeaders']
class ResponseHeaders(MultiDict):
"""
Dictionary view on the response headerlist.
Keys are normalized for ... | [
[
1,
0,
0.0063,
0.0063,
0,
0.66,
0,
193,
0,
1,
0,
0,
193,
0,
0
],
[
1,
0,
0.0222,
0.0253,
0,
0.66,
0.1111,
218,
0,
2,
0,
0,
218,
0,
0
],
[
1,
0,
0.038,
0.0063,
0,
0... | [
"from collections import MutableMapping",
"from webob.compat import (\n iteritems_,\n string_types,\n )",
"from webob.multidict import MultiDict",
"__all__ = ['ResponseHeaders', 'EnvironHeaders']",
"class ResponseHeaders(MultiDict):\n \"\"\"\n Dictionary view on the response headerlist.\n... |
# code stolen from "six"
import sys
import types
# True if we are running on Python 3.
PY3 = sys.version_info[0] == 3
if PY3: # pragma: no cover
string_types = str,
integer_types = int,
class_types = type,
text_type = str
long = int
else:
string_types = basestring,
integer_types = (int, l... | [
[
1,
0,
0.0229,
0.0076,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.0305,
0.0076,
0,
0.66,
0.0833,
209,
0,
1,
0,
0,
209,
0,
0
],
[
14,
0,
0.0534,
0.0076,
0,
... | [
"import sys",
"import types",
"PY3 = sys.version_info[0] == 3",
"if PY3: # pragma: no cover\n string_types = str,\n integer_types = int,\n class_types = type,\n text_type = str\n long = int\nelse:\n string_types = basestring,",
" string_types = str,",
" integer_types = int,",
" ... |
import collections
from datetime import (
date,
datetime,
timedelta,
)
import re
import string
import time
from webob.compat import (
PY3,
text_type,
bytes_,
text_,
native_,
string_types,
)
__all__ = ['Cookie']
_marker = object()
class RequestCookies(collections.MutableM... | [
[
1,
0,
0.0027,
0.0027,
0,
0.66,
0,
193,
0,
1,
0,
0,
193,
0,
0
],
[
1,
0,
0.0135,
0.0135,
0,
0.66,
0.0189,
426,
0,
3,
0,
0,
426,
0,
0
],
[
1,
0,
0.0216,
0.0027,
0,
... | [
"import collections",
"from datetime import (\n date,\n datetime,\n timedelta,\n )",
"import re",
"import string",
"import time",
"from webob.compat import (\n PY3,\n text_type,\n bytes_,\n text_,\n native_,\n string_types,\n )",
"__all__ = ['Cookie']",
"_marker = obje... |
"""
Decorators to wrap functions to make them WSGI applications.
The main decorator :class:`wsgify` turns a function into a WSGI
application (while also allowing normal calling of the method with an
instantiated request).
"""
from webob.compat import (
bytes_,
text_type,
)
from webob.request import Reque... | [
[
8,
0,
0.0134,
0.0234,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0351,
0.0134,
0,
0.66,
0.1429,
218,
0,
2,
0,
0,
218,
0,
0
],
[
1,
0,
0.0468,
0.0033,
0,
0.66... | [
"\"\"\"\nDecorators to wrap functions to make them WSGI applications.\n\nThe main decorator :class:`wsgify` turns a function into a WSGI\napplication (while also allowing normal calling of the method with an\ninstantiated request).\n\"\"\"",
"from webob.compat import (\n bytes_,\n text_type,\n )",
"fro... |
import errno
import sys
import re
try:
import httplib
except ImportError: # pragma: no cover
import http.client as httplib
from webob.compat import url_quote
import socket
from webob import exc
from webob.compat import PY3
__all__ = ['send_request_app', 'SendRequest']
class SendRequest:
"""
Sends the... | [
[
1,
0,
0.0055,
0.0055,
0,
0.66,
0,
546,
0,
1,
0,
0,
546,
0,
0
],
[
1,
0,
0.011,
0.0055,
0,
0.66,
0.0833,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.0165,
0.0055,
0,
0... | [
"import errno",
"import sys",
"import re",
"try:\n import httplib\nexcept ImportError: # pragma: no cover\n import http.client as httplib",
" import httplib",
" import http.client as httplib",
"from webob.compat import url_quote",
"import socket",
"from webob import exc",
"from webob.c... |
# (c) 2005 Ian Bicking and contributors; written for Paste
# (http://pythonpaste.org) Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license.php
"""
Gives a multi-value dictionary object (MultiDict) plus several wrappers
"""
from collections import MutableMapping
import warnings
from webob.c... | [
[
8,
0,
0.0101,
0.0061,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0142,
0.002,
0,
0.66,
0.1,
193,
0,
1,
0,
0,
193,
0,
0
],
[
1,
0,
0.0182,
0.002,
0,
0.66,
... | [
"\"\"\"\nGives a multi-value dictionary object (MultiDict) plus several wrappers\n\"\"\"",
"from collections import MutableMapping",
"import warnings",
"from webob.compat import (\n PY3,\n iteritems_,\n itervalues_,\n url_encode,\n )",
"__all__ = ['MultiDict', 'NestedMultiDict', 'NoVars', 'Ge... |
import mimetypes
import os
from webob import exc
from webob.dec import wsgify
from webob.response import Response
__all__ = [
'FileApp', 'DirectoryApp',
]
mimetypes._winreg = None # do not load mimetypes from windows registry
mimetypes.add_type('text/javascript', '.js') # stdlib default is application/x-javascri... | [
[
1,
0,
0.006,
0.006,
0,
0.66,
0,
583,
0,
1,
0,
0,
583,
0,
0
],
[
1,
0,
0.0119,
0.006,
0,
0.66,
0.0833,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0238,
0.006,
0,
0.66... | [
"import mimetypes",
"import os",
"from webob import exc",
"from webob.dec import wsgify",
"from webob.response import Response",
"__all__ = [\n 'FileApp', 'DirectoryApp',\n]",
"mimetypes._winreg = None # do not load mimetypes from windows registry",
"mimetypes.add_type('text/javascript', '.js') # s... |
import binascii
import cgi
import io
import os
import re
import sys
import tempfile
import mimetypes
try:
import simplejson as json
except ImportError:
import json
import warnings
from webob.acceptparse import (
AcceptLanguage,
AcceptCharset,
MIMEAccept,
MIMENilAccept,
NoAccept,
accept_... | [
[
1,
0,
0.0006,
0.0006,
0,
0.66,
0,
984,
0,
1,
0,
0,
984,
0,
0
],
[
1,
0,
0.0012,
0.0006,
0,
0.66,
0.0238,
934,
0,
1,
0,
0,
934,
0,
0
],
[
1,
0,
0.0017,
0.0006,
0,
... | [
"import binascii",
"import cgi",
"import io",
"import os",
"import re",
"import sys",
"import tempfile",
"import mimetypes",
"try:\n import simplejson as json\nexcept ImportError:\n import json",
" import simplejson as json",
" import json",
"import warnings",
"from webob.acceptp... |
from base64 import b64encode
from datetime import (
datetime,
timedelta,
)
from hashlib import md5
import re
import struct
import zlib
try:
import simplejson as json
except ImportError:
import json
from webob.byterange import ContentRange
from webob.cachecontrol import (
CacheControl,
seri... | [
[
1,
0,
0.0008,
0.0008,
0,
0.66,
0,
177,
0,
1,
0,
0,
177,
0,
0
],
[
1,
0,
0.0027,
0.0031,
0,
0.66,
0.0345,
426,
0,
2,
0,
0,
426,
0,
0
],
[
1,
0,
0.0046,
0.0008,
0,
... | [
"from base64 import b64encode",
"from datetime import (\n datetime,\n timedelta,\n )",
"from hashlib import md5",
"import re",
"import struct",
"import zlib",
"try:\n import simplejson as json\nexcept ImportError:\n import json",
" import simplejson as json",
" import json",
"... |
"""
Represents the Cache-Control header
"""
import re
class UpdateDict(dict):
"""
Dict that has a callback on all updates
"""
# these are declared as class attributes so that
# we don't need to override constructor just to
# set some defaults
updated = None
updated_args = None
def ... | [
[
8,
0,
0.0087,
0.0131,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0175,
0.0044,
0,
0.66,
0.125,
540,
0,
1,
0,
0,
540,
0,
0
],
[
3,
0,
0.1376,
0.2271,
0,
0.66,... | [
"\"\"\"\nRepresents the Cache-Control header\n\"\"\"",
"import re",
"class UpdateDict(dict):\n \"\"\"\n Dict that has a callback on all updates\n \"\"\"\n # these are declared as class attributes so that\n # we don't need to override constructor just to\n # set some defaults\n updated = Non... |
import warnings
from webob.compat import (
escape,
string_types,
text_,
text_type,
)
from webob.headers import _trans_key
def html_escape(s):
"""HTML-escape a string or object
This converts any non-string objects passed into it to strings
(actually, using ``unicode()``). All values ... | [
[
1,
0,
0.0076,
0.0076,
0,
0.66,
0,
358,
0,
1,
0,
0,
358,
0,
0
],
[
1,
0,
0.0417,
0.0455,
0,
0.66,
0.1429,
218,
0,
4,
0,
0,
218,
0,
0
],
[
1,
0,
0.0758,
0.0076,
0,
... | [
"import warnings",
"from webob.compat import (\n escape,\n string_types,\n text_,\n text_type,\n )",
"from webob.headers import _trans_key",
"def html_escape(s):\n \"\"\"HTML-escape a string or object\n\n This converts any non-string objects passed into it to strings\n (actually, using... |
from datetime import (
date,
datetime,
)
import re
from webob.byterange import (
ContentRange,
Range,
)
from webob.compat import (
PY3,
text_type,
)
from webob.datetime_utils import (
parse_date,
serialize_date,
)
from webob.util import (
header_docstring,
wa... | [
[
1,
0,
0.0074,
0.0118,
0,
0.66,
0,
426,
0,
2,
0,
0,
426,
0,
0
],
[
1,
0,
0.0177,
0.0029,
0,
0.66,
0.0278,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.028,
0.0118,
0,
0... | [
"from datetime import (\n date,\n datetime,\n )",
"import re",
"from webob.byterange import (\n ContentRange,\n Range,\n )",
"from webob.compat import (\n PY3,\n text_type,\n )",
"from webob.datetime_utils import (\n parse_date,\n serialize_date,\n )",
"from webob.util ... |
"""
Parses a variety of ``Accept-*`` headers.
These headers generally take the form of::
value1; q=0.5, value2; q=0
Where the ``q`` parameter is optional. In theory other parameters
exists, but this ignores them.
"""
import re
from webob.headers import _trans_name as header_to_key
from webob.util import (
... | [
[
8,
0,
0.0162,
0.0295,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0354,
0.0029,
0,
0.66,
0.0714,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.0413,
0.0029,
0,
0.66... | [
"\"\"\"\nParses a variety of ``Accept-*`` headers.\n\nThese headers generally take the form of::\n\n value1; q=0.5, value2; q=0\n\nWhere the ``q`` parameter is optional. In theory other parameters",
"import re",
"from webob.headers import _trans_name as header_to_key",
"from webob.util import (\n heade... |
import calendar
from datetime import (
date,
datetime,
timedelta,
tzinfo,
)
from email.utils import (
formatdate,
mktime_tz,
parsedate_tz,
)
import time
from webob.compat import (
integer_types,
long,
native_,
text_type,
)
__all__ = [
'UTC', 'timedelta_to... | [
[
1,
0,
0.0085,
0.0085,
0,
0.66,
0,
917,
0,
1,
0,
0,
917,
0,
0
],
[
1,
0,
0.047,
0.0513,
0,
0.66,
0.05,
426,
0,
4,
0,
0,
426,
0,
0
],
[
1,
0,
0.1026,
0.0427,
0,
0.6... | [
"import calendar",
"from datetime import (\n date,\n datetime,\n timedelta,\n tzinfo,\n )",
"from email.utils import (\n formatdate,\n mktime_tz,\n parsedate_tz,\n )",
"import time",
"from webob.compat import (\n integer_types,\n long,\n native_,\n text_type,\n )",
... |
"""
Does parsing of ETag-related headers: If-None-Matches, If-Matches
Also If-Range parsing
"""
from webob.datetime_utils import (
parse_date,
serialize_date,
)
from webob.descriptors import _rx_etag
from webob.util import (
header_docstring,
warn_deprecation,
)
__all__ = ['AnyETag', 'NoETag... | [
[
8,
0,
0.0159,
0.0265,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.045,
0.0212,
0,
0.66,
0.0714,
676,
0,
2,
0,
0,
676,
0,
0
],
[
1,
0,
0.0582,
0.0053,
0,
0.66,... | [
"\"\"\"\nDoes parsing of ETag-related headers: If-None-Matches, If-Matches\n\nAlso If-Range parsing\n\"\"\"",
"from webob.datetime_utils import (\n parse_date,\n serialize_date,\n )",
"from webob.descriptors import _rx_etag",
"from webob.util import (\n header_docstring,\n warn_deprecation,\n ... |
from webob.datetime_utils import *
from webob.request import *
from webob.response import *
from webob.util import html_escape
__all__ = [
'Request', 'LegacyRequest', 'Response', 'UTC', 'day', 'week', 'hour',
'minute', 'second', 'month', 'year', 'html_escape'
]
BaseRequest.ResponseClass = Response
__version_... | [
[
1,
0,
0.0769,
0.0769,
0,
0.66,
0,
676,
0,
1,
0,
0,
676,
0,
0
],
[
1,
0,
0.1538,
0.0769,
0,
0.66,
0.1667,
900,
0,
1,
0,
0,
900,
0,
0
],
[
1,
0,
0.2308,
0.0769,
0,
... | [
"from webob.datetime_utils import *",
"from webob.request import *",
"from webob.response import *",
"from webob.util import html_escape",
"__all__ = [\n 'Request', 'LegacyRequest', 'Response', 'UTC', 'day', 'week', 'hour',\n 'minute', 'second', 'month', 'year', 'html_escape'\n]",
"BaseRequest.Respo... |
"""
HTTP Exception
--------------
This module processes Python exceptions that relate to HTTP exceptions
by defining a set of exceptions, all subclasses of HTTPException.
Each exception, in addition to being a Python exception that can be
raised and caught, is also a WSGI application and ``webob.Response``
object.
Thi... | [
[
8,
0,
0.0724,
0.144,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1457,
0.0009,
0,
0.66,
0.0143,
890,
0,
1,
0,
0,
890,
0,
0
],
[
1,
0,
0.1466,
0.0009,
0,
0.66,... | [
"\"\"\"\nHTTP Exception\n--------------\nThis module processes Python exceptions that relate to HTTP exceptions\nby defining a set of exceptions, all subclasses of HTTPException.\nEach exception, in addition to being a Python exception that can be\nraised and caught, is also a WSGI application and ``webob.Response`... |
import re
__all__ = ['Range', 'ContentRange']
_rx_range = re.compile('bytes *= *(\d*) *- *(\d*)', flags=re.I)
_rx_content_range = re.compile(r'bytes (?:(\d+)-(\d+)|[*])/(?:(\d+)|[*])')
class Range(object):
"""
Represents the Range header.
"""
def __init__(self, start, end):
assert end is... | [
[
1,
0,
0.0063,
0.0063,
0,
0.66,
0,
540,
0,
1,
0,
0,
540,
0,
0
],
[
14,
0,
0.0187,
0.0063,
0,
0.66,
0.1667,
272,
0,
0,
0,
0,
0,
5,
0
],
[
14,
0,
0.0312,
0.0063,
0,
... | [
"import re",
"__all__ = ['Range', 'ContentRange']",
"_rx_range = re.compile('bytes *= *(\\d*) *- *(\\d*)', flags=re.I)",
"_rx_content_range = re.compile(r'bytes (?:(\\d+)-(\\d+)|[*])/(?:(\\d+)|[*])')",
"class Range(object):\n \"\"\"\n Represents the Range header.\n \"\"\"\n\n def __init__(se... |
from setuptools import setup
version = '1.2.2'
testing_extras = ['nose']
docs_extras = ['Sphinx']
setup(
name='WebOb',
version=version,
description="WSGI request and response object",
long_description="""\
WebOb provides wrappers around the WSGI request environment, and an
object to help create WSGI... | [
[
1,
0,
0.0172,
0.0172,
0,
0.66,
0,
182,
0,
1,
0,
0,
182,
0,
0
],
[
14,
0,
0.0517,
0.0172,
0,
0.66,
0.25,
623,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.0862,
0.0172,
0,
0.... | [
"from setuptools import setup",
"version = '1.2.2'",
"testing_extras = ['nose']",
"docs_extras = ['Sphinx']",
"setup(\n name='WebOb',\n version=version,\n description=\"WSGI request and response object\",\n long_description=\"\"\"\\\nWebOb provides wrappers around the WSGI request environment, a... |
import os, sys
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
import pkg_resources
pkg_resources.require('WebOb')
| [
[
1,
0,
0.25,
0.25,
0,
0.66,
0,
688,
0,
2,
0,
0,
688,
0,
0
],
[
8,
0,
0.5,
0.25,
0,
0.66,
0.3333,
368,
3,
2,
0,
0,
0,
0,
3
],
[
1,
0,
0.75,
0.25,
0,
0.66,
0.666... | [
"import os, sys",
"sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))",
"import pkg_resources",
"pkg_resources.require('WebOb')"
] |
#!/usr/bin/env python
from webob.response import Response
def make_middleware(app):
from repoze.profile.profiler import AccumulatingProfileMiddleware
return AccumulatingProfileMiddleware(
app,
log_filename='/tmp/profile.log',
discard_first_request=True,
flush_at_shutdown=True,
... | [
[
1,
0,
0.04,
0.02,
0,
0.66,
0,
759,
0,
1,
0,
0,
759,
0,
0
],
[
2,
0,
0.15,
0.16,
0,
0.66,
0.3333,
512,
0,
1,
1,
0,
0,
0,
1
],
[
1,
1,
0.1,
0.02,
1,
0.75,
0,
... | [
"from webob.response import Response",
"def make_middleware(app):\n from repoze.profile.profiler import AccumulatingProfileMiddleware\n return AccumulatingProfileMiddleware(\n app,\n log_filename='/tmp/profile.log',\n discard_first_request=True,\n flush_at_shutdown=True,\n ... |
#
| [] | [] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# ... | [
[
1,
0,
0.1807,
0.012,
0,
0.66,
0,
662,
0,
1,
0,
0,
662,
0,
0
],
[
1,
0,
0.1928,
0.012,
0,
0.66,
0.125,
614,
0,
1,
0,
0,
614,
0,
0
],
[
1,
0,
0.2048,
0.012,
0,
0.66... | [
"from distutils.cmd import Command",
"import doctest",
"from glob import glob",
"import os",
"try:\n from setuptools import setup\nexcept ImportError:\n from distutils.core import setup",
" from setuptools import setup",
" from distutils.core import setup",
"import sys",
"sys.path.append... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# ... | [
[
1,
0,
0.4545,
0.0303,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.4848,
0.0303,
0,
0.66,
0.1111,
848,
0,
1,
0,
0,
848,
0,
0
],
[
1,
0,
0.5152,
0.0303,
0,
... | [
"import os",
"import pickle",
"from pprint import pprint",
"import sys",
"import babel",
"dirname = os.path.join(os.path.dirname(babel.__file__))",
"filename = os.path.join(dirname, 'global.dat')",
"fileobj = open(filename, 'rb')",
"try:\n data = pickle.load(fileobj)\nfinally:\n fileobj.close(... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# ... | [
[
1,
0,
0.3333,
0.0222,
0,
0.66,
0,
323,
0,
1,
0,
0,
323,
0,
0
],
[
1,
0,
0.3556,
0.0222,
0,
0.66,
0.2,
276,
0,
1,
0,
0,
276,
0,
0
],
[
1,
0,
0.3778,
0.0222,
0,
0.6... | [
"from optparse import OptionParser",
"from pprint import pprint",
"import sys",
"from babel.localedata import load, LocaleDataDict",
"def main():\n parser = OptionParser(usage='%prog [options] locale [path]')\n parser.add_option('--noinherit', action='store_false', dest='inherit',\n ... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0171,
0.0085,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0227,
0.0009,
0,
0.66,
0.0294,
777,
0,
1,
0,
0,
777,
0,
0
],
[
1,
0,
0.0237,
0.0009,
0,
0.66... | [
"\"\"\"Locale dependent formatting and parsing of dates and times.\n\nThe default locale for the functions in this module is determined by the\nfollowing environment variables, in that order:\n\n * ``LC_TIME``,\n * ``LC_ALL``, and\n * ``LANG``",
"from __future__ import division",
"from datetime import date, dat... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0766,
0.0239,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0957,
0.0048,
0,
0.66,
0.0667,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.1005,
0.0048,
0,
0.66... | [
"\"\"\"Low-level locale data access.\n\n:note: The `Locale` class, which uses this module under the hood, provides a\n more convenient interface for accessing the locale data.\n\"\"\"",
"import os",
"import pickle",
"try:\n import threading\nexcept ImportError:\n import dummy_threading as threadin... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0316,
0.0023,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0361,
0.0023,
0,
0.66,
0.0476,
540,
0,
1,
0,
0,
540,
0,
0
],
[
14,
0,
0.0418,
0.0045,
0,
0.6... | [
"\"\"\"CLDR Plural support. See UTS #35. EXPERIMENTAL\"\"\"",
"import re",
"__all__ = ['PluralRule', 'RuleError', 'to_gettext', 'to_javascript',\n 'to_python']",
"__docformat__ = 'restructuredtext en'",
"_plural_tags = ('zero', 'one', 'two', 'few', 'many', 'other')",
"_fallback_tag = 'other'",... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0173,
0.0012,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0198,
0.0012,
0,
0.66,
0.0769,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0211,
0.0012,
0,
0.66... | [
"\"\"\"Core locale representation and locale data access.\"\"\"",
"import os",
"import pickle",
"from babel import localedata",
"__all__ = ['UnknownLocaleError', 'Locale', 'default_locale', 'negotiate_locale',\n 'parse_locale']",
"__docformat__ = 'restructuredtext en'",
"_global_data = None",
... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0347,
0.0126,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0442,
0.0021,
0,
0.66,
0.0714,
426,
0,
1,
0,
0,
426,
0,
0
],
[
1,
0,
0.0463,
0.0021,
0,
0.66... | [
"\"\"\"Reading and writing of files in the ``gettext`` PO (portable object)\nformat.\n\n:see: `The Format of PO Files\n <http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files>`_\n\"\"\"",
"from datetime import datetime",
"import os",
"import re",
"from babel.messages.catalog import Catalog,... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0327,
0.0164,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0436,
0.0018,
0,
0.66,
0.0556,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0455,
0.0018,
0,
0.66... | [
"\"\"\"Basic infrastructure for extracting localizable messages from source files.\n\nThis module defines an extensible system for collecting localizable message\nstrings from a variety of sources. A native extractor for Python source files\nis builtin, extractors for other sources can be added using very simple pl... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0775,
0.0282,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0986,
0.0047,
0,
0.66,
0.1429,
80,
0,
1,
0,
0,
80,
0,
0
],
[
1,
0,
0.1033,
0.0047,
0,
0.66,
... | [
"\"\"\"Writing of files in the ``gettext`` MO (machine object) format.\n\n:since: version 0.9\n:see: `The Format of MO Files\n <http://www.gnu.org/software/gettext/manual/gettext.html#MO-Files>`_\n\"\"\"",
"import array",
"import struct",
"from babel.messages.catalog import Catalog, Message",
"__all__... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
1,
0,
0.0276,
0.002,
0,
0.66,
0,
426,
0,
1,
0,
0,
426,
0,
0
],
[
1,
0,
0.0296,
0.002,
0,
0.66,
0.1,
614,
0,
1,
0,
0,
614,
0,
0
],
[
1,
0,
0.0316,
0.002,
0,
0.66,
... | [
"from datetime import datetime",
"import doctest",
"from StringIO import StringIO",
"import unittest",
"from babel.messages.catalog import Catalog, Message",
"from babel.messages import pofile",
"from babel.util import FixedOffsetTimezone",
"class ReadPoTestCase(unittest.TestCase):\n\n def test_pre... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
1,
0,
0.0263,
0.0019,
0,
0.66,
0,
220,
0,
1,
0,
0,
220,
0,
0
],
[
1,
0,
0.0281,
0.0019,
0,
0.66,
0.1,
614,
0,
1,
0,
0,
614,
0,
0
],
[
1,
0,
0.03,
0.0019,
0,
0.66,... | [
"import codecs",
"import doctest",
"from StringIO import StringIO",
"import sys",
"import unittest",
"from babel.messages import extract",
"class ExtractPythonTestCase(unittest.TestCase):\n\n def test_nested_calls(self):\n buf = StringIO(\"\"\"\\\nmsg1 = _(i18n_arg.replace(r'\\\"', '\"'))\nmsg... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: sw=4 ts=4 fenc=utf-8
# =============================================================================
# $Id: setup.py 114 2007-06-14 21:17:14Z palgarvio $
# =============================================================================
# $URL: http://svn.edgewall.org/r... | [
[
1,
0,
0.6786,
0.0357,
0,
0.66,
0,
182,
0,
2,
0,
0,
182,
0,
0
],
[
8,
0,
0.875,
0.2857,
0,
0.66,
1,
234,
3,
6,
0,
0,
0,
0,
2
]
] | [
"from setuptools import setup, find_packages",
"setup(\n name = 'TestProject',\n version = '0.1',\n license = 'BSD',\n author = 'Foo Bar',\n author_email = 'foo@bar.tld',\n packages = find_packages(),\n)"
] |
# -*- coding: utf-8 -*-
# file1.py for tests
from gettext import gettext as _
def foo():
# TRANSLATOR: This will be a translator coment,
# that will include several lines
print _('bar')
| [
[
1,
0,
0.5,
0.125,
0,
0.66,
0,
723,
0,
1,
0,
0,
723,
0,
0
],
[
2,
0,
0.8125,
0.5,
0,
0.66,
1,
528,
0,
0,
0,
0,
0,
0,
2
],
[
8,
1,
1,
0.125,
1,
0.9,
0,
535,... | [
"from gettext import gettext as _",
"def foo():\n # TRANSLATOR: This will be a translator coment,\n # that will include several lines\n print(_('bar'))",
" print(_('bar'))"
] |
# -*- coding: utf-8 -*-
# file2.py for tests
from gettext import ngettext
def foo():
# Note: This will have the TRANSLATOR: tag but shouldn't
# be included on the extracted stuff
print ngettext('foobar', 'foobars', 1)
| [
[
1,
0,
0.4444,
0.1111,
0,
0.66,
0,
723,
0,
1,
0,
0,
723,
0,
0
],
[
2,
0,
0.8333,
0.4444,
0,
0.66,
1,
528,
0,
0,
0,
0,
0,
0,
2
],
[
8,
1,
1,
0.1111,
1,
0.22,
0,... | [
"from gettext import ngettext",
"def foo():\n # Note: This will have the TRANSLATOR: tag but shouldn't\n # be included on the extracted stuff\n print(ngettext('foobar', 'foobars', 1))",
" print(ngettext('foobar', 'foobars', 1))"
] |
# -*- coding: utf-8 -*-
# This file won't normally be in this directory.
# It IS only for tests
from gettext import ngettext
def foo():
# Note: This will have the TRANSLATOR: tag but shouldn't
# be included on the extracted stuff
print ngettext('FooBar', 'FooBars', 1)
| [
[
1,
0,
0.5455,
0.0909,
0,
0.66,
0,
723,
0,
1,
0,
0,
723,
0,
0
],
[
2,
0,
0.8636,
0.3636,
0,
0.66,
1,
528,
0,
0,
0,
0,
0,
0,
2
],
[
8,
1,
1,
0.0909,
1,
0.98,
0,... | [
"from gettext import ngettext",
"def foo():\n # Note: This will have the TRANSLATOR: tag but shouldn't\n # be included on the extracted stuff\n print(ngettext('FooBar', 'FooBars', 1))",
" print(ngettext('FooBar', 'FooBars', 1))"
] |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
1,
0,
0.1609,
0.0115,
0,
0.66,
0,
614,
0,
1,
0,
0,
614,
0,
0
],
[
1,
0,
0.1724,
0.0115,
0,
0.66,
0.1111,
723,
0,
1,
0,
0,
723,
0,
0
],
[
1,
0,
0.1839,
0.0115,
0,
... | [
"import doctest",
"import gettext",
"import os",
"import unittest",
"from StringIO import StringIO",
"from babel.messages import mofile, Catalog",
"class ReadMoTestCase(unittest.TestCase):\n\n def setUp(self):\n self.datadir = os.path.join(os.path.dirname(__file__), 'data')\n\n def test_bas... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
1,
0,
0.56,
0.04,
0,
0.66,
0,
614,
0,
1,
0,
0,
614,
0,
0
],
[
1,
0,
0.6,
0.04,
0,
0.66,
0.25,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.68,
0.04,
0,
0.66,
0.5,
... | [
"import doctest",
"import unittest",
"from babel.messages import plurals",
"def suite():\n suite = unittest.TestSuite()\n suite.addTest(doctest.DocTestSuite(plurals))\n return suite",
" suite = unittest.TestSuite()",
" suite.addTest(doctest.DocTestSuite(plurals))",
" return suite",
"... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
1,
0,
0.0478,
0.0034,
0,
0.66,
0,
739,
0,
1,
0,
0,
739,
0,
0
],
[
1,
0,
0.0512,
0.0034,
0,
0.66,
0.125,
426,
0,
1,
0,
0,
426,
0,
0
],
[
1,
0,
0.0546,
0.0034,
0,
0... | [
"import copy",
"import datetime",
"import doctest",
"import unittest",
"from babel.messages import catalog",
"class MessageTestCase(unittest.TestCase):\n\n def test_python_format(self):\n assert catalog.PYTHON_FORMAT.search('foo %d bar')\n assert catalog.PYTHON_FORMAT.search('foo %s bar')... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
1,
0,
0.4667,
0.0333,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
2,
0,
0.7167,
0.4,
0,
0.66,
0.5,
425,
0,
0,
1,
0,
0,
0,
15
],
[
1,
1,
0.5833,
0.0667,
1,
0.1,
... | [
"import unittest",
"def suite():\n from babel.messages.tests import catalog, extract, frontend, mofile, \\\n plurals, pofile, checkers\n suite = unittest.TestSuite()\n suite.addTest(catalog.suite())\n suite.addTest(extract.suite())\n suite.addTest(frontend.suite(... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0862,
0.0172,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1034,
0.0057,
0,
0.66,
0.0667,
616,
0,
1,
0,
0,
616,
0,
0
],
[
1,
0,
0.1092,
0.0057,
0,
0.66... | [
"\"\"\"A simple JavaScript 1.5 lexer which is used for the JavaScript\nextractor.\n\"\"\"",
"from operator import itemgetter",
"import re",
"operators = [\n '+', '-', '*', '%', '!=', '==', '<', '>', '<=', '>=', '=',\n '+=', '-=', '*=', '%=', '<<', '>>', '>>>', '<<=', '>>=',\n '>>>=', '&', '&=', '|', ... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0896,
0.0231,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1098,
0.0058,
0,
0.66,
0.125,
808,
0,
1,
0,
0,
808,
0,
0
],
[
1,
0,
0.1156,
0.0058,
0,
0.66,... | [
"\"\"\"Various routines that help with validation of translations.\n\n:since: version 0.9\n\"\"\"",
"from itertools import izip",
"from babel.messages.catalog import TranslationError, PYTHON_FORMAT",
"_string_format_compatibilities = [\n set(['i', 'd', 'u']),\n set(['x', 'X']),\n set(['f', 'F', 'g', ... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists... | [
[
8,
0,
0.0549,
0.0039,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0627,
0.0039,
0,
0.66,
0.1429,
40,
0,
2,
0,
0,
40,
0,
0
],
[
1,
0,
0.0667,
0.0039,
0,
0.66,
... | [
"\"\"\"Plural form definitions.\"\"\"",
"from babel.core import default_locale, Locale",
"from operator import itemgetter",
"LC_CTYPE = default_locale('LC_CTYPE')",
"PLURALS = {\n # Afar\n # 'aa': (),\n # Abkhazian\n # 'ab': (),\n # Avestan\n # 'ae': (),\n # Afrikaans - From Pootle's PO... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.