<commit_before>import logging
import logging.config

import cherrypy

from ingredients_http.tools.model import model_in, model_out, model_out_pagination
from ingredients_http.tools.param_validation import model_params


class HTTPApplication(object):
    def __init__(self, logging_config, debug=False):
        self.logger = logging.getLogger("%s.%s" % (self.__module__, self.__class__.__name__))
        self.logging_config = logging_config
        self.debug = debug

        self.database = None
        self.__mounts = []

    def register_mount(self, mount):
        self.__mounts.append(mount)

    def __setup_logging(self):
        logging.config.dictConfig(self.logging_config)

    def __setup_mounts(self):
        config = {}

        for mount in self.__mounts:
            mount.setup()
            config[mount.mount_point] = mount.mount_config()

        cherrypy.tree.mount(None, config=config)

    def __setup_tools(self):
        cherrypy.tools.model_params = cherrypy.Tool('before_request_body', model_params, priority=10)
        cherrypy.tools.model_in = cherrypy.Tool('before_request_body', model_in, priority=20)

        cherrypy.tools.model_out = cherrypy.Tool('before_handler', model_out)<commit_msg>allow giving a None logging config<commit_after>import logging
import logging.config

import cherrypy

from ingredients_http.tools.model import model_in, model_out, model_out_pagination
from ingredients_http.tools.param_validation import model_params


class HTTPApplication(object):
    def __init__(self, logging_config, debug=False):
        self.logger = logging.getLogger("%s.%s" % (self.__module__, self.__class__.__name__))
        self.logging_config = logging_config
        self.debug = debug

        self.database = None
        self.__mounts = []

    def register_mount(self, mount):
        self.__mounts.append(mount)

    def __setup_logging(self):
        if self.logging_config is not None:
            logging.config.dictConfig(self.logging_config)

    def __setup_mounts(self):
        config = {}

        for mount in self.__mounts:
            mount.setup()
            config[mount.mount_point] = mount.mount_config()

        cherrypy.tree.mount(None, config=config)

    def __setup_tools(self):
        cherrypy.tools.model_params = cherrypy.Tool('before_request_body', model_params, priority=10)
        cherrypy.tools.model_in = cherrypy.Tool('before_request_body', model_in, priority=20)

        cherrypy.tools.model_out = cherrypy.Tool('before_handler', model_out)
{'fraction_non_alphanumeric': 0.09576573011476058, 'fraction_numerical': 0.0031658092599920855, 'mean_word_length': 3.4507042253521125, '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': '6576826', 'n_tokens_mistral': 760, 'n_tokens_neox': 726, 'n_words': 139}