<commit_before># Initialize output before importing any module, that can use colorama.
from .system import init_output

init_output()

from argparse import ArgumentParser
from pprint import pformat
import sys
from . import logs, types
from .shells import shell
from .conf import settings
from .corrector import get_corrected_commands
from .exceptions import EmptyCommand
from .utils import get_installation_info, get_alias
from .ui import select_command


def fix_command():
    """Fixes previous command. Used when `thefuck` called without arguments."""
    settings.init()
    with logs.debug_time('Total'):
        logs.debug(u'Run with settings: {}'.format(pformat(settings)))

        try:
            command = types.Command.from_raw_script(sys.argv[1:])
        except EmptyCommand:
            logs.debug('Empty command, nothing to do')
            return

        corrected_commands = get_corrected_commands(command)
        selected_command = select_command(corrected_commands)

        if selected_command:
            selected_command.run(command)
        else:
            sys.exit(1)


def print_alias():
    """Prints alias for current shell."""
    try:
        alias = sys.argv[2]
    except IndexError:
        alias = get_alias()

    print(shell.app_alias(alias))


def how_to_configure_alias():
    """Shows useful information about how-to configure alias.

    It'll be only visible when user type fuck and when alias isn't configured.

    """
    settings.init()
    logs.how_to_configure_alias(shell.how_to_configure())


def main():
    parser = ArgumentParser(prog='thefuck')
    version = get_installation_info().version
    parser.add_argument(
            '-v', '--version',
            action='version',
            version='The Fuck {} using Python {}'.format(
                    version, sys.version.split()[0]))
    parser.add_argument('-a', '--alias',
                        action='store_true',
                        help='[custom-alias-name] prints alias for current shell')
    parser.add_argument('command',
                        nargs='*',
                        help='command that should be fixed')
    known_args = parser.parse_args(sys.argv[1:2])

    if known_args.alias:
        print_alias()
    elif known_args.command:
        fix_command()
    else:
        parser.print_usage()
<commit_msg>Ignore flake8 errors with inline comments: E402 module level import not at top of file<commit_after># Initialize output before importing any module, that can use colorama.
from .system import init_output

init_output()

from argparse import ArgumentParser  # noqa: E402
from pprint import pformat  # noqa: E402
import sys  # noqa: E402
from . import logs, types  # noqa: E402
from .shells import shell  # noqa: E402
from .conf import settings  # noqa: E402
from .corrector import get_corrected_commands  # noqa: E402
from .exceptions import EmptyCommand  # noqa: E402
from .utils import get_installation_info, get_alias  # noqa: E402
from .ui import select_command  # noqa: E402


def fix_command():
    """Fixes previous command. Used when `thefuck` called without arguments."""
    settings.init()
    with logs.debug_time('Total'):
        logs.debug(u'Run with settings: {}'.format(pformat(settings)))

        try:
            command = types.Command.from_raw_script(sys.argv[1:])
        except EmptyCommand:
            logs.debug('Empty command, nothing to do')
            return

        corrected_commands = get_corrected_commands(command)
        selected_command = select_command(corrected_commands)

        if selected_command:
            selected_command.run(command)
        else:
            sys.exit(1)


def print_alias():
    """Prints alias for current shell."""
    try:
        alias = sys.argv[2]
    except IndexError:
        alias = get_alias()

    print(shell.app_alias(alias))


def how_to_configure_alias():
    """Shows useful information about how-to configure alias.

    It'll be only visible when user type fuck and when alias isn't configured.

    """
    settings.init()
    logs.how_to_configure_alias(shell.how_to_configure())


def main():
    parser = ArgumentParser(prog='thefuck')
    version = get_installation_info().version
    parser.add_argument(
            '-v', '--version',
            action='version',
            version='The Fuck {} using Python {}'.format(
                    version, sys.version.split()[0]))
    parser.add_argument('-a', '--alias',
                        action='store_true',
                        help='[custom-alias-name] prints alias for current shell')
    parser.add_argument('command',
                        nargs='*',
                        help='command that should be fixed')
    known_args = parser.parse_args(sys.argv[1:2])

    if known_args.alias:
        print_alias()
    elif known_args.command:
        fix_command()
    else:
        parser.print_usage()

{'fraction_non_alphanumeric': 0.09965355614428367, 'fraction_numerical': 0.009374363154676992, 'mean_word_length': 2.64907063197026, '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': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2434045', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1332, 'n_words': 384}