コード例 #1
0
    def make_lilypond_revert_string(
        grob_name,
        grob_attribute,
        context_name=None,
        ):
        '''Makes LilyPond revert string.

        Returns string.
        '''
        from abjad.tools import stringtools
        # parse input strings
        grob_name = stringtools.snake_case_to_upper_camel_case(grob_name)
        grob_attribute = LilyPondFormatManager.format_lilypond_attribute(
            grob_attribute)
        # change #'bound-details #'left #'text to #'bound-details
        grob_attribute = grob_attribute.split(' ')[0]
        context_prefix = ''
        if context_name is not None:
            context_prefix = \
                stringtools.snake_case_to_upper_camel_case(context_name)
            context_prefix += '.'
        # format revert string
        result = r'\revert {}{} {}'
        result = result.format(context_prefix, grob_name, grob_attribute)
        # return revert string
        return result
コード例 #2
0
 def __getattr__(self, name):
     from abjad import ly
     if name.startswith('_'):
         try:
             return vars(self)[name]
         except KeyError:
             message = '{!r} object has no attribute: {!r}.'
             message = message.format(self.__class__.__name__, name)
             raise AttributeError(message)
     else:
         camel_name = stringtools.snake_case_to_upper_camel_case(name)
         if camel_name in ly.contexts:
             try:
                 return vars(self)['_' + name]
             except KeyError:
                 context = LilyPondGrobProxyContextWrapper()
                 vars(self)['_' + name] = context
                 return context
         elif camel_name in ly.grob_interfaces:
             try:
                 return vars(self)[name]
             except KeyError:
                 vars(self)[name] = LilyPondGrobProxy()
                 return vars(self)[name]
         else:
             return vars(self)[name]
コード例 #3
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.snake_case_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)
コード例 #4
0
def make_lilypond_override_string(
    grob_name, 
    grob_attribute, 
    grob_value, 
    context_name=None, 
    is_once=False,
    ):
    '''Makes Lilypond override string.

    Does not include once indicator.

    Returns string.
    '''
    from format_lilypond_attribute import format_lilypond_attribute
    from format_lilypond_value import format_lilypond_value

    # parse input strings
    grob_name = stringtools.snake_case_to_upper_camel_case(grob_name)
    grob_attribute = format_lilypond_attribute(grob_attribute)
    grob_value = format_lilypond_value(grob_value)
    if context_name is not None:
        context_prefix = \
            stringtools.snake_case_to_upper_camel_case(context_name)
        context_prefix += '.'
    else:
        context_prefix = ''
    if is_once:
        once_prefix = r'\once '
    else:
        once_prefix = ''

    # return override string
    result = r'{}\override {}{} {} = {}'
    result = result.format(
        once_prefix, 
        context_prefix, 
        grob_name, 
        grob_attribute, 
        grob_value,
        )

    return result
コード例 #5
0
 def __getattr__(self, name):
     from abjad import ly
     try:
         return vars(self)[name]
     except KeyError:
         if stringtools.snake_case_to_upper_camel_case(name) in \
             ly.grob_interfaces:
             vars(self)[name] = LilyPondGrobProxy()
             return vars(self)[name]
         else:
             message = 'object can have only'
             message += ' LilyPond grob attributes: "%s".'
             message = message % self._class_name
             raise AttributeError(message)
コード例 #6
0
    def __getattr__(self, name):
        r"""Gets attribute `name` from LilyPond grob name manager.

        Returns string.
        """
        from abjad import ly
        from abjad.tools import lilypondnametools

        camel_name = stringtools.snake_case_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.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)