Esempio n. 1
0
    def __init__(self, version_string=None):
        from abjad import abjad_configuration

        assert isinstance(version_string, (str, type(None)))
        if version_string is None:
            version_string = abjad_configuration.get_lilypond_version_string()
        self._version_string = version_string
Esempio n. 2
0
 def _handle_create(
     self,
     target_name,
     force,
     paper_size=None,
     orientation=None,
 ):
     from abjad import abjad_configuration
     if target_name is True:
         name = paper_size.lower().replace(' ', '-')
         name = '{}-{}'.format(name, orientation)
     else:
         name = datastructuretools.String(target_name).to_dash_case()
     dimensions = self.paper_sizes[paper_size]
     message = 'Creating build target {!r} ({}{} x {}{})'.format(
         name,
         dimensions[0][0],
         dimensions[0][1],
         dimensions[1][0],
         dimensions[1][1],
     )
     print(message)
     target_path = self._name_to_score_subdirectory(
         name, 'builds', self._score_package_path)
     if target_path.exists() and not force:
         print('    Path exists: {!s}'.format(
             target_path.relative_to(self._score_package_path.parent)))
         sys.exit(1)
     metadata = self._read_score_metadata_json(self._score_package_path)
     metadata['score_package_name'] = self._score_package_path.name
     if orientation == 'portrait':
         rotation = 0
         width, height = self.paper_sizes[paper_size]
     else:
         rotation = -90
         height, width = self.paper_sizes[paper_size]
     metadata['rotation'] = rotation
     metadata['orientation'] = orientation
     metadata['paper_size'] = paper_size
     metadata['height'] = height[0]
     metadata['width'] = width[0]
     metadata['unit'] = height[1]
     metadata['global_staff_size'] = 12
     metadata['uppercase_composer_name'] = metadata['composer_name'].upper()
     metadata['uppercase_title'] = metadata['title'].upper()
     metadata['lilypond_version'] = \
         abjad_configuration.get_lilypond_version_string()
     source_name = 'build'
     source_path = self._get_boilerplate_path().joinpath(source_name)
     suffixes = ('.py', '.tex', '.ly', '.ily')
     for path in self._copy_tree(source_path, target_path):
         if path.is_file() and path.suffix in suffixes:
             self._template_file(path, **metadata)
     print('    Created {!s}'.format(
         target_path.relative_to(self._score_repository_path)))
Esempio n. 3
0
 def _handle_create(
     self,
     target_name,
     force,
     paper_size=None,
     orientation=None,
     ):
     from abjad import abjad_configuration
     if target_name is True:
         name = paper_size.lower().replace(' ', '-')
         name = '{}-{}'.format(name, orientation)
     else:
         name = stringtools.to_dash_case(target_name)
     dimensions = self.paper_sizes[paper_size]
     message = 'Creating build target {!r} ({}{} x {}{})'.format(
         name,
         dimensions[0][0], dimensions[0][1],
         dimensions[1][0], dimensions[1][1],
         )
     print(message)
     target_path = self._name_to_score_subdirectory_path(
         name, 'build', self._score_package_path)
     if target_path.exists() and not force:
         print('    Path exists: {!s}'.format(
             target_path.relative_to(self._score_package_path.parent)))
         sys.exit(1)
     metadata = self._read_score_metadata_json(self._score_package_path)
     metadata['score_package_name'] = self._score_package_path.name
     if orientation == 'portrait':
         rotation = 0
         width, height = self.paper_sizes[paper_size]
     else:
         rotation = -90
         height, width = self.paper_sizes[paper_size]
     metadata['rotation'] = rotation
     metadata['orientation'] = orientation
     metadata['paper_size'] = paper_size
     metadata['height'] = height[0]
     metadata['width'] = width[0]
     metadata['unit'] = height[1]
     metadata['global_staff_size'] = 12
     metadata['uppercase_composer_name'] = metadata['composer_name'].upper()
     metadata['uppercase_title'] = metadata['title'].upper()
     metadata['lilypond_version'] = \
         abjad_configuration.get_lilypond_version_string()
     source_name = 'example_build_target'
     source_path = self._get_boilerplate_path().joinpath(source_name)
     suffixes = ('.py', '.tex', '.ly', '.ily')
     for path in self._copy_tree(source_path, target_path):
         if path.is_file() and path.suffix in suffixes:
             self._template_file(path, **metadata)
     print('    Created {!s}'.format(target_path.relative_to(
         self._score_repository_path)))
Esempio n. 4
0
 def _create_build_target(
     self,
     name,
     score_path,
     paper_size,
     orientation,
     force=False,
     ):
     from abjad import abjad_configuration
     target_path = self._name_to_score_subdirectory_path(
         name, 'build', score_path)
     if target_path.exists() and not force:
         print('    Path exists: {!s}'.format(
             target_path.relative_to(self._score_package_path.parent)))
         sys.exit(1)
     metadata = self._read_score_metadata_json(score_path)
     metadata['score_package_name'] = score_path.name
     if orientation == 'portrait':
         rotation = 0
         width, height = self.paper_sizes[paper_size]
     else:
         rotation = -90
         height, width = self.paper_sizes[paper_size]
     metadata['rotation'] = rotation
     metadata['orientation'] = orientation
     metadata['paper_size'] = paper_size
     metadata['height'] = height[0]
     metadata['width'] = width[0]
     metadata['unit'] = height[1]
     metadata['global_staff_size'] = 12
     metadata['uppercase_composer_name'] = metadata['composer_name'].upper()
     metadata['uppercase_title'] = metadata['title'].upper()
     metadata['lilypond_version'] = \
         abjad_configuration.get_lilypond_version_string()
     source_name = 'example_build_target'
     source_path = self._get_boilerplate_path().joinpath(source_name)
     suffixes = ('.py', '.tex', '.ly', '.ily')
     for path in self._copy_tree(source_path, target_path):
         if path.is_file() and path.suffix in suffixes:
             self._template_file(path, **metadata)
     return target_path
Esempio n. 5
0
 def _create_build_target(
     self,
     name,
     score_path,
     paper_size,
     orientation,
     force=False,
 ):
     from abjad import abjad_configuration
     target_path = self._name_to_score_subdirectory(name, 'builds',
                                                    score_path)
     if target_path.exists() and not force:
         print('    Path exists: {!s}'.format(
             target_path.relative_to(self._score_package_path.parent)))
         sys.exit(1)
     metadata = self._read_score_metadata_json(score_path)
     metadata['score_package_name'] = score_path.name
     if orientation == 'portrait':
         rotation = 0
         width, height = self.paper_sizes[paper_size]
     else:
         rotation = -90
         height, width = self.paper_sizes[paper_size]
     metadata['rotation'] = rotation
     metadata['orientation'] = orientation
     metadata['paper_size'] = paper_size
     metadata['height'] = height[0]
     metadata['width'] = width[0]
     metadata['unit'] = height[1]
     metadata['global_staff_size'] = 12
     metadata['uppercase_composer_name'] = metadata['composer_name'].upper()
     metadata['uppercase_title'] = metadata['title'].upper()
     metadata['lilypond_version'] = \
         abjad_configuration.get_lilypond_version_string()
     source_name = 'build'
     source_path = self._get_boilerplate_path().joinpath(source_name)
     suffixes = ('.py', '.tex', '.ly', '.ily')
     for path in self._copy_tree(source_path, target_path):
         if path.is_file() and path.suffix in suffixes:
             self._template_file(path, **metadata)
     return target_path
Esempio n. 6
0
 def version(self):
     from abjad import abjad_configuration
     if self._version is None:
         return abjad_configuration.get_lilypond_version_string()
     return self._version