<commit_before>import json

from tornado.template import Loader, Template

from social.utils import build_absolute_uri
from social.strategies.base import BaseStrategy, BaseTemplateStrategy


class TornadoTemplateStrategy(BaseTemplateStrategy):
    def render_template(self, tpl, context):
        path, tpl = tpl.rsplit('/', 1)
        return Loader(path).load(tpl).generate(**context)

    def render_string(self, html, context):
        return Template(html).generate(**context)


class TornadoStrategy(BaseStrategy):
    DEFAULT_TEMPLATE_STRATEGY = TornadoTemplateStrategy

    def __init__(self, storage, request_handler, tpl=None):
        self.request_handler = request_handler
        self.request = self.request_handler.request
        super(TornadoStrategy, self).__init__(storage, tpl)

    def get_setting(self, name):
        return self.request_handler.settings[name]

    def request_data(self, merge=True):
        # Multiple valued arguments not supported yet
        return {key: val[0] for key, val in self.request.arguments.iteritems()}

    def request_host(self):
        return self.request.host

    def redirect(self, url):
        return self.request_handler.redirect(url)

    def html(self, content):
        self.request_handler.write(content)<commit_msg>Fix syntax (backward compatible)<commit_after>import json

from tornado.template import Loader, Template

from social.utils import build_absolute_uri
from social.strategies.base import BaseStrategy, BaseTemplateStrategy


class TornadoTemplateStrategy(BaseTemplateStrategy):
    def render_template(self, tpl, context):
        path, tpl = tpl.rsplit('/', 1)
        return Loader(path).load(tpl).generate(**context)

    def render_string(self, html, context):
        return Template(html).generate(**context)


class TornadoStrategy(BaseStrategy):
    DEFAULT_TEMPLATE_STRATEGY = TornadoTemplateStrategy

    def __init__(self, storage, request_handler, tpl=None):
        self.request_handler = request_handler
        self.request = self.request_handler.request
        super(TornadoStrategy, self).__init__(storage, tpl)

    def get_setting(self, name):
        return self.request_handler.settings[name]

    def request_data(self, merge=True):
        # Multiple valued arguments not supported yet
        return dict((key, val[0])
                for key, val in self.request.arguments.iteritems())

    def request_host(self):
        return self.request.host

    def redirect(self, url):
        return self.request_handler.redirect(url)

    def html(self, content):
        self.request_handler.write(content)
{'fraction_non_alphanumeric': 0.09205983889528194, 'fraction_numerical': 0.0015343306482546988, 'mean_word_length': 3.8475836431226766, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2217291', 'n_tokens_mistral': 745, 'n_tokens_neox': 714, 'n_words': 172}