Permalink
Browse files

add external libraries

  • Loading branch information...
1 parent c52dd75 commit 1c5cb2822f370f43c6cd1c116292b538235f09af @najeira committed Mar 25, 2012
Showing with 39,566 additions and 6 deletions.
  1. +0 −6 .gitignore
  2. +73 −0 jinja2/__init__.py
  3. +78 −0 jinja2/_debugsupport.c
  4. +225 −0 jinja2/_markupsafe/__init__.py
  5. +49 −0 jinja2/_markupsafe/_bundle.py
  6. +267 −0 jinja2/_markupsafe/_constants.py
  7. +45 −0 jinja2/_markupsafe/_native.py
  8. +80 −0 jinja2/_markupsafe/tests.py
  9. +18 −0 jinja2/_stringdefs.py
  10. +289 −0 jinja2/bccache.py
  11. +1,652 −0 jinja2/compiler.py
  12. +32 −0 jinja2/constants.py
  13. +333 −0 jinja2/debug.py
  14. +40 −0 jinja2/defaults.py
  15. +1,121 −0 jinja2/environment.py
  16. +143 −0 jinja2/exceptions.py
  17. +612 −0 jinja2/ext.py
  18. +801 −0 jinja2/filters.py
  19. +681 −0 jinja2/lexer.py
  20. +451 −0 jinja2/loaders.py
  21. +102 −0 jinja2/meta.py
  22. +910 −0 jinja2/nodes.py
  23. +68 −0 jinja2/optimizer.py
  24. +896 −0 jinja2/parser.py
  25. +550 −0 jinja2/runtime.py
  26. +361 −0 jinja2/sandbox.py
  27. +146 −0 jinja2/tests.py
  28. +95 −0 jinja2/testsuite/__init__.py
  29. +245 −0 jinja2/testsuite/api.py
  30. +285 −0 jinja2/testsuite/core_tags.py
  31. +60 −0 jinja2/testsuite/debug.py
  32. +29 −0 jinja2/testsuite/doctests.py
  33. +455 −0 jinja2/testsuite/ext.py
  34. +349 −0 jinja2/testsuite/filters.py
  35. +141 −0 jinja2/testsuite/imports.py
  36. +227 −0 jinja2/testsuite/inheritance.py
  37. +387 −0 jinja2/testsuite/lexnparse.py
  38. +190 −0 jinja2/testsuite/loader.py
  39. +255 −0 jinja2/testsuite/regression.py
  40. 0 jinja2/testsuite/res/__init__.py
  41. +3 −0 jinja2/testsuite/res/templates/broken.html
  42. +1 −0 jinja2/testsuite/res/templates/foo/test.html
  43. +4 −0 jinja2/testsuite/res/templates/syntaxerror.html
  44. +1 −0 jinja2/testsuite/res/templates/test.html
  45. +165 −0 jinja2/testsuite/security.py
  46. +87 −0 jinja2/testsuite/tests.py
  47. +82 −0 jinja2/testsuite/utils.py
  48. +601 −0 jinja2/utils.py
  49. +87 −0 jinja2/visitor.py
  50. +14 −0 raginei/__init__.py
  51. +658 −0 raginei/app.py
  52. +68 −0 raginei/cache.py
  53. +144 −0 raginei/ctx.py
  54. +468 −0 raginei/helpers.py
  55. +87 −0 raginei/jinja2loader.py
  56. +92 −0 raginei/testutil.py
  57. +36 −0 raginei/timezone.py
  58. +118 −0 raginei/util.py
  59. +83 −0 raginei/wrappers.py
  60. +149 −0 werkzeug/__init__.py
  61. +405 −0 werkzeug/_internal.py
  62. +16 −0 werkzeug/contrib/__init__.py
  63. +343 −0 werkzeug/contrib/atom.py
  64. +672 −0 werkzeug/contrib/cache.py
  65. +224 −0 werkzeug/contrib/fixers.py
  66. +277 −0 werkzeug/contrib/iterio.py
  67. +259 −0 werkzeug/contrib/jsrouting.py
  68. +288 −0 werkzeug/contrib/kickstart.py
  69. +36 −0 werkzeug/contrib/limiter.py
  70. +333 −0 werkzeug/contrib/lint.py
  71. +118 −0 werkzeug/contrib/profiler.py
  72. +332 −0 werkzeug/contrib/securecookie.py
  73. +344 −0 werkzeug/contrib/sessions.py
  74. +71 −0 werkzeug/contrib/testtools.py
  75. +275 −0 werkzeug/contrib/wrappers.py
  76. +2,573 −0 werkzeug/datastructures.py
  77. +185 −0 werkzeug/debug/__init__.py
  78. +208 −0 werkzeug/debug/console.py
  79. +267 −0 werkzeug/debug/repr.py
  80. +96 −0 werkzeug/debug/shared/FONT_LICENSE
  81. BIN werkzeug/debug/shared/console.png
  82. +200 −0 werkzeug/debug/shared/debugger.js
  83. +167 −0 werkzeug/debug/shared/jquery.js
  84. BIN werkzeug/debug/shared/less.png
  85. BIN werkzeug/debug/shared/more.png
  86. BIN werkzeug/debug/shared/source.png
  87. +113 −0 werkzeug/debug/shared/style.css
  88. BIN werkzeug/debug/shared/ubuntu.ttf
  89. +483 −0 werkzeug/debug/tbtools.py
  90. +536 −0 werkzeug/exceptions.py
  91. +463 −0 werkzeug/formparser.py
  92. +841 −0 werkzeug/http.py
  93. +394 −0 werkzeug/local.py
  94. +105 −0 werkzeug/posixemulation.py
  95. +1,622 −0 werkzeug/routing.py
  96. +313 −0 werkzeug/script.py
  97. +140 −0 werkzeug/security.py
  98. +617 −0 werkzeug/serving.py
  99. +399 −0 werkzeug/templates.py
  100. +843 −0 werkzeug/test.py
  101. +230 −0 werkzeug/testapp.py
  102. +146 −0 werkzeug/testsuite/__init__.py
  103. +58 −0 werkzeug/testsuite/compat.py
  104. +19 −0 werkzeug/testsuite/contrib/__init__.py
  105. +166 −0 werkzeug/testsuite/contrib/cache.py
  106. +187 −0 werkzeug/testsuite/contrib/fixers.py
  107. +72 −0 werkzeug/testsuite/contrib/iterio.py
  108. +65 −0 werkzeug/testsuite/contrib/securecookie.py
  109. +81 −0 werkzeug/testsuite/contrib/sessions.py
  110. +97 −0 werkzeug/testsuite/contrib/wrappers.py
  111. +618 −0 werkzeug/testsuite/datastructures.py
  112. +163 −0 werkzeug/testsuite/debug.py
  113. +85 −0 werkzeug/testsuite/exceptions.py
  114. +358 −0 werkzeug/testsuite/formparser.py
  115. +392 −0 werkzeug/testsuite/http.py
  116. +81 −0 werkzeug/testsuite/internal.py
  117. +133 −0 werkzeug/testsuite/local.py
  118. +56 −0 werkzeug/testsuite/multipart/collect.py
  119. BIN werkzeug/testsuite/multipart/firefox3-2png1txt/file1.png
  120. BIN werkzeug/testsuite/multipart/firefox3-2png1txt/file2.png
  121. BIN werkzeug/testsuite/multipart/firefox3-2png1txt/request.txt
  122. +1 −0 werkzeug/testsuite/multipart/firefox3-2png1txt/text.txt
  123. BIN werkzeug/testsuite/multipart/firefox3-2pnglongtext/file1.png
  124. BIN werkzeug/testsuite/multipart/firefox3-2pnglongtext/file2.png
  125. BIN werkzeug/testsuite/multipart/firefox3-2pnglongtext/request.txt
  126. +3 −0 werkzeug/testsuite/multipart/firefox3-2pnglongtext/text.txt
  127. BIN werkzeug/testsuite/multipart/ie6-2png1txt/file1.png
  128. BIN werkzeug/testsuite/multipart/ie6-2png1txt/file2.png
  129. BIN werkzeug/testsuite/multipart/ie6-2png1txt/request.txt
  130. +1 −0 werkzeug/testsuite/multipart/ie6-2png1txt/text.txt
  131. BIN werkzeug/testsuite/multipart/ie7_full_path_request.txt
  132. BIN werkzeug/testsuite/multipart/opera8-2png1txt/file1.png
  133. BIN werkzeug/testsuite/multipart/opera8-2png1txt/file2.png
  134. BIN werkzeug/testsuite/multipart/opera8-2png1txt/request.txt
  135. +1 −0 werkzeug/testsuite/multipart/opera8-2png1txt/text.txt
  136. BIN werkzeug/testsuite/multipart/webkit3-2png1txt/file1.png
  137. BIN werkzeug/testsuite/multipart/webkit3-2png1txt/file2.png
  138. BIN werkzeug/testsuite/multipart/webkit3-2png1txt/request.txt
  139. +1 −0 werkzeug/testsuite/multipart/webkit3-2png1txt/text.txt
  140. +1 −0 werkzeug/testsuite/res/test.txt
  141. +633 −0 werkzeug/testsuite/routing.py
  142. +57 −0 werkzeug/testsuite/security.py
  143. +84 −0 werkzeug/testsuite/serving.py
  144. +376 −0 werkzeug/testsuite/test.py
  145. +168 −0 werkzeug/testsuite/urls.py
  146. +264 −0 werkzeug/testsuite/utils.py
  147. +662 −0 werkzeug/testsuite/wrappers.py
  148. +230 −0 werkzeug/testsuite/wsgi.py
  149. +539 −0 werkzeug/urls.py
  150. +185 −0 werkzeug/useragents.py
  151. +613 −0 werkzeug/utils.py
  152. +1,641 −0 werkzeug/wrappers.py
  153. +852 −0 werkzeug/wsgi.py
