<commit_before>import re

import os
from compose.cli.command import get_project
import compose.cli.command as cmd
from compose.cli.main import TopLevelCommand, perform_command
from compose.cli.utils import get_version_info
from compose.config.config import load
from compose.config.environment import Environment
from compose.const import DEFAULT_TIMEOUT
from compose.project import Project, ProjectNetworks
from compose.service import ConvergenceStrategy, BuildAction, Service
from compose.config.validation import load_jsonschema, get_resolver_path, \
    handle_errors, process_config_schema_errors, \
    process_service_constraint_errors
from dork_compose.helpers import tru

from functools import partial

from jsonschema import Draft4Validator
from jsonschema import FormatChecker
from jsonschema import RefResolver
import dork_compose


import logging
log = logging.getLogger(__name__)


def dork_get_version_info(scope):
    return '%s%sdork-compose version %s, build %s ' % (
        get_version_info(scope),
        ', ' if scope == 'compose' else '\n',
        dork_compose.__version__,
        dork_get_build_version()
    )


def dork_get_build_version():
    filename = os.path.join(os.path.dirname(dork_compose.__file__), 'GITSHA')
    if not os.path.exists(filename):
        return 'unknown'
    with open(filename) as fh:
        return fh.read().strip()


def dork_perform_command(options, handler, command_options):
    if '--timeout' in options and not options['--timeout']:
        options['--timeout'] = os.environ.get('DORK_DEFAULT_TIMEOUT', DEFAULT_TIMEOUT)
    return perform_command(options, handler, command_options)


def dork_config_load(plugins, config_details):
    config_data = load(config_details)
    for plugin in plugins:
        plugin.preprocess_config(config_data)
    return config_data


def get_dork_project(plugins, project_dir, config_path=None, project_name=None,
                     verbose=False, host=None, tls_config=None,
                     environment=None):

    cmd.config.load = partial(dork_config_load, plugins)
    project = get_project(project_dir, config_path, project_name, verbose, host, tls_config, environment)

    if 'COMPOSE_PROJECT_NAME' in os.environ:
        project.name = os.environ['COMPOSE_PROJECT_NAME']

    return DorkProject.from_project(project, plugins)


def get_dork_project_name(working_dir, project_name=None, environment=None):
    def normalize_name(name):
        # Full copy because compose strips dashes from project names.
        return re.sub(r'[^a-z0-9\-]', '', name.lower())

    if not environment:
        environment = Environment.from_env_file(working_dir)
    project_name = project_name or environment.get('COMPOSE_PROJECT_NAME')
    if project_name:
        return normalize_name(project_name)

    project = os.path.basename(os.path.abspath(working_dir))
    if project:
        return normalize_name(project)

    return 'default'<commit_msg>Fixed get_project signature change.<commit_after>import re

import os
from compose.cli.command import get_project
import compose.cli.command as cmd
from compose.cli.main import TopLevelCommand, perform_command
from compose.cli.utils import get_version_info
from compose.config.config import load
from compose.config.environment import Environment
from compose.const import DEFAULT_TIMEOUT
from compose.project import Project, ProjectNetworks
from compose.service import ConvergenceStrategy, BuildAction, Service
from compose.config.validation import load_jsonschema, get_resolver_path, \
    handle_errors, process_config_schema_errors, \
    process_service_constraint_errors
from dork_compose.helpers import tru

from functools import partial

from jsonschema import Draft4Validator
from jsonschema import FormatChecker
from jsonschema import RefResolver
import dork_compose


import logging
log = logging.getLogger(__name__)


def dork_get_version_info(scope):
    return '%s%sdork-compose version %s, build %s ' % (
        get_version_info(scope),
        ', ' if scope == 'compose' else '\n',
        dork_compose.__version__,
        dork_get_build_version()
    )


def dork_get_build_version():
    filename = os.path.join(os.path.dirname(dork_compose.__file__), 'GITSHA')
    if not os.path.exists(filename):
        return 'unknown'
    with open(filename) as fh:
        return fh.read().strip()


def dork_perform_command(options, handler, command_options):
    if '--timeout' in options and not options['--timeout']:
        options['--timeout'] = os.environ.get('DORK_DEFAULT_TIMEOUT', DEFAULT_TIMEOUT)
    return perform_command(options, handler, command_options)


def dork_config_load(plugins, config_details):
    config_data = load(config_details)
    for plugin in plugins:
        plugin.preprocess_config(config_data)
    return config_data


def get_dork_project(plugins, project_dir, config_path=None, project_name=None,
                     verbose=False, host=None, tls_config=None,
                     environment=None, override_dir=None):

    cmd.config.load = partial(dork_config_load, plugins)
    project = get_project(project_dir, config_path, project_name, verbose, host, tls_config, environment, override_dir)

    if 'COMPOSE_PROJECT_NAME' in os.environ:
        project.name = os.environ['COMPOSE_PROJECT_NAME']

    return DorkProject.from_project(project, plugins)


def get_dork_project_name(working_dir, project_name=None, environment=None):
    def normalize_name(name):
        # Full copy because compose strips dashes from project names.
        return re.sub(r'[^a-z0-9\-]', '', name.lower())

    if not environment:
        environment = Environment.from_env_file(working_dir)
    project_name = project_name or environment.get('COMPOSE_PROJECT_NAME')
    if project_name:
        return normalize_name(project_name)

    project = os.path.basename(os.path.abspath(working_dir))
    if project:
        return normalize_name(project)

    return 'default'
{'fraction_non_alphanumeric': 0.08429890848026868, 'fraction_numerical': 0.0010075566750629723, 'mean_word_length': 4.303650934995548, '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': '2102495', 'n_tokens_mistral': 1792, 'n_tokens_neox': 1739, 'n_words': 420}