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.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.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
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)
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.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)
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'. Returns string. ''' from abjad.tools import stringtools # parse input strings grob_name = stringtools.to_upper_camel_case(grob_name) grob_attribute = LilyPondFormatManager.format_lilypond_attribute( grob_attribute) grob_value = LilyPondFormatManager.format_lilypond_value(grob_value) if context_name is not None: context_prefix = \ stringtools.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
def to_lower_camel_case(string): r'''Changes `string` to lower camel case. .. container:: example Changes words to lower camel case: :: >>> stringtools.to_lower_camel_case('scale degrees 4 and 5') 'scaleDegrees4And5' .. container:: example Changes snake case to lower camel case: :: >>> stringtools.to_lower_camel_case('scale_degrees_4_and_5') 'scaleDegrees4And5' .. container:: example Changes dash case to lower camel case: :: >>> stringtools.to_lower_camel_case('scale-degrees-4-and-5') 'scaleDegrees4And5' .. container:: example Changes upper camel case to lower camel case: :: >>> stringtools.to_lower_camel_case('ScaleDegrees4And5') 'scaleDegrees4And5' Returns string. ''' from abjad.tools import stringtools result = stringtools.to_upper_camel_case(string) if result == '': return result result = result[0].lower() + result[1:] return result
def _title_case_name(self): return '{}{}In{}'.format( stringtools.to_upper_camel_case(self.quality_string), stringtools.to_upper_camel_case(self.extent_name), stringtools.to_upper_camel_case(self.position), )
def _file_name_callback(file_name): base_name, extension = os.path.splitext(file_name) base_name = stringtools.to_upper_camel_case(base_name) file_name = base_name + extension return file_name