<commit_before>import sys
import os
import os.path
import shutil
from pathlib import Path
import functools

import click
from doit.doit_cmd import DoitMain
from doit.cmd_base import ModuleTaskLoader
from doit.runner import ERROR

from elm_doc.tasks import build_task_creators
from elm_doc.elm_project import ProjectConfig


class DoitException(click.ClickException):
    def __init__(self, message, exit_code):
        click.ClickException.__init__(self, message)
        self.exit_code = exit_code


def validate_mount_at(ctx, param, value):
    if len(value) == 0 or value.startswith('/'):
        return value
    else:
        raise click.BadParameter('should be an absolute path, like /{}'.format(value))


def validate_elm_path(ctx, param, value):
    if value is None:
        return value

    realpath = os.path.realpath(value)
    if not os.path.isfile(realpath):
        realpath = shutil.which(value)

    if realpath is None or not os.path.isfile(realpath):
        raise click.BadParameter('{} not found'.format(value))


def _resolve_path(path: str) -> Path:
    # not using Path.resolve() for now because we don't expect strict
    # existence checking. maybe we should.
    return Path(os.path.normpath(os.path.abspath(path)))


def _translate_click_exception_exit_code(fn):
    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        try:
            return fn(*args, **kwargs)
        except click.ClickException as e:
            if not isinstance(e, DoitException):
                e.exit_code = ERROR
            raise e
    return wrapper


class LazyOutfile:
    def write(self, *args, **kwargs):
        sys.stdout.write(*args, **kwargs)


@click.command(context_settings=dict(
    ignore_unknown_options=True,<commit_msg>Fix: specified elm binary should be used<commit_after>import sys
import os
import os.path
import shutil
from pathlib import Path
import functools

import click
from doit.doit_cmd import DoitMain
from doit.cmd_base import ModuleTaskLoader
from doit.runner import ERROR

from elm_doc.tasks import build_task_creators
from elm_doc.elm_project import ProjectConfig


class DoitException(click.ClickException):
    def __init__(self, message, exit_code):
        click.ClickException.__init__(self, message)
        self.exit_code = exit_code


def validate_mount_at(ctx, param, value):
    if len(value) == 0 or value.startswith('/'):
        return value
    else:
        raise click.BadParameter('should be an absolute path, like /{}'.format(value))


def validate_elm_path(ctx, param, value):
    if value is None:
        return value

    realpath = os.path.realpath(value)
    if not os.path.isfile(realpath):
        realpath = shutil.which(value)

    if realpath is None or not os.path.isfile(realpath):
        raise click.BadParameter('{} not found'.format(value))

    return value


def _resolve_path(path: str) -> Path:
    # not using Path.resolve() for now because we don't expect strict
    # existence checking. maybe we should.
    return Path(os.path.normpath(os.path.abspath(path)))


def _translate_click_exception_exit_code(fn):
    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        try:
            return fn(*args, **kwargs)
        except click.ClickException as e:
            if not isinstance(e, DoitException):
                e.exit_code = ERROR
            raise e
    return wrapper


class LazyOutfile:
    def write(self, *args, **kwargs):
        sys.stdout.write(*args, **kwargs)


@click.command(context_settings=dict(
    ignore_unknown_options=True,
{'fraction_non_alphanumeric': 0.09372361384745286, 'fraction_numerical': 0.0005629045876723895, 'mean_word_length': 3.32360097323601, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6393584', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1056, 'n_words': 305}