示例#1
0
 def interpret_input_blocks(self, input_blocks, console, verbose=True):
     code_blocks = tuple(input_blocks.values())
     if not code_blocks:
         return
     progress_indicator = systemtools.ProgressIndicator(
         message='    Interpreting code blocks',
         total=len(code_blocks),
         verbose=verbose,
     )
     with progress_indicator:
         for code_block in code_blocks:
             code_block.interpret(console)
             progress_indicator.advance()
示例#2
0
    def render_asset_output_proxies(
        self,
        input_blocks,
    ):
        asset_output_proxies = self.collect_asset_output_proxies(input_blocks)
        if not asset_output_proxies:
            return
        if not os.path.exists(self.assets_directory):
            os.makedirs(self.assets_directory)

        progress_indicator = systemtools.ProgressIndicator(
            message='    Writing assets',
            total=len(asset_output_proxies),
        )
        with progress_indicator:
            for asset_output_proxy in asset_output_proxies:
                asset_output_proxy.render_for_latex(self.assets_directory, )
                progress_indicator.advance()
 def validate_score(score, verbose=True):
     consort.SegmentMaker.validate_score(score, verbose=verbose)
     component = score['Piano Staff']
     progress_indicator = systemtools.ProgressIndicator(
         is_warning=True,
         message='    coloring piano conflicts',
         verbose=verbose,
     )
     with progress_indicator:
         for vertical_moment in iterate(component).by_vertical_moment():
             pitch_numbers = collections.Counter()
             notes_and_chords = vertical_moment.notes_and_chords
             for note_or_chord in notes_and_chords:
                 if isinstance(note_or_chord, scoretools.Note):
                     pitch_number = note_or_chord.written_pitch.pitch_number
                     pitch_number = float(pitch_number)
                     pitch_numbers[pitch_number] += 1
                 else:
                     for pitch in note_or_chord.written_pitches:
                         pitch_number = pitch.pitch_number
                         pitch_number = float(pitch_number)
                         pitch_numbers[pitch_number] += 1
             conflict_pitch_numbers = set()
             for pitch_number, count in pitch_numbers.items():
                 if 1 < count:
                     conflict_pitch_numbers.add(pitch_number)
             if not conflict_pitch_numbers:
                 continue
             for note_or_chord in notes_and_chords:
                 if isinstance(note_or_chord, scoretools.Note):
                     pitch_number = note_or_chord.written_pitch.pitch_number
                     pitch_number = float(pitch_number)
                     if pitch_number in conflict_pitch_numbers:
                         #note_or_chord.note_head.tweak.color = 'red'
                         progress_indicator.advance()
                 else:
                     for note_head in note_or_chord.note_heads:
                         pitch_number = note_head.written_pitch.pitch_number
                         pitch_number = float(pitch_number)
                         if pitch_number in conflict_pitch_numbers:
                             #note_head.tweak.color = 'red'
                             progress_indicator.advance()