<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals

import logging

from flask_script import prompt_bool

from udata.commands import manager, IS_INTERACTIVE, green
from udata.core.dataset.commands import licenses
from udata.core.user import commands as user_commands
from udata.i18n import lazy_gettext as _
from udata.search.commands import init as init_search

from .db import migrate
from .fixtures import generate_fixtures

log = logging.getLogger(__name__)


@manager.command
def init():
    '''Initialize your udata instance (search index, user, sample data...)'''

    log.info('Apply DB migrations if needed')
    migrate(record=True)

    init_search(delete=True, force=not IS_INTERACTIVE)

    if IS_INTERACTIVE:
        text = _('Do you want to create a superadmin user ?')
        if prompt_bool(text, default=True):
            user = user_commands.create()
            user_commands.set_admin(user.email)

        text = _('Do you want to import some data-related license ?')
        if prompt_bool(text, default=True):
            licenses()

        text = _('Do you want to create some sample data ?')
        if prompt_bool(text, default=True):
            generate_fixtures()

    log.info(green(_('Your udata instance is ready !')))<commit_msg>No extra space before punctuation in English<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals

import logging

from flask_script import prompt_bool

from udata.commands import manager, IS_INTERACTIVE, green
from udata.core.dataset.commands import licenses
from udata.core.user import commands as user_commands
from udata.i18n import lazy_gettext as _
from udata.search.commands import init as init_search

from .db import migrate
from .fixtures import generate_fixtures

log = logging.getLogger(__name__)


@manager.command
def init():
    '''Initialize your udata instance (search index, user, sample data...)'''

    log.info('Apply DB migrations if needed')
    migrate(record=True)

    init_search(delete=True, force=not IS_INTERACTIVE)

    if IS_INTERACTIVE:
        text = _('Do you want to create a superadmin user?')
        if prompt_bool(text, default=True):
            user = user_commands.create()
            user_commands.set_admin(user.email)

        text = _('Do you want to import some data-related license?')
        if prompt_bool(text, default=True):
            licenses()

        text = _('Do you want to create some sample data?')
        if prompt_bool(text, default=True):
            generate_fixtures()

    log.info(green(_('Your udata instance is ready!')))
{'fraction_non_alphanumeric': 0.08962083492914592, 'fraction_numerical': 0.002297970126388357, 'mean_word_length': 3.4802744425385934, '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': '6307750', 'n_tokens_mistral': 743, 'n_tokens_neox': 732, 'n_words': 244}