def accepted_by(self): r'''Gets contexts accepting LilyPond context. :: >>> for accepting_context in context.accepted_by: ... accepting_context ... LilyPondContext(name='Score') ''' from abjad.ly import contexts accepting_contexts = set() for context_name, context_info in contexts.items(): if self.name in context_info['accepts']: accepting_context = LilyPondContext(context_name) accepting_contexts.add(accepting_context) return tuple(sorted(accepting_contexts, key=lambda x: x.name))
def accepted_by(self): r'''Gets contexts accepting LilyPond context. :: >>> for accepting_context in context.accepted_by: ... accepting_context ... LilyPondContext(name='Score') :: >>> for lilypond_context in lilypondnametools.LilyPondContext.list_all_contexts(): ... print('{}:'.format(lilypond_context.name)) ... accepted_by = lilypond_context.accepted_by ... if accepted_by: ... accepted_by = ',\n '.join(_.name for _ in accepted_by) ... print(' {}'.format(accepted_by)) ... ChoirStaff: ChoirStaff, Score, StaffGroup ChordNames: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup CueVoice: DrumStaff, GregorianTranscriptionStaff, KievanStaff, MensuralStaff, PetrucciStaff, RhythmicStaff, Staff, TabStaff, VaticanaStaff Devnull: Score DrumStaff: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup DrumVoice: DrumStaff Dynamics: GrandStaff, PianoStaff FiguredBass: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup FretBoards: Score, StaffGroup Global: GrandStaff: ChoirStaff, Score, StaffGroup GregorianTranscriptionStaff: Score GregorianTranscriptionVoice: GregorianTranscriptionStaff KievanStaff: Score KievanVoice: KievanStaff Lyrics: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup MensuralStaff: Score MensuralVoice: MensuralStaff NoteNames: Score NullVoice: DrumStaff, GregorianTranscriptionStaff, KievanStaff, MensuralStaff, PetrucciStaff, RhythmicStaff, Staff, TabStaff, VaticanaStaff PetrucciStaff: Score PetrucciVoice: PetrucciStaff PianoStaff: ChoirStaff, Score, StaffGroup RhythmicStaff: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup Score: Global Staff: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup StaffGroup: ChoirStaff, Score, StaffGroup TabStaff: GrandStaff, PianoStaff, Score, StaffGroup TabVoice: TabStaff VaticanaStaff: Score VaticanaVoice: VaticanaStaff Voice: RhythmicStaff, Staff ''' from abjad.ly import contexts accepting_contexts = set() for context_name, context_info in contexts.items(): if self.name in context_info['accepts']: accepting_context = LilyPondContext(context_name) accepting_contexts.add(accepting_context) return tuple(sorted(accepting_contexts, key=lambda x: x.name))
def unregister( self, context=None, ): r'''Unregisters custom context. :: >>> custom_context = lilypondnametools.LilyPondContext.register( ... accepted_by=['Score', 'StaffGroup'], ... alias='Staff', ... name='FingeringStaff', ... ) :: >>> score_context = lilypondnametools.LilyPondContext('Score') >>> for accepted_context in score_context.accepts: ... accepted_context ... LilyPondContext(name='ChoirStaff') LilyPondContext(name='ChordNames') LilyPondContext(name='Devnull') LilyPondContext(name='DrumStaff') LilyPondContext(name='FiguredBass') LilyPondContext(name='FingeringStaff') LilyPondContext(name='FretBoards') LilyPondContext(name='GrandStaff') LilyPondContext(name='GregorianTranscriptionStaff') LilyPondContext(name='KievanStaff') LilyPondContext(name='Lyrics') LilyPondContext(name='MensuralStaff') LilyPondContext(name='NoteNames') LilyPondContext(name='PetrucciStaff') LilyPondContext(name='PianoStaff') LilyPondContext(name='RhythmicStaff') LilyPondContext(name='Staff') LilyPondContext(name='StaffGroup') LilyPondContext(name='TabStaff') LilyPondContext(name='VaticanaStaff') :: >>> custom_context.unregister() :: >>> score_context = lilypondnametools.LilyPondContext('Score') >>> for accepted_context in score_context.accepts: ... accepted_context ... LilyPondContext(name='ChoirStaff') LilyPondContext(name='ChordNames') LilyPondContext(name='Devnull') LilyPondContext(name='DrumStaff') LilyPondContext(name='FiguredBass') LilyPondContext(name='FretBoards') LilyPondContext(name='GrandStaff') LilyPondContext(name='GregorianTranscriptionStaff') LilyPondContext(name='KievanStaff') LilyPondContext(name='Lyrics') LilyPondContext(name='MensuralStaff') LilyPondContext(name='NoteNames') LilyPondContext(name='PetrucciStaff') LilyPondContext(name='PianoStaff') LilyPondContext(name='RhythmicStaff') LilyPondContext(name='Staff') LilyPondContext(name='StaffGroup') LilyPondContext(name='TabStaff') LilyPondContext(name='VaticanaStaff') ''' from abjad.ly import contexts assert self.is_custom del (contexts[self.name]) del (self._identity_map[self.name]) for context_name, context_info in contexts.items(): if self.name in context_info['accepts']: context_info['accepts'].remove(self.name)
def accepted_by(self) -> typing.Tuple["LilyPondContext", ...]: r""" Gets contexts accepting LilyPond context. .. container:: example >>> context = abjad.LilyPondContext('MensuralStaff') >>> for accepting_context in context.accepted_by: ... accepting_context ... LilyPondContext(name='Score') >>> for lilypond_context in abjad.LilyPondContext.list_all_contexts(): ... print(f'{lilypond_context.name}:') ... accepted_by = lilypond_context.accepted_by ... if accepted_by: ... accepted_by = ',\n '.join(_.name for _ in accepted_by) ... print(f' {accepted_by}') ... ChoirStaff: ChoirStaff, Score, StaffGroup ChordNames: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup CueVoice: DrumStaff, GregorianTranscriptionStaff, KievanStaff, MensuralStaff, PetrucciStaff, RhythmicStaff, Staff, TabStaff, VaticanaStaff Devnull: Score DrumStaff: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup DrumVoice: DrumStaff Dynamics: GrandStaff, PianoStaff FiguredBass: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup FretBoards: Score, StaffGroup Global: GrandStaff: ChoirStaff, Score, StaffGroup GregorianTranscriptionStaff: Score GregorianTranscriptionVoice: GregorianTranscriptionStaff KievanStaff: Score KievanVoice: KievanStaff Lyrics: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup MensuralStaff: Score MensuralVoice: MensuralStaff NoteNames: Score NullVoice: DrumStaff, GregorianTranscriptionStaff, KievanStaff, MensuralStaff, PetrucciStaff, RhythmicStaff, Staff, TabStaff, VaticanaStaff PetrucciStaff: Score PetrucciVoice: PetrucciStaff PianoStaff: ChoirStaff, Score, StaffGroup RhythmicStaff: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup Score: Global Staff: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup StaffGroup: ChoirStaff, Score, StaffGroup TabStaff: GrandStaff, PianoStaff, Score, StaffGroup TabVoice: TabStaff VaticanaStaff: Score VaticanaVoice: VaticanaStaff Voice: RhythmicStaff, Staff """ from abjad.ly import contexts accepting_contexts = set() for lilypond_type, context_info in contexts.items(): assert isinstance(context_info, dict), repr(context_info) if self.name in context_info["accepts"]: accepting_context = LilyPondContext(lilypond_type) accepting_contexts.add(accepting_context) return tuple(sorted(accepting_contexts, key=lambda x: x.name))
def unregister(self, context=None) -> None: r""" Unregisters custom context. .. container:: example >>> custom_context = abjad.LilyPondContext.register( ... accepted_by=['Score', 'StaffGroup'], ... alias='Staff', ... name='FingeringStaff', ... ) >>> score_context = abjad.LilyPondContext('Score') >>> for accepted_context in score_context.accepts: ... accepted_context ... LilyPondContext(name='ChoirStaff') LilyPondContext(name='ChordNames') LilyPondContext(name='Devnull') LilyPondContext(name='DrumStaff') LilyPondContext(name='FiguredBass') LilyPondContext(name='FingeringStaff') LilyPondContext(name='FretBoards') LilyPondContext(name='GrandStaff') LilyPondContext(name='GregorianTranscriptionStaff') LilyPondContext(name='KievanStaff') LilyPondContext(name='Lyrics') LilyPondContext(name='MensuralStaff') LilyPondContext(name='NoteNames') LilyPondContext(name='PetrucciStaff') LilyPondContext(name='PianoStaff') LilyPondContext(name='RhythmicStaff') LilyPondContext(name='Staff') LilyPondContext(name='StaffGroup') LilyPondContext(name='TabStaff') LilyPondContext(name='VaticanaStaff') >>> custom_context.unregister() >>> score_context = abjad.LilyPondContext('Score') >>> for accepted_context in score_context.accepts: ... accepted_context ... LilyPondContext(name='ChoirStaff') LilyPondContext(name='ChordNames') LilyPondContext(name='Devnull') LilyPondContext(name='DrumStaff') LilyPondContext(name='FiguredBass') LilyPondContext(name='FretBoards') LilyPondContext(name='GrandStaff') LilyPondContext(name='GregorianTranscriptionStaff') LilyPondContext(name='KievanStaff') LilyPondContext(name='Lyrics') LilyPondContext(name='MensuralStaff') LilyPondContext(name='NoteNames') LilyPondContext(name='PetrucciStaff') LilyPondContext(name='PianoStaff') LilyPondContext(name='RhythmicStaff') LilyPondContext(name='Staff') LilyPondContext(name='StaffGroup') LilyPondContext(name='TabStaff') LilyPondContext(name='VaticanaStaff') """ from abjad.ly import contexts assert self.is_custom del contexts[self.name] del self._identity_map[self.name] for lilypond_type, context_info in contexts.items(): assert isinstance(context_info, dict), repr(context_info) set_ = context_info["accepts"] assert isinstance(set_, set), repr(set_) if self.name in set_: set_.remove(self.name)
def unregister( self, context=None, ): r'''Unregisters custom context. :: >>> custom_context = lilypondnametools.LilyPondContext.register( ... accepted_by=['Score', 'StaffGroup'], ... alias='Staff', ... name='FingeringStaff', ... ) :: >>> score_context = lilypondnametools.LilyPondContext('Score') >>> for accepted_context in score_context.accepts: ... accepted_context ... LilyPondContext(name='ChoirStaff') LilyPondContext(name='ChordNames') LilyPondContext(name='Devnull') LilyPondContext(name='DrumStaff') LilyPondContext(name='FiguredBass') LilyPondContext(name='FingeringStaff') LilyPondContext(name='FretBoards') LilyPondContext(name='GrandStaff') LilyPondContext(name='GregorianTranscriptionStaff') LilyPondContext(name='KievanStaff') LilyPondContext(name='Lyrics') LilyPondContext(name='MensuralStaff') LilyPondContext(name='NoteNames') LilyPondContext(name='PetrucciStaff') LilyPondContext(name='PianoStaff') LilyPondContext(name='RhythmicStaff') LilyPondContext(name='Staff') LilyPondContext(name='StaffGroup') LilyPondContext(name='TabStaff') LilyPondContext(name='VaticanaStaff') :: >>> custom_context.unregister() :: >>> score_context = lilypondnametools.LilyPondContext('Score') >>> for accepted_context in score_context.accepts: ... accepted_context ... LilyPondContext(name='ChoirStaff') LilyPondContext(name='ChordNames') LilyPondContext(name='Devnull') LilyPondContext(name='DrumStaff') LilyPondContext(name='FiguredBass') LilyPondContext(name='FretBoards') LilyPondContext(name='GrandStaff') LilyPondContext(name='GregorianTranscriptionStaff') LilyPondContext(name='KievanStaff') LilyPondContext(name='Lyrics') LilyPondContext(name='MensuralStaff') LilyPondContext(name='NoteNames') LilyPondContext(name='PetrucciStaff') LilyPondContext(name='PianoStaff') LilyPondContext(name='RhythmicStaff') LilyPondContext(name='Staff') LilyPondContext(name='StaffGroup') LilyPondContext(name='TabStaff') LilyPondContext(name='VaticanaStaff') ''' from abjad.ly import contexts assert self.is_custom del(contexts[self.name]) del(self._identity_map[self.name]) for context_name, context_info in contexts.items(): if self.name in context_info['accepts']: context_info['accepts'].remove(self.name)
def unregister( self, context=None, ) -> None: r""" Unregisters custom context. .. container:: example >>> custom_context = abjad.LilyPondContext.register( ... accepted_by=['Score', 'StaffGroup'], ... alias='Staff', ... name='FingeringStaff', ... ) >>> score_context = abjad.LilyPondContext('Score') >>> for accepted_context in score_context.accepts: ... accepted_context ... LilyPondContext(name='ChoirStaff') LilyPondContext(name='ChordNames') LilyPondContext(name='Devnull') LilyPondContext(name='DrumStaff') LilyPondContext(name='FiguredBass') LilyPondContext(name='FingeringStaff') LilyPondContext(name='FretBoards') LilyPondContext(name='GrandStaff') LilyPondContext(name='GregorianTranscriptionStaff') LilyPondContext(name='KievanStaff') LilyPondContext(name='Lyrics') LilyPondContext(name='MensuralStaff') LilyPondContext(name='NoteNames') LilyPondContext(name='PetrucciStaff') LilyPondContext(name='PianoStaff') LilyPondContext(name='RhythmicStaff') LilyPondContext(name='Staff') LilyPondContext(name='StaffGroup') LilyPondContext(name='TabStaff') LilyPondContext(name='VaticanaStaff') >>> custom_context.unregister() >>> score_context = abjad.LilyPondContext('Score') >>> for accepted_context in score_context.accepts: ... accepted_context ... LilyPondContext(name='ChoirStaff') LilyPondContext(name='ChordNames') LilyPondContext(name='Devnull') LilyPondContext(name='DrumStaff') LilyPondContext(name='FiguredBass') LilyPondContext(name='FretBoards') LilyPondContext(name='GrandStaff') LilyPondContext(name='GregorianTranscriptionStaff') LilyPondContext(name='KievanStaff') LilyPondContext(name='Lyrics') LilyPondContext(name='MensuralStaff') LilyPondContext(name='NoteNames') LilyPondContext(name='PetrucciStaff') LilyPondContext(name='PianoStaff') LilyPondContext(name='RhythmicStaff') LilyPondContext(name='Staff') LilyPondContext(name='StaffGroup') LilyPondContext(name='TabStaff') LilyPondContext(name='VaticanaStaff') """ from abjad.ly import contexts assert self.is_custom del(contexts[self.name]) del(self._identity_map[self.name]) for lilypond_type, context_info in contexts.items(): assert isinstance(context_info, dict), repr(context_info) set_ = context_info['accepts'] assert isinstance(set_, set), repr(set_) if self.name in set_: set_.remove(self.name)
def accepted_by(self) -> typing.Tuple['LilyPondContext', ...]: r""" Gets contexts accepting LilyPond context. .. container:: example >>> context = abjad.LilyPondContext('MensuralStaff') >>> for accepting_context in context.accepted_by: ... accepting_context ... LilyPondContext(name='Score') >>> for lilypond_context in abjad.LilyPondContext.list_all_contexts(): ... print(f'{lilypond_context.name}:') ... accepted_by = lilypond_context.accepted_by ... if accepted_by: ... accepted_by = ',\n '.join(_.name for _ in accepted_by) ... print(f' {accepted_by}') ... ChoirStaff: ChoirStaff, Score, StaffGroup ChordNames: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup CueVoice: DrumStaff, GregorianTranscriptionStaff, KievanStaff, MensuralStaff, PetrucciStaff, RhythmicStaff, Staff, TabStaff, VaticanaStaff Devnull: Score DrumStaff: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup DrumVoice: DrumStaff Dynamics: GrandStaff, PianoStaff FiguredBass: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup FretBoards: Score, StaffGroup Global: GrandStaff: ChoirStaff, Score, StaffGroup GregorianTranscriptionStaff: Score GregorianTranscriptionVoice: GregorianTranscriptionStaff KievanStaff: Score KievanVoice: KievanStaff Lyrics: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup MensuralStaff: Score MensuralVoice: MensuralStaff NoteNames: Score NullVoice: DrumStaff, GregorianTranscriptionStaff, KievanStaff, MensuralStaff, PetrucciStaff, RhythmicStaff, Staff, TabStaff, VaticanaStaff PetrucciStaff: Score PetrucciVoice: PetrucciStaff PianoStaff: ChoirStaff, Score, StaffGroup RhythmicStaff: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup Score: Global Staff: ChoirStaff, GrandStaff, PianoStaff, Score, StaffGroup StaffGroup: ChoirStaff, Score, StaffGroup TabStaff: GrandStaff, PianoStaff, Score, StaffGroup TabVoice: TabStaff VaticanaStaff: Score VaticanaVoice: VaticanaStaff Voice: RhythmicStaff, Staff """ from abjad.ly import contexts accepting_contexts = set() for lilypond_type, context_info in contexts.items(): assert isinstance(context_info, dict), repr(context_info) if self.name in context_info['accepts']: accepting_context = LilyPondContext(lilypond_type) accepting_contexts.add(accepting_context) return tuple(sorted(accepting_contexts, key=lambda x: x.name))