<commit_before>import argparse
import signal
import sys

from tornado import ioloop, web, httpserver

from . import api
from .log import setup_logger, INFO
from .task import Controller


def parse_args(args):
    parser = argparse.ArgumentParser('acddl')

    parser.add_argument('-l', '--listen', required=True, type=int)
    parser.add_argument('-r', '--root', required=True, type=str)

    args = parser.parse_args(args)

    return args


def main(args=None):
    if args is None:
        args = sys.argv

    args = parse_args(args[1:])
    setup_logger('/tmp/acddl.log')
    main_loop = ioloop.IOLoop.instance()

    controller = Controller(args.root)
    signal.signal(signal.SIGINT, controller.stop)

    application = web.Application([
        (r'/nodes', api.NodesHandler),
        (r'/nodes/([a-zA-Z0-9\-_]{22})', api.NodesHandler),
        (r'/equality', api.EqualityHandler),
    ], controller=controller)
    server = httpserver.HTTPServer(application)
    server.listen(args.listen)

    INFO('acddl') << 'ready'

    main_loop.start()
    main_loop.close()

    return 0
<commit_msg>change name<commit_after>import argparse
import signal
import sys

from tornado import ioloop, web, httpserver

from . import api
from .log import setup_logger, INFO
from .task import RootController


def parse_args(args):
    parser = argparse.ArgumentParser('acddl')

    parser.add_argument('-l', '--listen', required=True, type=int)
    parser.add_argument('-r', '--root', required=True, type=str)

    args = parser.parse_args(args)

    return args


def main(args=None):
    if args is None:
        args = sys.argv

    args = parse_args(args[1:])
    setup_logger('/tmp/acddl.log')
    main_loop = ioloop.IOLoop.instance()

    controller = RootController(args.root)
    signal.signal(signal.SIGINT, controller.stop)

    application = web.Application([
        (r'/nodes', api.NodesHandler),
        (r'/nodes/([a-zA-Z0-9\-_]{22})', api.NodesHandler),
        (r'/equality', api.EqualityHandler),
    ], controller=controller)
    server = httpserver.HTTPServer(application)
    server.listen(args.listen)

    INFO('acddl') << 'ready'

    main_loop.start()
    main_loop.close()

    return 0

{'fraction_non_alphanumeric': 0.13883847549909256, 'fraction_numerical': 0.0054446460980036296, 'mean_word_length': 3.3924302788844622, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5645843', 'n_tokens_mistral': 742, 'n_tokens_neox': 707, 'n_words': 151}