def __format__(self, format_specification=''): r'''Formats stem tremolo. .. container:: example Sixteenth-note tremolo: >>> stem_tremolo = abjad.StemTremolo(16) >>> print(format(stem_tremolo)) :16 .. container:: example Thirty-second-note tremolo: >>> stem_tremolo = abjad.StemTremolo(32) >>> print(format(stem_tremolo)) :32 Returns string. ''' import abjad if format_specification in ('', 'lilypond'): return self._get_lilypond_format() elif format_specification == 'storage': return abjad.StorageFormatManager(self).get_storage_format() return str(self)
def __repr__(self): '''Gets interpreter representation of leaf. Returns string. ''' import abjad return abjad.StorageFormatManager(self).get_repr_format()
def __repr__(self): """ Gets interpreter representation of Abjad object. Returns string. """ import abjad return abjad.StorageFormatManager(self).get_repr_format()
def _get_format_specification(self): manager = abjad.StorageFormatManager(self) names = list(manager.signature_keyword_names) return abjad.FormatSpecification( self, storage_format_args_values=self.commands, storage_format_keyword_names=names, )
def __format__(self, format_specification=''): """ Formats time relation. Returns string. """ import abjad if format_specification in ('', 'storage'): return abjad.StorageFormatManager(self).get_storage_format() return str(self)
def __hash__(self) -> int: """ Delegates to format manager. """ hash_values = abjad.StorageFormatManager(self).get_hash_values() try: result = hash(hash_values) except TypeError: raise TypeError(f"unhashable type: {self}") return result
def _get_format_specification(self): import abjad agent = abjad.StorageFormatManager(self) names = list(agent.signature_keyword_names) if self.item_class is abjad.Markup: names.remove('item_class') return abjad.FormatSpecification( client=self, storage_format_kwargs_names=names, )
def __format__(self, format_specification=""): """ Formats q-event. Set `format_specification` to `''` or `'storage'`. Interprets `''` equal to `'storage'`. Returns string. """ return abjad.StorageFormatManager(self).get_storage_format()
def __repr__(self): """ Gets interpreter representation. .. container:: example >>> microtones.ETBundle() ETBundle(pitch="c'") """ return abjad.StorageFormatManager(self).get_repr_format()
def _get_format_specification(self): agent = abjad.StorageFormatManager(self) names = agent.signature_keyword_names for name in ("attachments", ): if not getattr(self, name, None) and name in names: names.remove(name) return abjad.FormatSpecification( client=self, repr_is_indented=False, storage_format_keyword_names=names, )
def __repr__(self): """ Gets interpreter representation. .. container:: example >>> microtones.JIVector() JIVector(diatonic_accidental='natural', syntonic_commas_down=0, syntonic_commas_up=0, septimal_commas_down=0, septimal_commas_up=0, undecimal_quarter_tones_down=0, undecimal_quarter_tones_up=0, tridecimal_third_tones_down=0, tridecimal_third_tones_up=0, seventeen_limit_schismas_down=0, seventeen_limit_schismas_up=0, nineteen_limit_schismas_down=0, nineteen_limit_schismas_up=0, twenty_three_limit_commas_down=0, twenty_three_limit_commas_up=0) """ return abjad.StorageFormatManager(self).get_repr_format()
def __format__(self, format_specification=''): r'''Formats LilyPond literal. Returns string. ''' import abjad if format_specification in ('', 'storage'): return abjad.StorageFormatManager(self).get_storage_format() elif format_specification == 'lilypond': return self.argument return str(self)
def _get_format_specification(self): import abjad agent = abjad.StorageFormatManager(self) names = list(agent.signature_keyword_names) for name in names[:]: if not getattr(self, name): names.remove(name) return abjad.FormatSpecification( client=self, storage_format_kwargs_names=names, )
def __format__(self, format_specification=""): """ Formats q schema item. Set `format_specification` to `''` or `'storage'`. Interprets `''` equal to `'storage'`. Returns string. """ if format_specification in ("", "storage"): return abjad.StorageFormatManager(self).get_storage_format() return str(self)
def compare_objects(object_one, object_two): r'''Compares `object_one` to `object_two`. Returns true or false. ''' import abjad agent_one = abjad.StorageFormatManager(object_one) if agent_one.format_specification.coerce_for_equality: try: object_two = type(object_one)(object_two) except ( TypeError, ValueError, ): return False elif not isinstance(object_two, type(object_one)): return False agent_two = abjad.StorageFormatManager(object_two) template_1 = agent_one.get_template_dict() template_2 = agent_two.get_template_dict() return template_1 == template_2
def _get_format_specification(self): import abjad agent = abjad.StorageFormatManager(self) names = list(agent.signature_keyword_names) if 'items' in names: names.remove('items') return abjad.FormatSpecification( self, repr_is_indented=False, storage_format_args_values=[self._collection], storage_format_kwargs_names=names, )
def _get_format_specification(self): agent = abjad.StorageFormatManager(self) names = agent.signature_names template_names = names[:] if "q_event_proxies" in names and not self.q_event_proxies: names.remove("q_event_proxies") return abjad.FormatSpecification( client=self, repr_is_indented=True, storage_format_keyword_names=names, template_names=template_names, )
def __format__(self, format_specification=''): r'''Formats duration. Set `format_specification` to `''` or `'storage'`. Interprets `''` equal to `'storage'`. Returns string. ''' import abjad if format_specification in ('', 'storage'): return abjad.StorageFormatManager(self).get_storage_format() return str(self)
def __format__(self, format_specification=''): """ Formats Abjad object. Set ``format_specification`` to ``''`` or ``'storage'``. Interprets ``''`` equal to ``'storage'``. Returns string. """ import abjad if format_specification in ('', 'storage'): return abjad.StorageFormatManager(self).get_storage_format() return str(self)
def __format__(self, format_specification=''): r'''Formats component. Set `format_specification` to `''`, `'lilypond'` or `'storage'`. Returns string. ''' import abjad if format_specification in ('', 'lilypond'): return self._get_lilypond_format() elif format_specification == 'storage': return abjad.StorageFormatManager(self).get_storage_format() raise ValueError(repr(format_specification))
def _get_format_specification(self): import abjad agent = abjad.StorageFormatManager(self) repr_text = '{}.{}'.format(type(self).__name__, self.name) storage_format_text = '{}.{}'.format( agent.get_tools_package_name(), repr_text, ) return abjad.FormatSpecification( client=self, repr_text=repr_text, storage_format_text=storage_format_text, )
def __format__(self, format_specification=''): r'''Formats LilyPond command. Set `format_specification` to `''`, `'lilypond`' or `'storage'`. Interprets `''` equal to `'storage'`. Returns string. ''' import abjad if format_specification in ('', 'storage'): return abjad.StorageFormatManager(self).get_storage_format() elif format_specification == 'lilypond': return self._get_lilypond_format() return str(self)
def __hash__(self): """ Hashes typed frozen set. Returns integer. """ import abjad hash_values = abjad.StorageFormatManager(self).get_hash_values() try: result = hash(hash_values) except TypeError: message = 'unhashable type: {}'.format(self) raise TypeError(message) return result
def f(argument, strict=None): r""" Formats ``argument`` and prints result. .. container:: example >>> staff = abjad.Staff("c'4 d' e' f'") >>> markup = abjad.Markup('Allegro', direction=abjad.Up) >>> markup = markup.with_color('blue') >>> abjad.attach(markup, staff[0]) >>> for leaf in staff: ... abjad.attach(abjad.Articulation('.'), leaf) ... >>> abjad.f(staff) \new Staff { c'4 - \staccato ^ \markup { \with-color #blue Allegro } d'4 - \staccato e'4 - \staccato f'4 - \staccato } >>> abjad.show(staff) # doctest: +SKIP """ import abjad if strict is not None: assert isinstance(strict, int), repr(strict) if hasattr(argument, '_publish_storage_format'): string = abjad.StorageFormatManager(argument).get_storage_format() else: string = format(argument, 'lilypond') realign = None if isinstance(strict, int): string = abjad.LilyPondFormatManager.align_tags(string, strict) realign = strict string = abjad.LilyPondFormatManager.left_shift_tags( string, realign=realign, ) print(string)
def _get_format_specification(self): import abjad manager = abjad.StorageFormatManager(self) names = list(manager.signature_keyword_names) if "items" in names: names.remove("items") values = [list(self._collection.items())] return abjad.FormatSpecification( self, repr_is_indented=False, storage_format_args_values=values, storage_format_kwargs_names=names, )
def __format__(self, format_specification=""): """ Formats duration. Set ``format_specification`` to ``''`` or ``'storage'``. Interprets ``''`` equal to ``'storage'``. Returns string. """ import abjad if format_specification in ("", "storage"): return abjad.StorageFormatManager(self).get_storage_format() return str(self)
def __format__(self, format_specification=""): r""" Formats q-event sequence. Set `format_specification` to `''` or `'storage'`. Interprets `''` equal to `'storage'`. >>> durations = (1000, -500, 1250, -500, 750) >>> sequence = \ ... abjadext.nauert.QEventSequence.from_millisecond_durations( ... durations) >>> print(format(sequence)) abjadext.nauert.QEventSequence( ( abjadext.nauert.PitchedQEvent( offset=abjad.Offset((0, 1)), pitches=( abjad.NamedPitch("c'"), ), ), abjadext.nauert.SilentQEvent( offset=abjad.Offset((1000, 1)), ), abjadext.nauert.PitchedQEvent( offset=abjad.Offset((1500, 1)), pitches=( abjad.NamedPitch("c'"), ), ), abjadext.nauert.SilentQEvent( offset=abjad.Offset((2750, 1)), ), abjadext.nauert.PitchedQEvent( offset=abjad.Offset((3250, 1)), pitches=( abjad.NamedPitch("c'"), ), ), abjadext.nauert.TerminalQEvent( offset=abjad.Offset((4000, 1)), ), ) ) Returns string. """ if format_specification in ("", "storage"): return abjad.StorageFormatManager(self).get_storage_format() return str(self)
def __format__(self, format_specification=''): r'''Formats time signature. .. container:: example >>> print(format(abjad.TimeSignature((3, 8)))) abjad.TimeSignature((3, 8)) Returns string. ''' import abjad if format_specification in ('', 'storage'): return abjad.StorageFormatManager(self).get_storage_format() elif format_specification == 'lilypond': return self._get_lilypond_format() return str(self)
def __format__(self, format_specification=''): """ Formats duration. .. container:: example >>> ratio = abjad.NonreducedRatio((2, 4, 2)) >>> print(format(ratio)) abjad.NonreducedRatio((2, 4, 2)) Returns string. """ import abjad if format_specification in ('', 'storage'): return abjad.StorageFormatManager(self).get_storage_format() return str(self)
def __format__(self, format_specification=''): r'''Formats LilyPond dimension. .. container:: example >>> dimension = abjad.LilyPondDimension(2, 'in') >>> print(format(dimension)) 2\in Returns string. ''' import abjad if format_specification in ('', 'lilypond'): return self._get_lilypond_format() elif format_specification == 'storage': return abjad.StorageFormatManager(self).get_storage_format() return str(self)