예제 #1
0
 def __init__(
     self,
     payload,
     image_layout_specifier=None,
     image_render_specifier=None,
 ):
     from abjad.tools import abjadbooktools
     from abjad.tools import lilypondfiletools
     from abjad.tools import markuptools
     ImageOutputProxy.__init__(
         self,
         image_layout_specifier=image_layout_specifier,
         image_render_specifier=image_render_specifier,
     )
     payload = copy.deepcopy(payload)
     if image_render_specifier is None:
         image_render_specifier = abjadbooktools.ImageRenderSpecifier()
     if (not image_render_specifier.stylesheet
             and not image_render_specifier.no_stylesheet):
         payload = documentationtools.make_reference_manual_lilypond_file(
             payload)
     lilypond_file = payload
     assert isinstance(lilypond_file, lilypondfiletools.LilyPondFile)
     lilypond_file.header_block.tagline = markuptools.Markup('""')
     lilypond_file._date_time_token = None
     token = lilypondfiletools.LilyPondVersionToken("2.19.0", )
     lilypond_file._lilypond_version_token = token
     if (image_render_specifier.stylesheet
             and not image_render_specifier.no_stylesheet):
         if not lilypond_file.includes:
             lilypond_file._use_relative_includes = True
             includes = [image_render_specifier.stylesheet]
             lilypond_file._includes = tuple(includes)
     self._payload = lilypond_file
예제 #2
0
 def __init__(
     self,
     payload,
     image_layout_specifier=None,
     image_render_specifier=None,
 ):
     from abjad.tools import abjadbooktools
     ImageOutputProxy.__init__(
         self,
         image_layout_specifier=image_layout_specifier,
         image_render_specifier=image_render_specifier,
     )
     payload = copy.deepcopy(payload)
     if image_render_specifier is None:
         image_render_specifier = abjadbooktools.ImageRenderSpecifier()
     if (not image_render_specifier.stylesheet
             and not image_render_specifier.no_stylesheet):
         payload = documentationtools.make_reference_manual_lilypond_file(
             payload)
     manager = systemtools.IOManager
     lilypond_file = manager._insert_expr_into_lilypond_file(payload)
     lilypond_file.file_initial_system_comments[:] = []
     token = lilypondfiletools.LilyPondVersionToken("2.19.0", )
     lilypond_file.file_initial_system_includes[0] = token
     if (image_render_specifier.stylesheet
             and not image_render_specifier.no_stylesheet):
         lilypond_file.use_relative_includes = True
         lilypond_file.file_initial_user_includes[:] = [
             image_render_specifier.stylesheet
         ]
     self._payload = lilypond_file
예제 #3
0
 def __init__(
     self,
     comments=None,
     date_time_token=None,
     default_paper_size=None,
     global_staff_size=None,
     includes=None,
     items=None,
     lilypond_language_token=None,
     lilypond_version_token=None,
     use_relative_includes=None,
     ):
     from abjad.tools import lilypondfiletools
     comments = comments or ()
     comments = tuple(comments)
     self._comments = comments
     self._date_time_token = None
     if date_time_token is not False:
         self._date_time_token = lilypondfiletools.DateTimeToken()
     self._default_paper_size = default_paper_size
     self._global_staff_size = global_staff_size
     includes = includes or ()
     includes = tuple(includes)
     self._includes = includes
     self._items = items or []
     self._lilypond_language_token = None
     if not lilypond_language_token == False:
         token = lilypondfiletools.LilyPondLanguageToken()
         self._lilypond_language_token = token
     self._lilypond_version_token = None
     if not lilypond_version_token == False:
         token = lilypondfiletools.LilyPondVersionToken()
         self._lilypond_version_token = token
     self._use_relative_includes = use_relative_includes
예제 #4
0
 def __init__(self, payload):
     from abjad import abjad_configuration
     if isinstance(payload, str):
         self._payload = payload
     else:
         payload = copy.deepcopy(payload)
         manager = systemtools.IOManager
         lilypond_file = manager._insert_expr_into_lilypond_file(payload)
         lilypond_file.file_initial_system_comments[:] = []
         token = lilypondfiletools.LilyPondVersionToken(
             abjad_configuration.get_lilypond_minimum_version_string(), )
         lilypond_file.file_initial_system_includes[0] = token
         lilypond_format = format(lilypond_file)
         self._payload = lilypond_format
예제 #5
0
 def __init__(self):
     from abjad.tools import lilypondfiletools
     self._items = []
     self._file_initial_system_comments = []
     token = lilypondfiletools.DateTimeToken()
     self._file_initial_system_comments.append(token)
     self._file_initial_user_comments = []
     self._file_initial_system_includes = []
     token = lilypondfiletools.LilyPondVersionToken()
     self._file_initial_system_includes.append(token)
     token = lilypondfiletools.LilyPondLanguageToken()
     self._file_initial_system_includes.append(token)
     self._file_initial_user_includes = []
     self.default_paper_size = None
     self.global_staff_size = None
     self.use_relative_includes = False
