code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
# -*- coding: utf-8 -*-
"""
webapp2
=======
`webapp2`_ is a lightweight Python web framework compatible with Google App
Engine's `webapp`_.
webapp2 is `simple`_. it follows the simplicity of webapp, but
improves it in some ways: it adds better URI routing and exception handling,
a full featured response object and a m... | Python |
class BaseAction(object):
"""Base interface for custom actions."""
#: Reference to :class:`Manager`.
manager = None
#: Action name.
name = None
#: ArgumentParser description.
description = None
#: ArgumentParser epilog.
epilog = None
def __init__(self, manager):
raise ... | Python |
import ConfigParser
import os
import textwrap
import StringIO
import sys
import unittest
import StringIO
import test_utils
from manage.config import Config
class TestConfig(test_utils.BaseTestCase):
def get_fp(self, config):
return StringIO.StringIO(textwrap.dedent(config))
def test_get(self):
... | Python |
import ConfigParser
import re
InterpolationError = ConfigParser.InterpolationError
InterpolationSyntaxError = ConfigParser.InterpolationSyntaxError
NoOptionError = ConfigParser.NoOptionError
NoSectionError = ConfigParser.NoSectionError
class Converter(object):
"""Converts config values to several types.
Sup... | Python |
# Author: Steven J. Bethard <steven.bethard@gmail.com>.
"""Command-line parsing library
This module is an optparse-inspired command-line parsing library that:
- handles both optional and positional arguments
- produces highly informative usage messages
- supports parsers that dispatch to sub-parsers
The... | Python |
# -*- coding: utf-8 -*-
import StringIO
import webapp2
import test_base
def _norm_req(s):
return '\r\n'.join(s.strip().replace('\r','').split('\n'))
_test_req = """
POST /webob/ HTTP/1.0
Accept: */*
Cache-Control: max-age=0
Content-Type: multipart/form-data; boundary=----------------------------deb95b63e42a
Ho... | Python |
# -*- coding: utf-8 -*-
import datetime
import gettext as gettext_stdlib
import os
from babel.numbers import NumberFormatError
from pytz.gae import pytz
import webapp2
from webapp2_extras import i18n
import test_base
class I18nTestCase(test_base.BaseTestCase):
def setUp(self):
super(I18nTestCase, self... | Python |
from webapp2_extras import auth
from webapp2_extras.appengine.auth import models
from google.appengine.ext.ndb import model
import test_base
class UniqueConstraintViolation(Exception):
pass
class User(model.Model):
username = model.StringProperty(required=True)
auth_id = model.StringProperty()
ema... | Python |
import webapp2
from webapp2_extras import sessions
from webapp2_extras import auth
from webapp2_extras.appengine.auth import models
from google.appengine.ext.ndb import model
import test_base
class TestAuth(test_base.BaseTestCase):
def setUp(self):
super(TestAuth, self).setUp()
self.register_m... | Python |
# -*- coding: utf-8 -*-
import os
import webapp2
from webapp2_extras import mako
import test_base
current_dir = os.path.abspath(os.path.dirname(__file__))
template_path = os.path.join(current_dir, 'resources', 'mako_templates')
class TestMako(test_base.BaseTestCase):
def test_render_template(self):
app... | Python |
# -*- coding: utf-8 -*-
import webapp2
from webapp2_extras import sessions
from webapp2_extras import sessions_memcache
import test_base
app = webapp2.WSGIApplication(config={
'webapp2_extras.sessions': {
'secret_key': 'my-super-secret',
},
})
class TestMemcacheSession(test_base.BaseTestCase):
... | Python |
# -*- coding: utf-8 -*-
import os
import webapp2
from webapp2_extras import jinja2
import test_base
current_dir = os.path.abspath(os.path.dirname(__file__))
template_path = os.path.join(current_dir, 'resources', 'jinja2_templates')
compiled_path = os.path.join(current_dir, 'resources',
'... | Python |
# -*- coding: utf-8 -*-
from webapp2_extras import securecookie
import test_base
class TestSecureCookie(test_base.BaseTestCase):
def test_secure_cookie_serializer(self):
serializer = securecookie.SecureCookieSerializer('secret-key')
serializer._get_timestamp = lambda: 1
value = ['a', 'b'... | Python |
# -*- coding: utf-8 -*-
import re
from webapp2_extras import security
import test_base
class TestSecurity(test_base.BaseTestCase):
def test_generate_random_string(self):
self.assertRaises(ValueError, security.generate_random_string, None)
self.assertRaises(ValueError, security.generate_random_st... | Python |
# -*- coding: utf-8 -*-
import webapp2
from webapp2_extras import sessions
import test_base
app = webapp2.WSGIApplication(config={
'webapp2_extras.sessions': {
'secret_key': 'my-super-secret',
},
})
class TestSecureCookieSession(test_base.BaseTestCase):
factory = sessions.SecureCookieSessionFact... | Python |
# -*- coding: utf-8 -*-
from google.appengine.ext import webapp
import webapp2
import test_base
# Old WSGIApplication, new RequestHandler.
class NewStyleHandler(webapp2.RequestHandler):
def get(self, text):
self.response.out.write(text)
app = webapp.WSGIApplication([
(r'/test/(.*)', NewStyleHandler... | Python |
# -*- coding: utf-8 -*-
import base64
from webapp2_extras import xsrf
import test_base
class TestXSRFToken(test_base.BaseTestCase):
def test_verify_timeout(self):
token = xsrf.XSRFToken('user@example.com',
'secret',
current_time=1354160000)
... | Python |
# -*- coding: utf-8 -*-
import webapp2
from webapp2_extras import config as app_config
import test_base
class TestConfig(test_base.BaseTestCase):
def tearDown(self):
pass
def test_get(self):
config = app_config.Config({'foo': {
'bar': 'baz',
'doo': 'ding',
}}... | Python |
# -*- coding: utf-8 -*-
import os
import webapp2
from webapp2_extras import users
import test_base
def set_current_user(email, user_id, is_admin=False):
os.environ['USER_EMAIL'] = email or ''
os.environ['USER_ID'] = user_id or ''
os.environ['USER_IS_ADMIN'] = '1' if is_admin else '0'
class LoginRequir... | Python |
# -*- coding: utf-8 -*-
import webapp2
from webapp2_extras.routes import (DomainRoute, HandlerPrefixRoute,
RedirectRoute, NamePrefixRoute, PathPrefixRoute)
import test_base
class HomeHandler(webapp2.RequestHandler):
def get(self, **kwargs):
self.response.out.write('home sweet home')
app = webapp2.... | Python |
# -*- coding: utf-8 -*-
import webob
import webob.exc
import webapp2
import test_base
class TestMiscellaneous(test_base.BaseTestCase):
def test_abort(self):
self.assertRaises(webob.exc.HTTPOk, webapp2.abort, 200)
self.assertRaises(webob.exc.HTTPCreated, webapp2.abort, 201)
self.assertRa... | Python |
# -*- coding: utf-8 -*-
from google.appengine.api import datastore_errors
from google.appengine.api import memcache
import webapp2
from webapp2_extras import sessions
from webapp2_extras import sessions_ndb
import test_base
app = webapp2.WSGIApplication(config={
'webapp2_extras.sessions': {
'secret_key'... | Python |
# -*- coding: utf-8 -*-
"""
Tests for webapp2 webapp2.RequestHandler
"""
import os
import StringIO
import sys
import urllib
import webapp2
import test_base
class BareHandler(object):
def __init__(self, request, response):
self.response = response
response.write('I am not a RequestHandler but I w... | Python |
import webapp2
class LazyHandler(webapp2.RequestHandler):
def get(self, **kwargs):
self.response.out.write('I am a laaazy view.')
class CustomMethodHandler(webapp2.RequestHandler):
def custom_method(self):
self.response.out.write('I am a custom method.')
def handle_exception(request, respo... | Python |
from __future__ import division
from jinja2.runtime import LoopContext, TemplateReference, Macro, Markup, TemplateRuntimeError, missing, concat, escape, markup_join, unicode_join, to_string, TemplateNotFound
name = 'template1.html'
def root(context):
l_message = context.resolve('message')
if 0: yield None
... | Python |
from protorpc import messages
from protorpc import remote
class BonjourRequest(messages.Message):
my_name = messages.StringField(1, required=True)
class BonjourResponse(messages.Message):
hello = messages.StringField(1, required=True)
class BonjourService(remote.Service):
@remote.method(BonjourRequest, B... | Python |
default_config = {
'templates_dir': 'templates',
}
| Python |
from webapp2_extras import config
from webapp2_extras import i18n
default_config = {
'locale': 'en_US',
'timezone': 'America/Chicago',
'required': config.REQUIRED_VALUE,
}
def locale_selector(store, request):
return i18n.get_store().default_locale
def timezone_selector(store, request):
return i18... | Python |
# -*- coding: utf-8 -*-
import random
import webapp2
from webapp2 import BaseRoute, RedirectHandler, Request, Route, Router
import test_base
class TestRoute(test_base.BaseTestCase):
def test_no_variable(self):
route = Route(r'/hello', None)
route, args, kwargs = route.match(Request.blank('/hello... | Python |
# -*- coding: utf-8 -*-
import webapp2
from webapp2_extras import local_app
import test_base
class TestLocalApp(test_base.BaseTestCase):
def test_dispatch(self):
def hello_handler(request, *args, **kwargs):
return webapp2.Response('Hello, World!')
app = local_app.WSGIApplication([('/... | Python |
# -*- coding: utf-8 -*-
import webapp2
import test_base
class NoStringOrUnicodeConversion(object):
pass
class StringConversion(object):
def __str__(self):
return 'foo'.encode('utf-8')
class UnicodeConversion(object):
def __unicode__(self):
return 'bar'.decode('utf-8')
class TestResp... | Python |
# -*- coding: utf-8 -*-
from webapp2_extras import json
import test_base
class TestJson(test_base.BaseTestCase):
def test_encode(self):
self.assertEqual(json.encode(
'<script>alert("hello")</script>'),
'"<script>alert(\\"hello\\")<\\/script>"')
def test_decode(self):
... | Python |
# -*- coding: utf-8 -*-
"""
webapp2
=======
Taking Google App Engine's webapp to the next level!
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
from __future__ import with_statement
import cgi
import inspect
import logging
import os
import re
import ... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.sessions_ndb
===========================
Extended sessions stored in datastore using the ndb library.
App Engine-specific modules were moved to webapp2_extras.appengine.
This module is here for compatibility purposes.
:copyright: 2011 by tipfy.org.
... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.users
====================
Helpers for google.appengine.api.users.
App Engine-specific modules were moved to webapp2_extras.appengine.
This module is here for compatibility purposes.
:copyright: 2011 tipfy.org.
:license: Apache Sotware License, s... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.auth
===================
Utilities for authentication and authorization.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
import logging
import time
import webapp2
from webapp2_extras import security
from web... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.routes
=====================
Extra route classes for webapp2.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
import re
import urllib
from webob import exc
import webapp2
class MultiRoute(object):
"""B... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.xsrf
===================
Helpers for defending against cross-site request forgery attacks.
:copyright: 2012 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
__author__ = 'John Lockwood'
import base64
import hmac
import hashli... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.json
===================
JSON helpers for webapp2.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
from __future__ import absolute_import
import base64
import urllib
try:
# Preference for installed libra... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.securecookie
===========================
A serializer for signed cookies.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
import Cookie
import hashlib
import hmac
import logging
import time
from webapp2_extra... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.sessions
=======================
Lightweight but flexible session support for webapp2.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
import re
import webapp2
from webapp2_extras import securecookie
from we... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.local_app
~~~~~~~~~~~~~~~~~~~~~~~~
This module is deprecated. The functionality is now available
directly in webapp2.
Previously it implemented a WSGIApplication adapted for threaded
environments.
:copyright: 2011 by tipfy.org.
:license: Apac... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.local
~~~~~~~~~~~~~~~~~~~~
This module implements thread-local utilities.
This implementation comes from werkzeug.local.
:copyright: (c) 2010 by the Werkzeug Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
try:
... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.config
=====================
Configuration object for webapp2.
This module is deprecated. See :class:`webapp2.WSGIApplication.config`.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
from __future__ impor... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.appengine.sessions_ndb
=====================================
Extended sessions stored in datastore using the ndb library.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
from __future__ import absolute_import
... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.appengine.users
==============================
Helpers for google.appengine.api.users.
:copyright: 2011 tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
from google.appengine.api import users
def login_required(handler_method):
... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.appengine.auth.models
====================================
Auth related models.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
import time
try:
from ndb import model
except ImportError: # pragma: no cove... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.appengine.auth
=============================
Authentication and authorization utilities.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
| Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.appengine
========================
App Engine-specific modules.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
| Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.appengine.sessions_memcache
==========================================
Extended sessions stored in memcache.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
from google.appengine.api import memcache
from weba... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.mako
===================
Mako template support for webapp2.
Learn more about Mako: http://www.makotemplates.org/
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
from __future__ import absolute_import
fro... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras
==============
Extra modules for webapp2.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
| Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.jinja2
=====================
Jinja2 template support for webapp2.
Learn more about Jinja2: http://jinja.pocoo.org/
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
from __future__ import absolute_import
i... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.i18n
===================
Internationalization support for webapp2.
Several ideas borrowed from tipfy.i18n and Flask-Babel.
:copyright: 2011 by tipfy.org.
:license: Apache Sotware License, see LICENSE for details.
"""
import datetime
import gettext as... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.security
=======================
Security related helpers such as secure password hashing tools and a
random token generator.
:copyright: (c) 2010 by the Werkzeug Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
:co... | Python |
# -*- coding: utf-8 -*-
"""
webapp2_extras.sessions_memcache
================================
Extended sessions stored in memcache.
App Engine-specific modules were moved to webapp2_extras.appengine.
This module is here for compatibility purposes.
:copyright: 2011 by tipfy.org.
:license: ... | Python |
"""To test specific webapp issues."""
import os
import StringIO
import sys
import urllib
import unittest
gae_path = '/usr/local/google_appengine'
sys.path[0:0] = [
gae_path,
os.path.join(gae_path, 'lib', 'django_0_96'),
os.path.join(gae_path, 'lib', 'webob'),
os.path.join(gae_path, 'lib', 'yaml', 'lib... | Python |
import os
import sys
import unittest
gae_path = '/usr/local/google/home/proppy/google_appengine'
current_path = os.path.abspath(os.path.dirname(__file__))
tests_path = os.path.join(current_path, 'tests')
sys.path[0:0] = [
current_path,
tests_path,
gae_path,
# All libs used by webapp2 and extras.
o... | Python |
from jinja2 import nodes
from jinja2.ext import Extension
class FragmentCacheExtension(Extension):
# a set of names that trigger the extension.
tags = set(['cache'])
def __init__(self, environment):
super(FragmentCacheExtension, self).__init__(environment)
# add the defaults to the envir... | Python |
# -*- coding: utf-8 -*-
#
# Jinja2 documentation build configuration file, created by
# sphinx-quickstart on Sun Apr 27 21:42:41 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleab... | Python |
# -*- coding: utf-8 -*-
"""
Jinja Documentation Extensions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for automatically documenting filters and tests.
:copyright: Copyright 2008 by Armin Ronacher.
:license: BSD.
"""
import os
import re
import inspect
import jinja2
from itertools import islice
from typ... | Python |
# -*- 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 Jinja template::
{% extends 'base.html' %}
{% b... | Python |
from lib2to3 import fixer_base
from lib2to3.fixer_util import Name, BlankLine
class FixAltUnicode(fixer_base.BaseFix):
PATTERN = """
func=funcdef< 'def' name='__unicode__'
parameters< '(' NAME ')' > any+ >
"""
def transform(self, node, results):
name = results['name']
... | Python |
from lib2to3 import fixer_base, pytree
from lib2to3.fixer_util import Name, BlankLine, Name, Attr, ArgList
class FixBrokenReraising(fixer_base.BaseFix):
PATTERN = """
raise_stmt< 'raise' any ',' val=any ',' tb=any >
"""
# run before the broken 2to3 checker with the same goal
# tries to rewrite it... | Python |
from lib2to3 import fixer_base
from lib2to3.fixer_util import Name, BlankLine
# whyever this is necessary..
class FixXrange2(fixer_base.BaseFix):
PATTERN = "'xrange'"
def transform(self, node, results):
node.replace(Name('range', prefix=node.prefix))
| Python |
# -*- coding: utf-8 -*-
"""
Inline Gettext
~~~~~~~~~~~~~~
An example extension for Jinja2 that supports inline gettext calls.
Requires the i18n extension to be loaded.
:copyright: (c) 2009 by the Jinja Team.
:license: BSD.
"""
import re
from jinja2.ext import Extension
from jinja2.lexer import... | Python |
# -*- coding: utf-8 -*-
"""
Django to Jinja
~~~~~~~~~~~~~~~
Helper module that can convert django templates into Jinja2 templates.
This file is not intended to be used as stand alone application but to
be used as library. To convert templates you basically create your own
writer, add extra co... | Python |
from django.conf import settings
settings.configure(TEMPLATE_DIRS=['templates'], TEMPLATE_DEBUG=True)
from django2jinja import convert_templates, Writer
writer = Writer(use_jinja_autoescape=True)
convert_templates('converted', writer=writer)
| Python |
# -*- coding: utf-8 -*-
"""
djangojinja2
~~~~~~~~~~~~
Adds support for Jinja2 to Django.
Configuration variables:
======================= =============================================
Key Description
======================= =============================================... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.runtime
~~~~~~~~~~~~~~
Runtime helpers.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD.
"""
from itertools import chain, imap
from jinja2.nodes import EvalContext, _context_function_types
from jinja2.utils import Markup, partial, soft_unicode, escape, miss... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.bccache
~~~~~~~~~~~~~~
This module implements the bytecode cache system Jinja is optionally
using. This is useful if you have very complex template situations and
the compiliation of all those templates slow down your application too
much.
Situations whe... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.compiler
~~~~~~~~~~~~~~~
Compiles nodes into python code.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
from cStringIO import StringIO
from itertools import chain
from copy import deepcopy
from jinja2 import nodes
from j... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.meta
~~~~~~~~~~~
This module implements various functions that exposes information about
templates that might be interesting for various kinds of applications.
:copyright: (c) 2010 by the Jinja Team, see AUTHORS for more details.
:license: BSD, see LICENSE fo... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.regression
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests corner cases and bugs.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import unittest
from jinja2.testsuite import JinjaTestCase
from jinja2 import Template, Enviro... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.tests
~~~~~~~~~~~~~~~~~~~~~~
Who tests the tests?
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import unittest
from jinja2.testsuite import JinjaTestCase
from jinja2 import Markup, Environment
env = Environm... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.debug
~~~~~~~~~~~~~~~~~~~~~~
Tests the debug system.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import sys
import unittest
from jinja2.testsuite import JinjaTestCase, filesystem_loader
from jinja2 import E... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.doctests
~~~~~~~~~~~~~~~~~~~~~~~~~
The doctests. Collects all tests we want to test from
the Jinja modules.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import unittest
import doctest
def suite():
f... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.utils
~~~~~~~~~~~~~~~~~~~~~~
Tests utilities jinja uses.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import gc
import unittest
import pickle
from jinja2.testsuite import JinjaTestCase
from jinja2.utils imp... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.ext
~~~~~~~~~~~~~~~~~~~~
Tests for the extensions.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import re
import unittest
from jinja2.testsuite import JinjaTestCase
from jinja2 import Environment, DictLoader... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.inheritance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests the template inheritance feature.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import unittest
from jinja2.testsuite import JinjaTestCase
from jinja2 import Env... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.core_tags
~~~~~~~~~~~~~~~~~~~~~~~~~~
Test the core tags like for and if.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import unittest
from jinja2.testsuite import JinjaTestCase
from jinja2 import Environment... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite
~~~~~~~~~~~~~~~~
All the unittests of Jinja2. These tests can be executed by
either running run-tests.py using multiple Python versions at
the same time.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
i... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.filters
~~~~~~~~~~~~~~~~~~~~~~~~
Tests for the jinja filters.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import unittest
from jinja2.testsuite import JinjaTestCase
from jinja2 import Markup, Environment
en... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.lexnparse
~~~~~~~~~~~~~~~~~~~~~~~~~~
All the unittests regarding lexing, parsing and syntax.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import sys
import unittest
from jinja2.testsuite import JinjaTestCase
... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.loader
~~~~~~~~~~~~~~~~~~~~~~~
Test the loaders.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import os
import sys
import tempfile
import shutil
import unittest
from jinja2.testsuite import JinjaTestCase, dic... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.api
~~~~~~~~~~~~~~~~~~~~
Tests the public API and related stuff.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import unittest
from jinja2.testsuite import JinjaTestCase
from jinja2 import Environment, Undefi... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.imports
~~~~~~~~~~~~~~~~~~~~~~~~
Tests the import features (with includes).
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import unittest
from jinja2.testsuite import JinjaTestCase
from jinja2 import Environm... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.testsuite.security
~~~~~~~~~~~~~~~~~~~~~~~~~
Checks the sandbox and other security features.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import unittest
from jinja2.testsuite import JinjaTestCase
from jinja2 import E... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.nodes
~~~~~~~~~~~~
This module implements additional nodes derived from the ast base node.
It also provides some node tree helper functions like `in_lineno` and
`get_nodes` used by the parser and translator in order to normalize
python and jinja nodes.
:... | Python |
# -*- 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
... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.debug
~~~~~~~~~~~~
Implements the debug interface for Jinja. This module does some pretty
ugly stuff with the Python traceback system in order to achieve tracebacks
with correct line numbers, locals and contents.
:copyright: (c) 2010 by the Jinja Team.
:... | Python |
# -*- 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 ... | Python |
# -*- coding: utf-8 -*-
"""
jinja2.lexer
~~~~~~~~~~~~
This module implements a Jinja / Python combination lexer. The
`Lexer` class provided by this module is used to do some preprocessing
for Jinja.
On the one hand it filters out invalid operators like the bitshift
operators we don't allow... | Python |
# -*- 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... | Python |
# -*- 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... | Python |
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... | Python |
# -*- 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... | Python |
# -*- 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 ... | Python |
# -*- 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... | Python |
# -*- 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... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.