<commit_before># -*- coding: utf-8 -*-

import sys
import logging
import argparse

from gunicorn.app.base import BaseApplication
from gunicorn.six import iteritems
from gunicorn import config

from openfisca_core.scripts import add_tax_benefit_system_arguments, build_tax_benefit_system
from openfisca_web_api_preview.app import create_app


"""
    Define the `openfisca serve` command line interface.
"""

DEFAULT_PORT = '6000'
HOST = '127.0.0.1'
DEFAULT_WORKERS_NUMBER = '3'


log = logging.getLogger(__name__)


def define_command_line_options(parser):
    # Define OpenFisca modules configuration
    parser = add_tax_benefit_system_arguments(parser)

    # Define server configuration
    parser.add_argument('-p', '--port', action = 'store', help = "port to serve on", type = int)
    parser.add_argument('--tracker-url', action = 'store', help = "tracking service url", type = str)
    parser.add_argument('--tracker-idsite', action = 'store', help = "tracking service id site", type = int)
    parser.add_argument('--tracker-token', action = 'store', help = "tracking service authentication token", type = str)
    parser.add_argument('-f', '--configuration-file', action = 'store', help = "configuration file", type = str)

    return parser


def read_user_configuration(default_configuration, command_line_parser):
    configuration = default_configuration
    args, unknown_args = command_line_parser.parse_known_args()

    if args.configuration_file:
        file_configuration = {}
        execfile(args.configuration_file, {}, file_configuration)

        # Configuration file overloads default configuration
        update(configuration, file_configuration)

    # Command line configuration overloads all configuration<commit_msg>Fix openfisca serve -f ...<commit_after># -*- coding: utf-8 -*-

import sys
import logging
import argparse

from gunicorn.app.base import BaseApplication
from gunicorn.six import iteritems
from gunicorn import config

from openfisca_core.scripts import add_tax_benefit_system_arguments, build_tax_benefit_system
from openfisca_web_api_preview.app import create_app


"""
    Define the `openfisca serve` command line interface.
"""

DEFAULT_PORT = '6000'
HOST = '127.0.0.1'
DEFAULT_WORKERS_NUMBER = '3'


log = logging.getLogger(__name__)


def define_command_line_options(parser):
    # Define OpenFisca modules configuration
    parser = add_tax_benefit_system_arguments(parser)

    # Define server configuration
    parser.add_argument('-p', '--port', action = 'store', help = "port to serve on", type = int)
    parser.add_argument('--tracker-url', action = 'store', help = "tracking service url", type = str)
    parser.add_argument('--tracker-idsite', action = 'store', help = "tracking service id site", type = int)
    parser.add_argument('--tracker-token', action = 'store', help = "tracking service authentication token", type = str)
    parser.add_argument('-f', '--configuration-file', action = 'store', help = "configuration file", type = str)

    return parser


def read_user_configuration(default_configuration, command_line_parser):
    configuration = default_configuration
    args, unknown_args = command_line_parser.parse_known_args()

    if args.configuration_file:
        file_configuration = {}
        with open(args.configuration_file, "r") as file:
            exec(file.read(), {}, file_configuration)

        # Configuration file overloads default configuration
        update(configuration, file_configuration)

    # Command line configuration overloads all configuration
{'fraction_non_alphanumeric': 0.10208098987626546, 'fraction_numerical': 0.006749156355455568, 'mean_word_length': 4.514728682170543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3942669', 'n_tokens_mistral': 1029, 'n_tokens_neox': 982, 'n_words': 274}