예제 #6
0
 def __init__(
     self,
     payload,
     image_layout_specifier=None,
     image_render_specifier=None,
     strict=None,
     ):
     ImageOutputProxy.__init__(
         self,
         image_layout_specifier=image_layout_specifier,
         image_render_specifier=image_render_specifier,
         )
     payload = copy.deepcopy(payload)
     if image_render_specifier is None:
         image_render_specifier = ImageRenderSpecifier()
     if (not image_render_specifier.stylesheet and
         not image_render_specifier.no_stylesheet):
         payload = lilypondfiletools.LilyPondFile.new(payload)
     lilypond_file = payload
     assert isinstance(lilypond_file, lilypondfiletools.LilyPondFile)
     if lilypond_file.header_block:
         if getattr(lilypond_file.header_block, 'tagline') is False:
             # default.ily stylesheet already sets tagline = ##f
             delattr(lilypond_file.header_block, 'tagline')
         if lilypond_file.header_block.empty():
             lilypond_file.items.remove(lilypond_file.header_block)
     if lilypond_file.layout_block and lilypond_file.layout_block.empty():
         lilypond_file.items.remove(lilypond_file.layout_block)
     if lilypond_file.paper_block and lilypond_file.paper_block.empty():
         lilypond_file.items.remove(lilypond_file.paper_block)
     lilypond_file._date_time_token = None
     token = lilypondfiletools.LilyPondVersionToken("2.19.0")
     lilypond_file._lilypond_version_token = token
     if (image_render_specifier.stylesheet and
         not image_render_specifier.no_stylesheet):
         if not lilypond_file.includes:
             lilypond_file._use_relative_includes = True
             includes = [image_render_specifier.stylesheet]
             lilypond_file._includes = tuple(includes)
     self._payload = lilypond_file
     self._strict = strict
예제 #7
0
    def generate_music_source(self):
        r'''Generates ``music.ly``.

        Returns none.
        '''
        result = self._confirm_segment_names()
        if self._session.is_backtracking or not isinstance(result, list):
            return
        segment_names = result
        lilypond_names = [_.replace('_', '-') for _ in segment_names]
        source_path = os.path.join(
            self._configuration.score_manager_directory,
            'boilerplate',
            'music.ly',
            )
        manager = self._session.current_score_package_manager
        destination_path = os.path.join(
            manager._path,
            'build',
            'music.ly',
            )
        candidate_path = os.path.join(
            manager._path,
            'build',
            'music.candidate.ly',
            )
        with systemtools.FilesystemState(remove=[candidate_path]):
            shutil.copyfile(source_path, candidate_path)
            width, height, unit = manager._parse_paper_dimensions()
            old = '{PAPER_SIZE}'
            new = '{{{}{}, {}{}}}'
            new = new.format(width, unit, height, unit)
            self._replace_in_file(candidate_path, old, new)
            lines = []
            for lilypond_name in lilypond_names:
                file_name = lilypond_name + '.ly'
                line = r'   \include "{}"'
                line = line.format(file_name)
                lines.append(line)
            if lines:
                new = '\n'.join(lines)
                old = '%%% SEGMENTS %%%'
                self._replace_in_file(candidate_path, old, new)
            else:
                line_to_remove = '%%% SEGMENTS %%%\n'
                self._remove_file_line(candidate_path, line_to_remove)
            stylesheet_path = self._session.current_stylesheet_path
            if stylesheet_path:
                old = '% STYLESHEET_INCLUDE_STATEMENT'
                new = r'\include "../stylesheets/stylesheet.ily"'
                self._replace_in_file(candidate_path, old, new)
            language_token = lilypondfiletools.LilyPondLanguageToken()
            lilypond_language_directive = format(language_token)
            old = '% LILYPOND_LANGUAGE_DIRECTIVE'
            new = lilypond_language_directive
            self._replace_in_file(candidate_path, old, new)
            version_token = lilypondfiletools.LilyPondVersionToken()
            lilypond_version_directive = format(version_token)
            old = '% LILYPOND_VERSION_DIRECTIVE'
            new = lilypond_version_directive
            self._replace_in_file(candidate_path, old, new)
            score_title = manager._get_title()
            if score_title:
                old = 'SCORE_NAME'
                new = score_title
                self._replace_in_file(candidate_path, old, new)
            annotated_title = manager._get_title(year=True)
            if annotated_title:
                old = 'SCORE_TITLE'
                new = annotated_title
                self._replace_in_file(candidate_path, old, new)
            forces_tagline = manager._get_metadatum('forces_tagline')
            if forces_tagline:
                old = 'FORCES_TAGLINE'
                new = forces_tagline
                self._replace_in_file(candidate_path, old, new)
            self._handle_candidate(candidate_path, destination_path)