<commit_before>"""View classes.

For copyright, license, and warranty, see bottom of file.
"""

import sys
from schevo.lib import optimize

from schevo import base
from schevo.constant import UNASSIGNED
from schevo import field
from schevo.field import not_fget
from schevo.fieldspec import (
    FieldDefinition, FieldMap, FieldSpecMap, field_spec_from_class)
from schevo.label import label, label_from_name
from schevo.meta import schema_metaclass
import schevo.namespace
from schevo.namespace import NamespaceExtension


class View(base.View):
    """Views mimic the behavior of entities, while providing
    alternative information about them."""

    __metaclass__ = schema_metaclass('V')

    __slots__ = ['_entity', '_extent', '_field_map', '_oid',
                 'f', 'm', 'q', 'sys', 't', 'v', 'x']

    _field_spec = FieldSpecMap()

    _hidden_actions = set()
    _hidden_queries = set()

    def __init__(self, entity):
        self._entity = entity
        self._extent = entity._extent
        self._oid = entity._oid
        f = self._field_map = self._field_spec.field_map(instance=self)
        f.update_values(entity.sys.field_map(not_fget))
        self._setup(entity)
        # All fields should be readonly by default.
        for field in f.itervalues():
            field.readonly = True

    def _setup(self, entity):
        """Override this in subclasses to customize a transaction."""
        pass

    def __getattr__(self, name):
        if name == 'sys':
            self.sys = attr = ViewSys(self)
        elif name == 'f':
            self.f = attr = schevo.namespace.Fields(self)
        elif name == 'm' and self._entity is not None:
            self.m = attr = self._entity.m
        elif name == 'q' and self._entity is not None:
            self.q = attr = self._entity.q
        elif name == 't' and self._entity is not None:
            self.t = attr = ViewTransactions(self._entity, self)
        elif name == 'v' and self._entity is not None:<commit_msg>cut, paste, bork<commit_after>"""View classes.

For copyright, license, and warranty, see bottom of file.
"""

import sys
from schevo.lib import optimize

from schevo import base
from schevo.constant import UNASSIGNED
from schevo import field
from schevo.field import not_fget
from schevo.fieldspec import (
    FieldDefinition, FieldMap, FieldSpecMap, field_spec_from_class)
from schevo.label import label, label_from_name
from schevo.meta import schema_metaclass
import schevo.namespace
from schevo.namespace import NamespaceExtension


class View(base.View):
    """Views mimic the behavior of entities, while providing
    alternative information about them."""

    __metaclass__ = schema_metaclass('V')

    __slots__ = ['_entity', '_extent', '_field_map', '_oid',
                 'f', 'm', 'q', 'sys', 't', 'v', 'x']

    _field_spec = FieldSpecMap()

    _hidden_actions = set()
    _hidden_queries = set()

    def __init__(self, entity):
        self._entity = entity
        self._extent = entity._extent
        self._oid = entity._oid
        f = self._field_map = self._field_spec.field_map(instance=self)
        f.update_values(entity.sys.field_map(not_fget))
        self._setup(entity)
        # All fields should be readonly by default.
        for field in f.itervalues():
            field.readonly = True

    def _setup(self, entity):
        """Override this in subclasses to customize a view."""
        pass

    def __getattr__(self, name):
        if name == 'sys':
            self.sys = attr = ViewSys(self)
        elif name == 'f':
            self.f = attr = schevo.namespace.Fields(self)
        elif name == 'm' and self._entity is not None:
            self.m = attr = self._entity.m
        elif name == 'q' and self._entity is not None:
            self.q = attr = self._entity.q
        elif name == 't' and self._entity is not None:
            self.t = attr = ViewTransactions(self._entity, self)
        elif name == 'v' and self._entity is not None:
{'fraction_non_alphanumeric': 0.10325814536340852, 'fraction_numerical': 0.0, 'mean_word_length': 2.747417840375587, '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': '2587980', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1163, 'n_words': 371}