<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

# This file is part of tornado_angular.
# https://github.com/heynemann/tornado-angular

# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT-license
# Copyright (c) 2014 <NAME> <EMAIL>

import sys
from os.path import abspath, join

from cow.server import Server
import cow.handlers.healthcheck as healthcheck
from tornado.httpclient import AsyncHTTPClient
import tornado.web

from tornado_angular import __version__
from tornado_angular.handlers import RequestHandler
from tornado_angular.handlers.angular_handler import (
    AngularIndexHandler,
    AngularRedirectHandler,
    AngularViewHandler,
    AngularConfigHandler
)
from tornado_angular.config import Config


def main():
    AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
    TornadoAngularServer.run()


class VersionHandler(RequestHandler):
    def get(self):
        self.write(self.application.version)


class TornadoAngularServer(Server):
    def __init__(self, debug=None, *args, **kw):
        super(TornadoAngularServer, self).__init__(*args, **kw)
        self.force_debug = debug

    def get_extra_server_parameters(self):
        return {
            'no_keep_alive': False
        }

    def get_version(self):
        return __version__

    def get_settings(self):
        settings = super(TornadoAngularServer, self).get_settings()
        return settings

    def initialize_app(self, *args, **kw):
        super(TornadoAngularServer, self).initialize_app(*args, **kw)

        if self.force_debug is not None:
            self.debug = self.force_debug

    def get_api_handlers(self):
        return [
            ('version/?', VersionHandler),
        ]

    def get_web_prefix(self):
        return "web"

    def get_api_prefix(self):
        return "api"

    def get_web_app_name(self):
        return "sandboxApp"

    def config_parser(self, parser):
        parser.add_argument('--version', action='store_true', default=False, help="Displays application's current version")

    def get_items_path(self):
        if self.debug:
            angular_path = abspath(self.config.ANGULAR_ROOT)
            items = (
                (r'bower_components', join(angular_path, 'bower_components')),
                (r'scripts', join(angular_path, '.tmp/scripts')),
                (r'styles', join(angular_path, '.tmp/styles')),
                (r'images', join(angular_path, 'app/images')),
            )
        else:
            angular_path = abspath(join(self.config.ANGULAR_ROOT, 'dist'))
            items = (
                (r'bower_components', join(angular_path, 'bower_components')),
                (r'scripts', join(angular_path, 'scripts')),
                (r'styles', join(angular_path, 'styles')),
                (r'images', join(angular_path, 'images')),
            )

        return items

    def get_web_handlers(self):
        items = self.get_items_path()

        handlers = []
        web_prefix = self.get_web_prefix()

        for url, path in items:
            handlers.append((
                r"/%s/%s/(.+)" % (web_prefix, url),
                tornado.web.StaticFileHandler,
                {'path': path}
            ))

        handlers.append((r'/%s/views/(.+)' % web_prefix, AngularViewHandler))
        handlers.append((r'/%s/config.js' % web_prefix, AngularConfigHandler))
        handlers.append((r'/%s.+' % web_prefix, AngularIndexHandler))

        return handlers

    def get_handlers(self):
        handlers = [
            ('/version/?', VersionHandler),
        ]

        api_handlers = list(self.get_api_handlers())
        api_prefix = self.get_api_prefix()

        for api_handler in api_handlers:
            handler = list(api_handler)
            handler[0] = r"/%s/%s" % (api_prefix, handler[0])
            handlers.append(handler)

        handlers.append(
            ('/(.*)', AngularRedirectHandler),
        )

        return tuple(self.get_web_handlers() + handlers)

    def get_app(self):
        handlers = [
            ('/healthcheck/?', healthcheck.HealthCheckHandler),
        ]

        handlers = handlers + list(self.get_handlers())
        settings = self.get_settings()

        return tornado.web.Application(handlers, **settings)

    def get_config(self):
        return Config

    def get_web_allowed_config(self):
        return [
            'ANGULAR_ROOT',
        ]

    def get_api_plugins(self):
        return []

    def get_plugins(self):
        return self.get_api_plugins()

    def api_after_start(self, io_loop):
        pass

    def after_start(self, io_loop):
        self.application.debug = self.debug
        self.api_after_start(io_loop)
        self.application.allowed_configuration = self.get_web_allowed_config()
        self.application.web_app_name = self.get_web_app_name()
        self.application.version = self.get_version()

    def api_before_end(self, io_loop):
        pass

    def before_end(self, io_loop):
        self.api_before_end(io_loop)

    def start(self, args=None):
        options = self.parse_arguments(args)
        if options.version:
            print ("%s - version %s" % (self.get_server_name(), self.get_version()))
            sys.exit(0)

        super(TornadoAngularServer, self).start(args)<commit_msg>removing config<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

# This file is part of tornado_angular.
# https://github.com/heynemann/tornado-angular

# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT-license
# Copyright (c) 2014 <NAME> <EMAIL>

import sys
from os.path import abspath, join

from cow.server import Server
import cow.handlers.healthcheck as healthcheck
from tornado.httpclient import AsyncHTTPClient
import tornado.web

from tornado_angular import __version__
from tornado_angular.handlers import RequestHandler
from tornado_angular.handlers.angular_handler import (
    AngularIndexHandler,
    AngularRedirectHandler,
    AngularViewHandler,
    AngularConfigHandler
)
from tornado_angular.config import Config


def main():
    AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
    TornadoAngularServer.run()


class VersionHandler(RequestHandler):
    def get(self):
        self.write(self.application.version)


class TornadoAngularServer(Server):
    def __init__(self, debug=None, *args, **kw):
        super(TornadoAngularServer, self).__init__(*args, **kw)
        self.force_debug = debug

    def get_extra_server_parameters(self):
        return {
            'no_keep_alive': False
        }

    def get_version(self):
        return __version__

    def get_settings(self):
        settings = super(TornadoAngularServer, self).get_settings()
        return settings

    def initialize_app(self, *args, **kw):
        super(TornadoAngularServer, self).initialize_app(*args, **kw)

        if self.force_debug is not None:
            self.debug = self.force_debug

    def get_api_handlers(self):
        return [
            ('version/?', VersionHandler),
        ]

    def get_web_prefix(self):
        return "web"

    def get_api_prefix(self):
        return "api"

    def get_web_app_name(self):
        return "sandboxApp"

    def config_parser(self, parser):
        parser.add_argument('--version', action='store_true', default=False, help="Displays application's current version")

    def get_items_path(self):
        if self.debug:
            angular_path = abspath(self.config.ANGULAR_ROOT)
            items = (
                (r'bower_components', join(angular_path, 'bower_components')),
                (r'scripts', join(angular_path, '.tmp/scripts')),
                (r'styles', join(angular_path, '.tmp/styles')),
                (r'images', join(angular_path, 'app/images')),
            )
        else:
            angular_path = abspath(join(self.config.ANGULAR_ROOT, 'dist'))
            items = (
                (r'bower_components', join(angular_path, 'bower_components')),
                (r'scripts', join(angular_path, 'scripts')),
                (r'styles', join(angular_path, 'styles')),
                (r'images', join(angular_path, 'images')),
            )

        return items

    def get_web_handlers(self):
        items = self.get_items_path()

        handlers = []
        web_prefix = self.get_web_prefix()

        for url, path in items:
            handlers.append((
                r"/%s/%s/(.+)" % (web_prefix, url),
                tornado.web.StaticFileHandler,
                {'path': path}
            ))

        handlers.append((r'/%s/views/(.+)' % web_prefix, AngularViewHandler))
        handlers.append((r'/%s/config.js' % web_prefix, AngularConfigHandler))
        handlers.append((r'/%s.+' % web_prefix, AngularIndexHandler))

        return handlers

    def get_handlers(self):
        handlers = [
            ('/version/?', VersionHandler),
        ]

        api_handlers = list(self.get_api_handlers())
        api_prefix = self.get_api_prefix()

        for api_handler in api_handlers:
            handler = list(api_handler)
            handler[0] = r"/%s/%s" % (api_prefix, handler[0])
            handlers.append(handler)

        handlers.append(
            ('/(.*)', AngularRedirectHandler),
        )

        return tuple(self.get_web_handlers() + handlers)

    def get_app(self):
        handlers = [
            ('/healthcheck/?', healthcheck.HealthCheckHandler),
        ]

        handlers = handlers + list(self.get_handlers())
        settings = self.get_settings()

        return tornado.web.Application(handlers, **settings)

    def get_config(self):
        return Config

    def get_web_allowed_config(self):
        return []

    def get_api_plugins(self):
        return []

    def get_plugins(self):
        return self.get_api_plugins()

    def api_after_start(self, io_loop):
        pass

    def after_start(self, io_loop):
        self.application.debug = self.debug
        self.api_after_start(io_loop)
        self.application.allowed_configuration = self.get_web_allowed_config()
        self.application.web_app_name = self.get_web_app_name()
        self.application.version = self.get_version()

    def api_before_end(self, io_loop):
        pass

    def before_end(self, io_loop):
        self.api_before_end(io_loop)

    def start(self, args=None):
        options = self.parse_arguments(args)
        if options.version:
            print ("%s - version %s" % (self.get_server_name(), self.get_version()))
            sys.exit(0)

        super(TornadoAngularServer, self).start(args)
{'fraction_non_alphanumeric': 0.11564881904582666, 'fraction_numerical': 0.0015055989460807378, 'mean_word_length': 2.5403064623584277, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2196470', 'n_tokens_mistral': 3276, 'n_tokens_neox': 3124, 'n_words': 599}