<commit_before># -*- encoding: utf-8 -*-
import abc
import functools
from supriya.tools.systemtools.SupriyaObject import SupriyaObject


class SessionObject(SupriyaObject):
    """
    A non-realtime session object, analogous to ServerObjectProxy.
    """

    ### CLASS VARIABLES ###

    __documentation_section__ = 'Session Internals'

    __slots__ = ()

    ### INITIALIZER ###

    @abc.abstractmethod
    def __init__(
        self,
        session,
        ):
        from supriya.tools import nonrealtimetools
        prototype = (
            nonrealtimetools.Session,
            type(None),
            )
        assert isinstance(session, prototype)
        self._session = session

    ### PRIVATE METHODS ###

    def _get_format_specification(self):
        from abjad.tools import systemtools
        from supriya.tools import nonrealtimetools
        agent = systemtools.StorageFormatAgent(self)
        names = agent.signature_positional_names
        values = (agent._get(_) for _ in names)
        values = [
            _ for _ in values
            if not isinstance(_, nonrealtimetools.Session)
            ]
        return systemtools.FormatSpecification(
            client=self,
            storage_format_args_values=values,
            )

    ### PUBLIC METHODS ###

    @staticmethod
    def require_offset(function):
        @functools.wraps(function)
        def wrapper(self, *args, **kwargs):
            if isinstance(self, nonrealtimetools.Session):
                session = self
            else:
                session = self.session
            if 'offset' not in kwargs or kwargs['offset'] is None:
                if not session._active_moments:
                    raise ValueError('No active moment.')
                offset = session._active_moments[-1].offset
                kwargs['offset'] = offset
            if isinstance(self, SessionObject):
                if not (self.start_offset <= kwargs['offset'] <= self.stop_offset):
                    raise ValueError('Offset {} must intersect [{}, {}]'.format(
                        float(offset), self.start_offset, self.stop_offset))
            with session.at(kwargs['offset']):
                return function(self, *args, **kwargs)
        from supriya.tools import nonrealtimetools
        return wrapper

    ### PUBLIC PROPERTIES ###

    @property
    def session(self):
        return self._session<commit_msg>Moved one import for Python 3.4 compatibility.<commit_after># -*- encoding: utf-8 -*-
import abc
import functools
from supriya.tools.systemtools.SupriyaObject import SupriyaObject


class SessionObject(SupriyaObject):
    """
    A non-realtime session object, analogous to ServerObjectProxy.
    """

    ### CLASS VARIABLES ###

    __documentation_section__ = 'Session Internals'

    __slots__ = ()

    ### INITIALIZER ###

    @abc.abstractmethod
    def __init__(
        self,
        session,
        ):
        from supriya.tools import nonrealtimetools
        prototype = (
            nonrealtimetools.Session,
            type(None),
            )
        assert isinstance(session, prototype)
        self._session = session

    ### PRIVATE METHODS ###

    def _get_format_specification(self):
        from abjad.tools import systemtools
        from supriya.tools import nonrealtimetools
        agent = systemtools.StorageFormatAgent(self)
        names = agent.signature_positional_names
        values = (agent._get(_) for _ in names)
        values = [
            _ for _ in values
            if not isinstance(_, nonrealtimetools.Session)
            ]
        return systemtools.FormatSpecification(
            client=self,
            storage_format_args_values=values,
            )

    ### PUBLIC METHODS ###

    @staticmethod
    def require_offset(function):
        @functools.wraps(function)
        def wrapper(self, *args, **kwargs):
            from supriya.tools import nonrealtimetools
            if isinstance(self, nonrealtimetools.Session):
                session = self
            else:
                session = self.session
            if 'offset' not in kwargs or kwargs['offset'] is None:
                if not session._active_moments:
                    raise ValueError('No active moment.')
                offset = session._active_moments[-1].offset
                kwargs['offset'] = offset
            if isinstance(self, SessionObject):
                if not (self.start_offset <= kwargs['offset'] <= self.stop_offset):
                    raise ValueError('Offset {} must intersect [{}, {}]'.format(
                        float(offset), self.start_offset, self.stop_offset))
            with session.at(kwargs['offset']):
                return function(self, *args, **kwargs)
        return wrapper

    ### PUBLIC PROPERTIES ###

    @property
    def session(self):
        return self._session
{'fraction_non_alphanumeric': 0.0925281473899693, 'fraction_numerical': 0.0012282497441146367, 'mean_word_length': 2.0179122915379866, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7313093', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1253, 'n_words': 305}