<commit_before>"""Resources for managing assets."""

from pyramid.registry import Registry

from adhocracy_core.interfaces import IPool
from adhocracy_core.interfaces import IServicePool
from adhocracy_core.interfaces import ISimple
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.pool import IBasicPool
from adhocracy_core.resources.pool import basicpool_metadata
from adhocracy_core.resources.service import service_metadata
from adhocracy_core.resources.simple import simple_metadata
from adhocracy_core.sheets.asset import IHasAssetPool


class IPoolWithAssets(IBasicPool):

    """A pool with an auto-created asset pool."""


class IAsset(ISimple):

    """Comment versions pool."""


asset_meta = simple_metadata._replace(
    content_name='Asset',
    iresource=IAsset,
    use_autonaming=True,
    permission_add='add_asset',
)


class IAssetsService(IServicePool):

    """The 'assets' ServicePool."""


assets_service_meta = service_metadata._replace(
    iresource=IAssetsService,
    content_name='assets',
    element_types=[IAsset],
)


def add_assets_service(context: IPool, registry: Registry, options: dict):
    """Add `assets` service to context."""
    registry.content.create(IAssetsService.__identifier__, parent=context)


pool_with_assets_meta = basicpool_metadata._replace(
    iresource=IPoolWithAssets,
    basic_sheets=basicpool_metadata.basic_sheets + [IHasAssetPool],
    after_creation=basicpool_metadata.after_creation + [add_assets_service],
)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(asset_meta, config)
    add_resource_type_to_registry(assets_service_meta, config)
    add_resource_type_to_registry(pool_with_assets_meta, config)<commit_msg>Add new sheets to asset resource<commit_after>"""Resources for managing assets."""

from pyramid.registry import Registry

from adhocracy_core.interfaces import IPool
from adhocracy_core.interfaces import IServicePool
from adhocracy_core.interfaces import ISimple
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.pool import IBasicPool
from adhocracy_core.resources.pool import basicpool_metadata
from adhocracy_core.resources.service import service_metadata
from adhocracy_core.resources.simple import simple_metadata
import adhocracy_core.sheets.asset


class IPoolWithAssets(IBasicPool):

    """A pool with an auto-created asset pool."""


class IAsset(ISimple):

    """A generic asset."""


asset_meta = simple_metadata._replace(
    content_name='Asset',
    iresource=IAsset,
    basic_sheets=simple_metadata.basic_sheets + [
        adhocracy_core.sheets.asset.IAssetMetadata,
        adhocracy_core.sheets.asset.IAssetData
    ],
    use_autonaming=True,
    permission_add='add_asset',
)


class IAssetsService(IServicePool):

    """The 'assets' ServicePool."""


assets_service_meta = service_metadata._replace(
    iresource=IAssetsService,
    content_name='assets',
    element_types=[IAsset],
)


def add_assets_service(context: IPool, registry: Registry, options: dict):
    """Add `assets` service to context."""
    registry.content.create(IAssetsService.__identifier__, parent=context)


pool_with_assets_meta = basicpool_metadata._replace(
    iresource=IPoolWithAssets,
    basic_sheets=basicpool_metadata.basic_sheets + [
                 adhocracy_core.sheets.asset.IHasAssetPool],
    after_creation=basicpool_metadata.after_creation + [add_assets_service],
)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(asset_meta, config)
    add_resource_type_to_registry(assets_service_meta, config)
    add_resource_type_to_registry(pool_with_assets_meta, config)
{'fraction_non_alphanumeric': 0.08337758895379713, 'fraction_numerical': 0.0, 'mean_word_length': 5.8992673992674, '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': '3430068', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1110, 'n_words': 221}