示例#1
0
def test_AbjadConfiguration___init___01():
    configuration = abjad.AbjadConfiguration()
    assert configuration.configuration_directory.exists()
    assert configuration.configuration_file_path.exists()
    assert pathlib.Path(configuration.abjad_output_directory).exists()
    for key in [
        "abjad_output_directory",
        "lilypond_path",
        "midi_player",
        "pdf_viewer",
        "text_editor",
    ]:
        assert key in configuration
def test_systemtools_AbjadConfiguration___init___01():

    configuration = abjad.AbjadConfiguration()
    assert configuration.configuration_directory.exists()
    assert configuration.configuration_file_path.exists()
    assert pathlib.Path(configuration.abjad_output_directory).exists()
    for key in [
            'abjad_output_directory',
            'accidental_spelling',
            'lilypond_path',
            'midi_player',
            'pdf_viewer',
            'text_editor',
    ]:
        assert key in configuration
示例#3
0
 def _make_score_package(
     score_package_path,
     composer_email=None,
     composer_full_name=None,
     composer_last_name=None,
     composer_github_username=None,
     composer_library=None,
     score_title=None,
     year=None,
 ):
     import abjad
     configuration = abjad.AbjadConfiguration()
     score_package_name = os.path.basename(score_package_path)
     source_path = os.path.join(
         configuration.boilerplate_directory,
         'score',
     )
     target_path = score_package_path
     if not os.path.exists(target_path):
         shutil.copytree(source_path, target_path)
     else:
         for subentry in os.listdir(source_path):
             subentry_source = os.path.join(source_path, subentry)
             subentry_target = os.path.join(target_path, subentry)
             if os.path.isfile(subentry_source):
                 shutil.copy(subentry_source, subentry_target)
             elif os.path.isdir(subentry_source):
                 shutil.copytree(subentry_source, subentry_target)
             else:
                 raise ValueError(subentry_source)
     old_contents_directory = os.path.join(target_path, 'score')
     new_contents_directory = os.path.join(
         target_path,
         score_package_name,
     )
     shutil.move(old_contents_directory, new_contents_directory)
     suffixes = ('.py', '.tex', '.md', '.rst', '.ly', '.ily')
     for root, directory_name, file_names in os.walk(target_path):
         for file_name in file_names:
             if not file_name.endswith(suffixes):
                 continue
             file_ = os.path.join(root, file_name)
             with open(file_, 'r') as file_pointer:
                 template = file_pointer.read()
             try:
                 template = template.format(
                     composer_email=composer_email,
                     composer_full_name=composer_full_name,
                     composer_github_username=composer_github_username,
                     composer_last_name=composer_last_name,
                     composer_library=composer_library,
                     score_package_name=score_package_name,
                     score_title=score_title,
                     year=year,
                 )
             except (IndexError, KeyError):
                 lines = template.splitlines()
                 for i, line in enumerate(lines):
                     try:
                         lines[i] = line.format(
                             composer_email=composer_email,
                             composer_full_name=composer_full_name,
                             composer_github_username=
                             composer_github_username,
                             composer_last_name=composer_last_name,
                             composer_library=composer_library,
                             score_package_name=score_package_name,
                             score_title=score_title,
                             year=year,
                         )
                     except (KeyError, IndexError, ValueError):
                         pass
                 template = '\n'.join(lines)
             with open(file_, 'w') as file_pointer:
                 file_pointer.write(template)
import os
import abjad
configuration = abjad.AbjadConfiguration()

path_1 = os.path.join(
    configuration.abjad_directory,
    'test_1.ly',
    )
path_2 = os.path.join(
    configuration.abjad_directory,
    'test_2.ly',
    )

lines = [
    r'\language "english"',
    '',
    r'\new Staff {',
    "    c'4",
    "    d'4",
    "    e'4",
    "    f'4",
    ]


def test_TestManager_compare_files_01():
    """
    Is true when lines are exactly the same.
    """

    with abjad.FilesystemState(remove=[path_1, path_2]):
        first_lines = [r'\version "2.19.7"'] + lines