Beispiel #1
0
def test_strip_controls():
    # We want control codes like \x0c to disappear.
    eq_('I ove you', helpers.strip_controls('I \x0cove you'))
Beispiel #2
0
def test_strip_controls():
    # We want control codes like \x0c to disappear.
    eq_('I ove you', helpers.strip_controls('I \x0cove you'))
Beispiel #3
0
from django.conf import settings

from jinja2 import Environment, FileSystemLoader
from rest_framework.compat import etree, six
from rest_framework.exceptions import ParseError
from rest_framework.parsers import JSONParser, XMLParser

import amo.utils
from amo.helpers import strip_controls

from mkt.constants import ratingsbodies

root = os.path.join(settings.ROOT, 'lib', 'iarc')
env = Environment(loader=FileSystemLoader(os.path.join(root, 'templates')))
env.finalize = lambda x: strip_controls(x)


def render_xml(template, context):
    """
    Renders an XML template given a dict of the context.

    This also strips control characters before encoding.

    """
    # All XML passed requires a password. Let's add it to the context.
    context['password'] = settings.IARC_PASSWORD
    context['platform'] = settings.IARC_PLATFORM

    template = env.get_template(template)
    return template.render(**context)
Beispiel #4
0
def test_strip_controls():
    # We want control codes like \x0c to disappear.
    eq_("I ove you", helpers.strip_controls("I \x0cove you"))
Beispiel #5
0
from django.conf import settings

from jinja2 import Environment, FileSystemLoader
from rest_framework.compat import etree, six
from rest_framework.exceptions import ParseError
from rest_framework.parsers import JSONParser, XMLParser

import amo.utils
from amo.helpers import strip_controls

from mkt.constants import ratingsbodies


root = os.path.join(settings.ROOT, 'lib', 'iarc')
env = Environment(loader=FileSystemLoader(os.path.join(root, 'templates')))
env.finalize = lambda x: strip_controls(x)


def render_xml(template, context):
    """
    Renders an XML template given a dict of the context.

    This also strips control characters before encoding.

    """
    # All XML passed requires a password. Let's add it to the context.
    context['password'] = settings.IARC_PASSWORD
    context['platform'] = settings.IARC_PLATFORM

    template = env.get_template(template)
    return template.render(**context)