<commit_before>"""
Project handling for the pprof study.
"""
from os import path, listdir
from abc import abstractmethod
from plumbum import local
from plumbum.cmd import mv, chmod, rm, mkdir, rmdir  # pylint: disable=E0401
from pprof.settings import config
from pprof.utils.db import persist_project

PROJECT_BIN_F_EXT = ".bin"
PROJECT_BLOB_F_EXT = ".postproc"


class ProjectRegistry(type):
    """Registry for pprof projects."""

    projects = {}

    def __init__(cls, name, bases, dict):
        """Registers a project in the registry."""
        super(ProjectRegistry, cls).__init__(name, bases, dict)

        ebuild_data = {}
        env_values = config["pprof-ebuild"].split('/')
        if env_values != "":
            ebuild_data["domain"] = env_values[0]
            ebuild_data["ebuild"] = env_values[1]

        if cls.NAME is not None and cls.DOMAIN is not None:
            cls.NAME = cls.NAME.format(**ebuild_data)
            cls.DOMAIN = cls.DOMAIN.format(**ebuild_data)
            ProjectRegistry.projects[cls.NAME] = cls
<commit_msg>only create generic gentoo project if env var is set<commit_after>"""
Project handling for the pprof study.
"""
from os import path, listdir
from abc import abstractmethod
from plumbum import local
from plumbum.cmd import mv, chmod, rm, mkdir, rmdir  # pylint: disable=E0401
from pprof.settings import config
from pprof.utils.db import persist_project

PROJECT_BIN_F_EXT = ".bin"
PROJECT_BLOB_F_EXT = ".postproc"


class ProjectRegistry(type):
    """Registry for pprof projects."""

    projects = {}

    def __init__(cls, name, bases, dict):
        """Registers a project in the registry."""
        super(ProjectRegistry, cls).__init__(name, bases, dict)

        ebuild_data = {}
        env_values = config["pprof-ebuild"].split('/')
        gen_project = config["pprof-ebuild"] != ""
        if gen_project:
            ebuild_data["domain"] = env_values[0]
            ebuild_data["ebuild"] = env_values[1]

        if cls.NAME is not None and cls.DOMAIN is not None:
            if gen_project or not "{domain}" in cls.NAME:
                cls.NAME = cls.NAME.format(**ebuild_data)
                cls.DOMAIN = cls.DOMAIN.format(**ebuild_data)
                ProjectRegistry.projects[cls.NAME] = cls

{'fraction_non_alphanumeric': 0.1128250330542089, 'fraction_numerical': 0.005288673424416042, 'mean_word_length': 3.010600706713781, 'pattern_counts': {'":': 1, '<': 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': '1254133', 'n_tokens_mistral': 713, 'n_tokens_neox': 702, 'n_words': 196}