View
@@ -2,9 +2,3 @@
.idea
*.pyc
*.db
-jinja2
-jinja2/*
-werkzeug
-werkzeug/*
-raginei
-raginei/*
View
@@ -0,0 +1,73 @@
+# -*- 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::
+
+ {% extends 'base.html' %}
+ {% block title %}Memberlist{% endblock %}
+ {% block content %}
+ <ul>
+ {% for user in users %}
+ <li><a href="{{ user.url }}">{{ user.username }}</a></li>
+ {% endfor %}
+ </ul>
+ {% endblock %}
+
+
+ :copyright: (c) 2010 by the Jinja Team.
+ :license: BSD, see LICENSE for more details.
+"""
+__docformat__ = 'restructuredtext en'
+try:
+ __version__ = __import__('pkg_resources') \
+ .get_distribution('Jinja2').version
+except Exception:
+ __version__ = 'unknown'
+
+# high level interface
+from jinja2.environment import Environment, Template
+
+# loaders
+from jinja2.loaders import BaseLoader, FileSystemLoader, PackageLoader, \
+ DictLoader, FunctionLoader, PrefixLoader, ChoiceLoader, \
+ ModuleLoader
+
+# bytecode caches
+from jinja2.bccache import BytecodeCache, FileSystemBytecodeCache, \
+ MemcachedBytecodeCache
+
+# undefined types
+from jinja2.runtime import Undefined, DebugUndefined, StrictUndefined
+
+# exceptions
+from jinja2.exceptions import TemplateError, UndefinedError, \
+ TemplateNotFound, TemplatesNotFound, TemplateSyntaxError, \
+ TemplateAssertionError
+
+# decorators and public utilities
+from jinja2.filters import environmentfilter, contextfilter, \
+ evalcontextfilter
+from jinja2.utils import Markup, escape, clear_caches, \
+ environmentfunction, evalcontextfunction, contextfunction, \
+ is_undefined
+
+__all__ = [
+ 'Environment', 'Template', 'BaseLoader', 'FileSystemLoader',
+ 'PackageLoader', 'DictLoader', 'FunctionLoader', 'PrefixLoader',
+ 'ChoiceLoader', 'BytecodeCache', 'FileSystemBytecodeCache',
+ 'MemcachedBytecodeCache', 'Undefined', 'DebugUndefined',
+ 'StrictUndefined', 'TemplateError', 'UndefinedError', 'TemplateNotFound',
+ 'TemplatesNotFound', 'TemplateSyntaxError', 'TemplateAssertionError',
+ 'ModuleLoader', 'environmentfilter', 'contextfilter', 'Markup', 'escape',
+ 'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined',
+ 'evalcontextfilter', 'evalcontextfunction'
+]
@@ -0,0 +1,78 @@
+/**
+ * jinja2._debugsupport
+ * ~~~~~~~~~~~~~~~~~~~~
+ *
+ * C implementation of `tb_set_next`.
+ *
+ * :copyright: (c) 2010 by the Jinja Team.
+ * :license: BSD.
+ */
+
+#include <Python.h>
+
+
+static PyObject*
+tb_set_next(PyObject *self, PyObject *args)
+{
+ PyTracebackObject *tb, *old;
+ PyObject *next;
+
+ if (!PyArg_ParseTuple(args, "O!O:tb_set_next", &PyTraceBack_Type, &tb, &next))
+ return NULL;
+ if (next == Py_None)
+ next = NULL;
+ else if (!PyTraceBack_Check(next)) {
+ PyErr_SetString(PyExc_TypeError,
+ "tb_set_next arg 2 must be traceback or None");
+ return NULL;
+ }
+ else
+ Py_INCREF(next);
+
+ old = tb->tb_next;
+ tb->tb_next = (PyTracebackObject*)next;
+ Py_XDECREF(old);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef module_methods[] = {
+ {"tb_set_next", (PyCFunction)tb_set_next, METH_VARARGS,
+ "Set the tb_next member of a traceback object."},
+ {NULL, NULL, 0, NULL} /* Sentinel */
+};
+
+
+#if PY_MAJOR_VERSION < 3
+
+#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
+#define PyMODINIT_FUNC void
+#endif
+PyMODINIT_FUNC
+init_debugsupport(void)
+{
+ Py_InitModule3("jinja2._debugsupport", module_methods, "");
+}
+
+#else /* Python 3.x module initialization */
+
+static struct PyModuleDef module_definition = {
+ PyModuleDef_HEAD_INIT,
+ "jinja2._debugsupport",
+ NULL,
+ -1,
+ module_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC
+PyInit__debugsupport(void)
+{
+ return PyModule_Create(&module_definition);
+}
+
+#endif
@@ -0,0 +1,225 @@
+# -*- 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(r'(<!--.*?-->|<[^>]*>)')
+_entity_re = re.compile(r'&([^;]+);')
+
+
+class Markup(unicode):
+ r"""Marks a string as being safe for inclusion in HTML/XML output without
+ needing to be escaped. This implements the `__html__` interface a couple
+ of frameworks and web applications use. :class:`Markup` is a direct
+ subclass of `unicode` and provides all the methods of `unicode` just that
+ it escapes arguments passed and always returns `Markup`.
+
+ The `escape` function returns markup objects so that double escaping can't
+ happen.
+
+ The constructor of the :class:`Markup` class can be used for three
+ different things: When passed an unicode object it's assumed to be safe,
+ when passed an object with an HTML representation (has an `__html__`
+ method) that representation is used, otherwise the object passed is
+ converted into a unicode string and then assumed to be safe:
+
+ >>> Markup("Hello <em>World</em>!")
+ Markup(u'Hello <em>World</em>!')
+ >>> class Foo(object):
+ ... def __html__(self):
+ ... return '<a href="#">foo</a>'
+ ...
+ >>> Markup(Foo())
+ Markup(u'<a href="#">foo</a>')
+
+ If you want object passed being always treated as unsafe you can use the
+ :meth:`escape` classmethod to create a :class:`Markup` object:
+
+ >>> Markup.escape("Hello <em>World</em>!")
+ Markup(u'Hello &lt;em&gt;World&lt;/em&gt;!')
+
+ Operations on a markup string are markup aware which means that all
+ arguments are passed through the :func:`escape` function:
+
+ >>> em = Markup("<em>%s</em>")
+ >>> em % "foo & bar"
+ Markup(u'<em>foo &amp; bar</em>')
+ >>> strong = Markup("<strong>%(text)s</strong>")
+ >>> strong % {'text': '<blink>hacker here</blink>'}
+ Markup(u'<strong>&lt;blink&gt;hacker here&lt;/blink&gt;</strong>')
+ >>> Markup("<em>Hello</em> ") + "<foo>"
+ Markup(u'<em>Hello</em> &lt;foo&gt;')
+ """
+ __slots__ = ()
+
+ def __new__(cls, base=u'', encoding=None, errors='strict'):
+ if hasattr(base, '__html__'):
+ base = base.__html__()
+ if encoding is None:
+ return unicode.__new__(cls, base)
+ return unicode.__new__(cls, base, encoding, errors)
+
+ def __html__(self):
+ return self
+
+ def __add__(self, other):
+ if hasattr(other, '__html__') or isinstance(other, basestring):
+ return self.__class__(unicode(self) + unicode(escape(other)))
+ return NotImplemented
+
+ def __radd__(self, other):
+ if hasattr(other, '__html__') or isinstance(other, basestring):
+ return self.__class__(unicode(escape(other)) + unicode(self))
+ return NotImplemented
+
+ def __mul__(self, num):
+ if isinstance(num, (int, long)):
+ return self.__class__(unicode.__mul__(self, num))
+ return NotImplemented
+ __rmul__ = __mul__
+
+ def __mod__(self, arg):
+ if isinstance(arg, tuple):
+ arg = tuple(imap(_MarkupEscapeHelper, arg))
+ else:
+ arg = _MarkupEscapeHelper(arg)
+ return self.__class__(unicode.__mod__(self, arg))
+
+ def __repr__(self):
+ return '%s(%s)' % (
+ self.__class__.__name__,
+ unicode.__repr__(self)
+ )
+
+ def join(self, seq):
+ return self.__class__(unicode.join(self, imap(escape, seq)))
+ join.__doc__ = unicode.join.__doc__
+
+ def split(self, *args, **kwargs):
+ return map(self.__class__, unicode.split(self, *args, **kwargs))
+ split.__doc__ = unicode.split.__doc__
+
+ def rsplit(self, *args, **kwargs):
+ return map(self.__class__, unicode.rsplit(self, *args, **kwargs))
+ rsplit.__doc__ = unicode.rsplit.__doc__
+
+ def splitlines(self, *args, **kwargs):
+ return map(self.__class__, unicode.splitlines(self, *args, **kwargs))
+ splitlines.__doc__ = unicode.splitlines.__doc__
+
+ def unescape(self):
+ r"""Unescape markup again into an unicode string. This also resolves
+ known HTML4 and XHTML entities:
+
+ >>> Markup("Main &raquo; <em>About</em>").unescape()
+ u'Main \xbb <em>About</em>'
+ """
+ from jinja2._markupsafe._constants import HTML_ENTITIES
+ def handle_match(m):
+ name = m.group(1)
+ if name in HTML_ENTITIES:
+ return unichr(HTML_ENTITIES[name])
+ try:
+ if name[:2] in ('#x', '#X'):
+ return unichr(int(name[2:], 16))
+ elif name.startswith('#'):
+ return unichr(int(name[1:]))
+ except ValueError:
+ pass
+ return u''
+ return _entity_re.sub(handle_match, unicode(self))
+
+ def striptags(self):
+ r"""Unescape markup into an unicode string and strip all tags. This
+ also resolves known HTML4 and XHTML entities. Whitespace is
+ normalized to one:
+
+ >>> Markup("Main &raquo; <em>About</em>").striptags()
+ u'Main \xbb About'
+ """
+ stripped = u' '.join(_striptags_re.sub('', self).split())
+ return Markup(stripped).unescape()
+
+ @classmethod
+ def escape(cls, s):
+ """Escape the string. Works like :func:`escape` with the difference
+ that for subclasses of :class:`Markup` this function would return the
+ correct subclass.
+ """
+ rv = escape(s)
+ if rv.__class__ is not cls:
+ return cls(rv)
+ return rv
+
+ def make_wrapper(name):
+ orig = getattr(unicode, name)
+ def func(self, *args, **kwargs):
+ args = _escape_argspec(list(args), enumerate(args))
+ _escape_argspec(kwargs, kwargs.iteritems())
+ return self.__class__(orig(self, *args, **kwargs))
+ func.__name__ = orig.__name__
+ func.__doc__ = orig.__doc__
+ return func
+
+ for method in '__getitem__', 'capitalize', \
+ 'title', 'lower', 'upper', 'replace', 'ljust', \
+ 'rjust', 'lstrip', 'rstrip', 'center', 'strip', \
+ 'translate', 'expandtabs', 'swapcase', 'zfill':
+ locals()[method] = make_wrapper(method)
+
+ # new in python 2.5
+ if hasattr(unicode, 'partition'):
+ partition = make_wrapper('partition'),
+ rpartition = make_wrapper('rpartition')
+
+ # new in python 2.6
+ if hasattr(unicode, 'format'):
+ format = make_wrapper('format')
+
+ # not in python 3
+ if hasattr(unicode, '__getslice__'):
+ __getslice__ = make_wrapper('__getslice__')
+
+ del method, make_wrapper
+
+
+def _escape_argspec(obj, iterable):
+ """Helper for various string-wrapped functions."""
+ for key, value in iterable:
+ if hasattr(value, '__html__') or isinstance(value, basestring):
+ obj[key] = escape(value)
+ return obj
+
+
+class _MarkupEscapeHelper(object):
+ """Helper for Markup.__mod__"""
+
+ def __init__(self, obj):
+ self.obj = obj
+
+ __getitem__ = lambda s, x: _MarkupEscapeHelper(s.obj[x])
+ __str__ = lambda s: str(escape(s.obj))
+ __unicode__ = lambda s: unicode(escape(s.obj))
+ __repr__ = lambda s: str(escape(repr(s.obj)))
+ __int__ = lambda s: int(s.obj)
+ __float__ = lambda s: float(s.obj)
+
+
+# we have to import it down here as the speedups and native
+# modules imports the markup type which is define above.
+try:
+ from jinja2._markupsafe._speedups import escape, escape_silent, soft_unicode
+except ImportError:
+ from jinja2._markupsafe._native import escape, escape_silent, soft_unicode
Oops, something went wrong. Retry.

0 comments on commit 1c5cb28

Please sign in to comment.