# Path: consort/tools/HashCachingObject.py
# class HashCachingObject(abctools.AbjadValueObject):
# 
#     ### CLASS VARIABLES ###
# 
#     __slots__ = (
#         '_format',
#         '_hash',
#         )
# 
#     ### INITIALIZER ###
# 
#     def __init__(self):
#         self._format = None
#         self._hash = None
# 
#     ### SPECIAL METHODS ###
# 
#     #@profile
#     def __eq__(self, expr):
#         if isinstance(expr, type(self)):
#             if format(self) == format(expr):
#                 return True
#         return False
# 
#     #@profile
#     def __format__(self, format_specification=''):
#         if self._format is None:
#             agent = systemtools.StorageFormatAgent(self)
#             self._format = agent.get_storage_format()
#         return self._format
# 
#     #@profile
#     def __hash__(self):
#         if self._hash is None:
#             self._hash = hash((type(self), format(self)))
#         return self._hash


import abjad
from abjad import attach
from abjad import inspect
from abjad import mutate
from abjad import select
from abjad.tools import durationtools
from abjad.tools import selectiontools
from consort.tools.HashCachingObject import HashCachingObject
        leaf=None,
        attachments=None,
        ):
        HashCachingObject.__init__(self)
        prototype = abjad.Leaf
        if leaf is not None:
            if isinstance(leaf, prototype):
                leaf = mutate(leaf).copy()
            elif issubclass(leaf, prototype):
                leaf = leaf()
            else:
                raise ValueError(leaf)
        self._leaf = leaf
        if attachments is not None:
            attachments = tuple(attachments)
        self._attachments = attachments

    ### SPECIAL METHODS ###

    def __call__(self, expr):
        if isinstance(expr, abjad.Leaf):
            expr = select(expr)
        assert isinstance(expr, selectiontools.Selection)
        for i, old_leaf in enumerate(expr):
            assert isinstance(old_leaf, abjad.Leaf)
            new_leaf = self._make_new_leaf(old_leaf)

            timespan = old_leaf._timespan
            start_offset = old_leaf._start_offset
            stop_offset = old_leaf._stop_offset

# Path: consort/tools/HashCachingObject.py
# class HashCachingObject(abctools.AbjadValueObject):
# 
#     ### CLASS VARIABLES ###
# 
#     __slots__ = (
#         '_format',
#         '_hash',
#         )
# 
#     ### INITIALIZER ###
# 
#     def __init__(self):
#         self._format = None
#         self._hash = None
# 
#     ### SPECIAL METHODS ###
# 
#     #@profile
#     def __eq__(self, expr):
#         if isinstance(expr, type(self)):
#             if format(self) == format(expr):
#                 return True
#         return False
# 
#     #@profile
#     def __format__(self, format_specification=''):
#         if self._format is None:
#             agent = systemtools.StorageFormatAgent(self)
#             self._format = agent.get_storage_format()
#         return self._format
# 
#     #@profile
#     def __hash__(self):
#         if self._hash is None:
#             self._hash = hash((type(self), format(self)))
#         return self._hash


# Path: consort/tools/LeafExpression.py
import abjad
from abjad import attach
from abjad import inspect
from abjad import mutate
from abjad import select
from abjad.tools import durationtools
from abjad.tools import selectiontools
from consort.tools.HashCachingObject import HashCachingObject

        leaf=None,
        attachments=None,
        ):
        HashCachingObject.__init__(self)
        prototype = abjad.Leaf
        if leaf is not None:
            if isinstance(leaf, prototype):
                leaf = mutate(leaf).copy()
            elif issubclass(leaf, prototype):
                leaf = leaf()
            else:
                raise ValueError(leaf)
        self._leaf = leaf
        if attachments is not None:
            attachments = tuple(attachments)
        self._attachments = attachments

    ### SPECIAL METHODS ###

    def __call__(self, expr):
        if isinstance(expr, abjad.Leaf):
            expr = select(expr)
        assert isinstance(expr, selectiontools.Selection)
        for i, old_leaf in enumerate(expr):
            assert isinstance(old_leaf, abjad.Leaf)
            new_leaf = self._make_new_leaf(old_leaf)

            timespan = old_leaf._timespan
            start_offset = old_leaf._start_offset
            stop_offset = old_leaf._stop_offset

            mutate(old_leaf).replace(new_leaf)