Example #1
0
    def __getattr__(self, name):
        r'''Gets setting `name` from LilyPond setting name manager.

        Returns string.
        '''
        from abjad import ly
        from abjad.tools import lilypondnametools
        camel_name = stringtools.to_upper_camel_case(name)
        if name.startswith('_'):
            try:
                return vars(self)[name]
            except KeyError:
                message = '{!r} object has no attribute: {!r}.'
                message = message.format(type(self).__name__, name)
                raise AttributeError(message)
        elif camel_name in ly.contexts:
            try:
                return vars(self)['_' + name]
            except KeyError:
                context = lilypondnametools.LilyPondNameManager()
                vars(self)['_' + name] = context
                return context
        else:
            try:
                return vars(self)[name]
            except KeyError:
                message = '{!r} object has no attribute: {!r}.'
                message = message.format(type(self).__name__, name)
                raise AttributeError(message)
Example #2
0
    def __getattr__(self, name):
        r'''Gets arbitrary object keyed to `name`.

        ..  container:: example

            >>> staff = abjad.Staff("c'4 d' e' f'")
            >>> abjad.setting(staff).instrument_name = abjad.Markup('Vn. I')
            >>> abjad.show(staff) # doctest: +SKIP

            ..  docs::

                >>> abjad.f(staff)
                \new Staff
                \with
                {
                    instrumentName = \markup { "Vn. I" }
                }
                {
                    c'4
                    d'4
                    e'4
                    f'4
                }

        ..  container:: example

            Returns arbitrary object keyed to `name`:

            >>> abjad.setting(staff).instrument_name
            Markup(contents=['Vn. I'])

        '''
        from abjad import ly
        from abjad.tools import lilypondnametools
        camel_name = datastructuretools.String(name).to_upper_camel_case()
        if name.startswith('_'):
            try:
                return vars(self)[name]
            except KeyError:
                message = '{!r} object has no attribute: {!r}.'
                message = message.format(type(self).__name__, name)
                raise AttributeError(message)
        elif camel_name in ly.contexts:
            try:
                return vars(self)['_' + name]
            except KeyError:
                context = lilypondnametools.LilyPondNameManager()
                vars(self)['_' + name] = context
                return context
        else:
            try:
                return vars(self)[name]
            except KeyError:
                message = '{!r} object has no attribute: {!r}.'
                message = message.format(type(self).__name__, name)
                raise AttributeError(message)
Example #3
0
    def tweak(self):
        r'''LilyPond tweak reservoir of note-head.

        ::

            >>> note_head = scoretools.NoteHead("cs''")
            >>> note_head.tweak
            LilyPondNameManager()

        Returns LilyPond tweak reservoir.
        '''
        from abjad.tools import lilypondnametools
        if self._tweak is None:
            self._tweak = lilypondnametools.LilyPondNameManager()
        return self._tweak
    def __getattr__(self, name):
        r'''Gets LilyPond name manager keyed to `name`.

        ..  container:: example

            >>> staff = abjad.Staff("c'4 d' e' f'")
            >>> abjad.override(staff).note_head.color = 'red'
            >>> abjad.show(staff) # doctest: +SKIP

            ..  docs::

                >>> abjad.f(staff)
                \new Staff
                \with
                {
                    \override NoteHead.color = #red
                }
                {
                    c'4
                    d'4
                    e'4
                    f'4
                }

        ..  container:: example

            Returns LilyPond name manager:

            >>> abjad.override(staff).note_head
            LilyPondNameManager(('color', 'red'))

        '''
        import abjad
        from abjad import ly
        from abjad.tools import lilypondnametools
        camel_name = abjad.String(name).to_upper_camel_case()
        if name.startswith('_'):
            try:
                return vars(self)[name]
            except KeyError:
                message = '{!r} object has no attribute: {!r}.'
                message = message.format(type(self).__name__, name)
                raise AttributeError(message)
        elif camel_name in ly.contexts:
            try:
                return vars(self)['_' + name]
            except KeyError:
                context = lilypondnametools.LilyPondGrobNameManager()
                vars(self)['_' + name] = context
                return context
        elif camel_name in ly.grob_interfaces:
            try:
                return vars(self)[name]
            except KeyError:
                vars(self)[name] = lilypondnametools.LilyPondNameManager()
                return vars(self)[name]
        else:
            try:
                return vars(self)[name]
            except KeyError:
                message = '{!r} object has no attribute: {!r}.'
                message = message.format(type(self).__name__, name)
                raise AttributeError(message)