Esempio n. 1
0
    def open_last_log():
        r'''Opens LilyPond log file in operating system-specific text
        editor.

        ..  container:: example

            ::

                >>> systemtools.IOManager.open_last_log() # doctest: +SKIP

            ::

                GNU LilyPond 2.19.2
                Processing `0440.ly'
                Parsing...
                Interpreting music...
                Preprocessing graphical objects...
                Finding the ideal number of pages...
                Fitting music on 1 page...
                Drawing systems...
                Layout output to `0440.ps'...
                Converting to `./0440.pdf'...

        Returns none.
        '''
        from abjad import abjad_configuration
        abjad_output_directory = abjad_configuration['abjad_output_directory']
        text_editor = abjad_configuration.get_text_editor()
        log_file_path = os.path.join(abjad_output_directory, 'lily.log')
        command = '{} {}'.format(text_editor, log_file_path)
        IOManager.spawn_subprocess(command)
 def _handle_stage(self):
     from abjad import abjad_configuration
     print('Staging segments:')
     all_names = [
         path.name for path in self._list_segment_subpackages(
             self._score_package_path)
     ]
     old_staged_names = self._read_segments_list_json()
     contents = self._create_staging_contents(all_names, old_staged_names)
     with systemtools.TemporaryDirectory() as directory:
         with systemtools.TemporaryDirectoryChange(directory):
             file_path = 'segments.txt'
             with open(file_path, 'w') as file_pointer:
                 file_pointer.write(contents)
             command = '{} {}'.format(
                 abjad_configuration.get_text_editor(),
                 file_path,
             )
             self._call_subprocess(command)
             with open(file_path, 'r') as file_pointer:
                 contents = file_pointer.read()
     lines = (line.strip() for line in contents.splitlines())
     lines = (line for line in lines if not line.startswith('#'))
     lines = (line for line in lines if line in all_names)
     new_staged_names = list(lines)
     if new_staged_names != old_staged_names:
         self._write_segments_list_json(new_staged_names)
     print('Staged:')
     for name in new_staged_names:
         print('    {}'.format(name))
Esempio n. 3
0
 def _handle_stage(self):
     from abjad import abjad_configuration
     print('Staging segments:')
     all_names = [
         path.name for path in
         self._list_segment_subpackages(self._score_package_path)
         ]
     old_staged_names = self._read_segments_list_json()
     contents = self._create_staging_contents(all_names, old_staged_names)
     with systemtools.TemporaryDirectory() as directory_path:
         with systemtools.TemporaryDirectoryChange(directory_path):
             file_path = 'segments.txt'
             with open(file_path, 'w') as file_pointer:
                 file_pointer.write(contents)
             command = '{} {}'.format(
                 abjad_configuration.get_text_editor(),
                 file_path,
                 )
             self._call_subprocess(command)
             with open(file_path, 'r') as file_pointer:
                 contents = file_pointer.read()
     lines = (line.strip() for line in contents.splitlines())
     lines = (line for line in lines if not line.startswith('#'))
     lines = (line for line in lines if line in all_names)
     new_staged_names = list(lines)
     if new_staged_names != old_staged_names:
         self._write_segments_list_json(new_staged_names)
     print('Staged:')
     for name in new_staged_names:
         print('    {}'.format(name))
Esempio n. 4
0
    def open_last_log():
        r'''Opens LilyPond log file in operating system-specific text
        editor.

        ..  container:: example

            ::

                >>> systemtools.IOManager.open_last_log() # doctest: +SKIP

            ::

                GNU LilyPond 2.19.2
                Processing `0440.ly'
                Parsing...
                Interpreting music...
                Preprocessing graphical objects...
                Finding the ideal number of pages...
                Fitting music on 1 page...
                Drawing systems...
                Layout output to `0440.ps'...
                Converting to `./0440.pdf'...

        Returns none.
        '''
        from abjad import abjad_configuration
        abjad_output_directory = abjad_configuration['abjad_output_directory']
        text_editor = abjad_configuration.get_text_editor()
        log_file_path = os.path.join(abjad_output_directory, 'lily.log')
        command = '{} {}'.format(text_editor, log_file_path)
        IOManager.spawn_subprocess(command)
Esempio n. 5
0
def log():
    r'''Opens the LilyPond log file in operating system-specific text editor.

    ::

        >>> iotools.log() # doctest: +SKIP

    ::

        GNU LilyPond 2.12.2
        Processing `0440.ly'
        Parsing...
        Interpreting music...
        Preprocessing graphical objects...
        Finding the ideal number of pages...
        Fitting music on 1 page...
        Drawing systems...
        Layout output to `0440.ps'...
        Converting to `./0440.pdf'...

    Returns none.
    '''
    from abjad import abjad_configuration
    from abjad.tools import iotools

    abjad_output = abjad_configuration['abjad_output']
    text_editor = abjad_configuration.get_text_editor()
    log_file_path = os.path.join(abjad_output, 'lily.log')
    command = '{} {}'.format(text_editor, log_file_path)
    iotools.spawn_subprocess(command)
Esempio n. 6
0
 def open_last_log() -> None:
     """
     Opens LilyPond log file in operating system-specific text editor.
     """
     text_editor = _configuration.get_text_editor()
     file_path = _configuration.lilypond_log_file_path
     IOManager.open_file(file_path, application=text_editor)
Esempio n. 7
0
 def open_last_log() -> None:
     """
     Opens LilyPond log file in operating system-specific text editor.
     """
     text_editor = _configuration.get_text_editor()
     file_path = _configuration.lilypond_log_file_path
     IOManager.open_file(file_path, application=text_editor)
Esempio n. 8
0
 def process_args(self, args):
     from abjad import abjad_configuration
     text_editor = abjad_configuration.get_text_editor()
     if args.clean:
         if os.path.exists(self.commit_message_path):
             os.remove(self.commit_message_path)
     command = '{} {}'.format(text_editor, self.commit_message_path)
     iotools.spawn_subprocess(command)
 def test_success(self, call_subprocess_mock):
     call_subprocess_mock.return_value = 0
     self.create_score()
     self.create_segment('segment_a')
     self.create_segment('segment_b')
     self.create_segment('segment_c')
     script = commandlinetools.ManageSegmentScript()
     command = ['--stage']
     with systemtools.RedirectedStreams(stdout=self.string_io):
         with systemtools.TemporaryDirectoryChange(str(self.score_path)):
             try:
                 script(command)
             except SystemExit as e:
                 raise RuntimeError('SystemExit: {}'.format(e.code))
     self.compare_captured_output(r'''
     Staging segments:
         Reading test_score/segments/metadata.json ... OK!
     Staged:
         segment_a
         segment_b
         segment_c
     '''.replace('/', os.path.sep))
     call_subprocess_mock.assert_called_with(
         '{} segments.txt'.format(abjad_configuration.get_text_editor()),
         )
     call_subprocess_mock.side_effect = self.side_effect
     self.reset_string_io()
     with systemtools.RedirectedStreams(stdout=self.string_io):
         with systemtools.TemporaryDirectoryChange(str(self.score_path)):
             try:
                 script(command)
             except SystemExit as e:
                 raise RuntimeError('SystemExit: {}'.format(e.code))
     self.compare_captured_output(r'''
     Staging segments:
         Reading test_score/segments/metadata.json ... OK!
         Writing test_score/segments/metadata.json
     Staged:
         segment_c
         segment_b
         segment_a
     '''.replace('/', os.path.sep))
     call_subprocess_mock.assert_called_with(
         '{} segments.txt'.format(abjad_configuration.get_text_editor()),
         )
Esempio n. 10
0
    def open_last_log():
        r'''Opens LilyPond log file in operating system-specific text
        editor.

        Returns none.
        '''
        from abjad import abjad_configuration
        abjad_output_directory = abjad_configuration['abjad_output_directory']
        text_editor = abjad_configuration.get_text_editor()
        log_file_path = os.path.join(abjad_output_directory, 'lily.log')
        command = '{} {}'.format(text_editor, log_file_path)
        IOManager.spawn_subprocess(command)
Esempio n. 11
0
    def open_last_log():
        r'''Opens LilyPond log file in operating system-specific text
        editor.

        Returns none.
        '''
        from abjad import abjad_configuration
        abjad_output_directory = abjad_configuration['abjad_output_directory']
        text_editor = abjad_configuration.get_text_editor()
        log_file_path = os.path.join(abjad_output_directory, 'lily.log')
        command = '{} {}'.format(text_editor, log_file_path)
        IOManager.spawn_subprocess(command)
Esempio n. 12
0
    def open_last_log():
        r'''Opens LilyPond log file in operating system-specific text
        editor.

        Returns none.
        '''
        from abjad import abjad_configuration
        text_editor = abjad_configuration.get_text_editor()
        command = '{} {}'.format(
            text_editor,
            abjad_configuration.lilypond_log_file_path,
            )
        IOManager.spawn_subprocess(command)
Esempio n. 13
0
    def open_last_log():
        r'''Opens LilyPond log file in operating system-specific text
        editor.

        Returns none.
        '''
        from abjad import abjad_configuration
        text_editor = abjad_configuration.get_text_editor()
        command = '{} {}'.format(
            text_editor,
            abjad_configuration.lilypond_log_file_path,
        )
        IOManager.spawn_subprocess(command)
Esempio n. 14
0
 def _handle_edit(self, material_name):
     from abjad import abjad_configuration
     globbable_names = self._collect_globbable_names(material_name)
     print('Edit candidates: {!r} ...'.format(' '.join(globbable_names)))
     matching_paths = self._collect_matching_paths(globbable_names)
     if not matching_paths:
         print('    No matching materials.')
         self._handle_list()
     command = [abjad_configuration.get_text_editor()]
     for path in matching_paths:
         command.append(str(path.joinpath('definition.py')))
     command = ' '.join(command)
     exit_code = self._call_subprocess(command)
     if exit_code:
         sys.exit(exit_code)
Esempio n. 15
0
    def open_last_ly(target=-1):
        r'''Opens last LilyPond output file produced by Abjad.

        Uses operating-specific text editor.

        Set ``target=-2`` to open the next-to-last LilyPond output file
        produced by Abjad, and so on.

        Returns none.
        '''
        from abjad import abjad_configuration
        abjad_output_directory = abjad_configuration['abjad_output_directory']
        text_editor = abjad_configuration.get_text_editor()
        if isinstance(target, int) and target < 0:
            last_lilypond = IOManager.get_last_output_file_name()
            if last_lilypond:
                last_number = last_lilypond
                last_number = last_number.replace('.ly', '')
                last_number = last_number.replace('.pdf', '')
                last_number = last_number.replace('.midi', '')
                last_number = last_number.replace('.mid', '')
                target_number = int(last_number) + (target + 1)
                target_str = '%04d' % target_number
                target_ly = os.path.join(
                    abjad_output_directory,
                    target_str + '.ly',
                    )
            else:
                print('Target LilyPond input file does not exist.')
        elif isinstance(target, int) and 0 <= target:
            target_str = '%04d' % target
            target_ly = os.path.join(
                abjad_output_directory,
                target_str + '.ly',
                )
        elif isinstance(target, str):
            target_ly = os.path.join(abjad_output_directory, target)
        else:
            message = 'can not get target LilyPond input from {}.'
            message = message.format(target)
            raise ValueError(message)
        if os.stat(target_ly):
            command = '{} {}'.format(text_editor, target_ly)
            IOManager.spawn_subprocess(command)
        else:
            message = 'Target LilyPond input file {} does not exist.'
            message = message.format(target_ly)
            print(message)
Esempio n. 16
0
    def open_last_ly(target=-1):
        r'''Opens last LilyPond output file produced by Abjad.

        Uses operating-specific text editor.

        Set ``target=-2`` to open the next-to-last LilyPond output file
        produced by Abjad, and so on.

        Returns none.
        '''
        from abjad import abjad_configuration
        abjad_output_directory = abjad_configuration['abjad_output_directory']
        text_editor = abjad_configuration.get_text_editor()
        if isinstance(target, int) and target < 0:
            last_lilypond = IOManager.get_last_output_file_name()
            if last_lilypond:
                last_number = last_lilypond
                last_number = last_number.replace('.ly', '')
                last_number = last_number.replace('.pdf', '')
                last_number = last_number.replace('.midi', '')
                last_number = last_number.replace('.mid', '')
                target_number = int(last_number) + (target + 1)
                target_str = '%04d' % target_number
                target_ly = os.path.join(
                    abjad_output_directory,
                    target_str + '.ly',
                )
            else:
                print('Target LilyPond input file does not exist.')
        elif isinstance(target, int) and 0 <= target:
            target_str = '%04d' % target
            target_ly = os.path.join(
                abjad_output_directory,
                target_str + '.ly',
            )
        elif isinstance(target, str):
            target_ly = os.path.join(abjad_output_directory, target)
        else:
            message = 'can not get target LilyPond input from {}.'
            message = message.format(target)
            raise ValueError(message)
        if os.stat(target_ly):
            command = '{} {}'.format(text_editor, target_ly)
            IOManager.spawn_subprocess(command)
        else:
            message = 'Target LilyPond input file {} does not exist.'
            message = message.format(target_ly)
            print(message)
Esempio n. 17
0
 def _handle_edit(self, material_name):
     from abjad import abjad_configuration
     globbable_names = self._collect_globbable_names(material_name)
     print('Edit candidates: {!r} ...'.format(
         ' '.join(globbable_names)))
     matching_paths = self._collect_matching_paths(globbable_names)
     if not matching_paths:
         print('    No matching materials.')
         self._handle_list()
     command = [abjad_configuration.get_text_editor()]
     for path in matching_paths:
         command.append(str(path.joinpath('definition.py')))
     command = ' '.join(command)
     exit_code = self._call_subprocess(command)
     if exit_code:
         sys.exit(exit_code)
Esempio n. 18
0
    def open_last_ly(
        target: int = -1,
        ) -> None:
        """
        Opens last LilyPond output file produced by Abjad.

        Uses operating-specific text editor.

        Set ``target=-2`` to open the next-to-last LilyPond output file
        produced by Abjad, and so on.
        """
        abjad_output_directory = _configuration['abjad_output_directory']
        text_editor = _configuration.get_text_editor()
        if isinstance(target, int) and target < 0:
            last_lilypond = IOManager.get_last_output_file_name()
            if last_lilypond:
                last_number = last_lilypond
                last_number = last_number.replace('.ly', '')
                last_number = last_number.replace('.pdf', '')
                last_number = last_number.replace('.midi', '')
                last_number = last_number.replace('.mid', '')
                target_number = int(last_number) + (target + 1)
                target_str = '%04d' % target_number
                target_ly = os.path.join(
                    abjad_output_directory,
                    target_str + '.ly',
                    )
            else:
                print('Target LilyPond input file does not exist.')
        elif isinstance(target, int) and 0 <= target:
            target_str = '%04d' % target
            target_ly = os.path.join(
                abjad_output_directory,
                target_str + '.ly',
                )
        elif isinstance(target, str):
            target_ly = os.path.join(abjad_output_directory, target)
        else:
            message = f'can not get target LilyPond input from {target}.'
            raise ValueError(message)
        if os.path.exists(target_ly):
            IOManager.open_file(target_ly, application=text_editor)
        else:
            message = f'Target LilyPond input file {target_ly} does not exist.'
            print(message)
Esempio n. 19
0
    def open_last_ly(target: int = -1,) -> None:
        """
        Opens last LilyPond output file produced by Abjad.

        Uses operating-specific text editor.

        Set ``target=-2`` to open the next-to-last LilyPond output file
        produced by Abjad, and so on.
        """
        abjad_output_directory = _configuration["abjad_output_directory"]
        text_editor = _configuration.get_text_editor()
        if isinstance(target, int) and target < 0:
            last_lilypond = IOManager.get_last_output_file_name()
            if last_lilypond:
                last_number = last_lilypond
                last_number = last_number.replace(".ly", "")
                last_number = last_number.replace(".pdf", "")
                last_number = last_number.replace(".midi", "")
                last_number = last_number.replace(".mid", "")
                target_number = int(last_number) + (target + 1)
                target_str = "%04d" % target_number
                target_ly = os.path.join(
                    abjad_output_directory, target_str + ".ly"
                )
            else:
                print("Target LilyPond input file does not exist.")
        elif isinstance(target, int) and 0 <= target:
            target_str = "%04d" % target
            target_ly = os.path.join(
                abjad_output_directory, target_str + ".ly"
            )
        elif isinstance(target, str):
            target_ly = os.path.join(abjad_output_directory, target)
        else:
            message = f"can not get target LilyPond input from {target}."
            raise ValueError(message)
        if os.path.exists(target_ly):
            IOManager.open_file(target_ly, application=text_editor)
        else:
            message = f"Target LilyPond input file {target_ly} does not exist."
            print(message)
 def test_success(self, call_subprocess_mock):
     call_subprocess_mock.return_value = 0
     self.create_score()
     material_path = self.create_material('test_material')
     script = abjad.cli.ManageMaterialScript()
     command = ['--edit', 'test_material']
     with abjad.RedirectedStreams(stdout=self.string_io):
         with abjad.TemporaryDirectoryChange(str(self.score_path)):
             try:
                 script(command)
             except SystemExit as e:
                 raise RuntimeError('SystemExit: {}'.format(e.code))
     self.compare_captured_output(r'''
     Edit candidates: 'test_material' ...
     ''')
     definition_path = material_path.joinpath('definition.py')
     command = '{} {!s}'.format(
         abjad_configuration.get_text_editor(),
         definition_path,
         )
     call_subprocess_mock.assert_called_with(command)
 def test_success(self, call_subprocess_mock):
     call_subprocess_mock.return_value = 0
     self.create_score()
     material_path = self.create_material('test_material')
     script = commandlinetools.ManageMaterialScript()
     command = ['--edit', 'test_material']
     with systemtools.RedirectedStreams(stdout=self.string_io):
         with systemtools.TemporaryDirectoryChange(str(self.score_path)):
             try:
                 script(command)
             except SystemExit as e:
                 raise RuntimeError('SystemExit: {}'.format(e.code))
     self.compare_captured_output(r'''
     Edit candidates: 'test_material' ...
     ''')
     definition_path = material_path.joinpath('definition.py')
     command = '{} {!s}'.format(
         abjad_configuration.get_text_editor(),
         definition_path,
         )
     call_subprocess_mock.assert_called_with(command)
 def test_success(self, call_subprocess_mock):
     call_subprocess_mock.return_value = 0
     self.create_score()
     segment_path = self.create_segment('test_segment')
     script = commandlinetools.ManageSegmentScript()
     command = ['--edit', 'test_segment']
     with systemtools.RedirectedStreams(stdout=self.string_io):
         with systemtools.TemporaryDirectoryChange(str(self.score_path)):
             try:
                 script(command)
             except SystemExit as e:
                 raise RuntimeError('SystemExit: {}'.format(e.code))
     self.compare_captured_output(r'''
     Edit candidates: 'test_segment' ...
         Reading test_score/segments/metadata.json ... OK!
     '''.replace('/', os.path.sep))
     definition_path = segment_path.joinpath('definition.py')
     command = '{} {!s}'.format(
         abjad_configuration.get_text_editor(),
         definition_path,
         )
     call_subprocess_mock.assert_called_with(command)
 def test_success(self, call_subprocess_mock):
     call_subprocess_mock.return_value = 0
     self.create_score()
     segment_path = self.create_segment('test_segment')
     script = commandlinetools.ManageSegmentScript()
     command = ['--edit', 'test_segment']
     with systemtools.RedirectedStreams(stdout=self.string_io):
         with systemtools.TemporaryDirectoryChange(str(self.score_path)):
             try:
                 script(command)
             except SystemExit as e:
                 raise RuntimeError('SystemExit: {}'.format(e.code))
     self.compare_captured_output(r'''
     Edit candidates: 'test_segment' ...
         Reading test_score/segments/metadata.json ... OK!
     '''.replace('/', os.path.sep))
     definition_path = segment_path.joinpath('definition.py')
     command = '{} {!s}'.format(
         abjad_configuration.get_text_editor(),
         definition_path,
     )
     call_subprocess_mock.assert_called_with(command)
Esempio n. 24
0
    def open_last_ly(target=-1):
        r'''Opens last LilyPond output file produced by Abjad.

        ..  container:: example

            Opens the last LilyPond output file:

            ::

                >>> systemtools.IOManager.open_last_ly() # doctest: +SKIP

            ::

                % 2014-02-12 14:29

                \version "2.19.2"
                \language "english"

                \header {
                    tagline = \markup {}
                }

                \layout {}

                \paper {}

                \score {
                    {
                        c'4
                    }
                }

        Uses operating-specific text editor.

        Set ``target=-2`` to open the next-to-last LilyPond output file
        produced by Abjad, and so on.

        Returns none.
        '''
        from abjad import abjad_configuration
        ABJADOUTPUT = abjad_configuration['abjad_output_directory']
        text_editor = abjad_configuration.get_text_editor()
        if isinstance(target, int) and target < 0:
            last_lilypond = IOManager.get_last_output_file_name()
            if last_lilypond:
                last_number = last_lilypond
                last_number = last_number.replace('.ly', '')
                last_number = last_number.replace('.pdf', '')
                last_number = last_number.replace('.midi', '')
                last_number = last_number.replace('.mid', '')
                target_number = int(last_number) + (target + 1)
                target_str = '%04d' % target_number
                target_ly = os.path.join(ABJADOUTPUT, target_str + '.ly')
            else:
                print('Target LilyPond input file does not exist.')
        elif isinstance(target, int) and 0 <= target:
            target_str = '%04d' % target
            target_ly = os.path.join(ABJADOUTPUT, target_str + '.ly')
        elif isinstance(target, str):
            target_ly = os.path.join(ABJADOUTPUT, target)
        else:
            message = 'can not get target LilyPond input from {}.'
            message = message.format(target)
            raise ValueError(message)
        if os.stat(target_ly):
            command = '{} {}'.format(text_editor, target_ly)
            IOManager.spawn_subprocess(command)
        else:
            message = 'Target LilyPond input file {} does not exist.'
            message = message.format(target_ly)
            print(message)
Esempio n. 25
0
def ly(target=-1):
    r"""Opens the last LilyPond output file in text editor.

    ..  container:: example

        **Example 1.** Open the last LilyPond output file:

        ::

            >>> iotools.ly() # doctest: +SKIP

        ::

            % Abjad revision 2162
            % 2009-05-31 14:29

            \version "2.12.2"
            \include "english.ly"

            {
                c'4
            }

    ..  container:: example

        **Example 2.** Open the next-to-last LilyPond output file:

        ::

            >>> iotools.ly(-2) # doctest: +SKIP

    Returns none.
    """
    from abjad import abjad_configuration
    from abjad.tools import iotools

    ABJADOUTPUT = abjad_configuration["abjad_output"]
    text_editor = abjad_configuration.get_text_editor()
    if isinstance(target, int) and target < 0:
        last_lilypond = iotools.get_last_output_file_name()
        if last_lilypond:
            last_number = last_lilypond
            last_number = last_number.replace(".ly", "")
            last_number = last_number.replace(".pdf", "")
            last_number = last_number.replace(".midi", "")
            last_number = last_number.replace(".mid", "")
            target_number = int(last_number) + (target + 1)
            target_str = "%04d" % target_number
            target_ly = os.path.join(ABJADOUTPUT, target_str + ".ly")
        else:
            print "Target LilyPond input file does not exist."
    elif isinstance(target, int) and 0 <= target:
        target_str = "%04d" % target
        target_ly = os.path.join(ABJADOUTPUT, target_str + ".ly")
    elif isinstance(target, str):
        target_ly = os.path.join(ABJADOUTPUT, target)
    else:
        message = "can not get target LilyPond input from {}."
        message = message.format(target)
        raise ValueError(message)

    if os.stat(target_ly):
        command = "{} {}".format(text_editor, target_ly)
        iotools.spawn_subprocess(command)
    else:
        message = "Target LilyPond input file {} does not exist."
        message = message.format(target_ly)
        print message
Esempio n. 26
0
    def open_last_ly(target=-1):
        r'''Opens last LilyPond output file produced by Abjad.

        ..  container:: example

            Opens the last LilyPond output file:

            ::

                >>> systemtools.IOManager.open_last_ly() # doctest: +SKIP

            ::

                % 2014-02-12 14:29

                \version "2.19.2"
                \language "english"

                \header {
                    tagline = \markup {}
                }

                \layout {}

                \paper {}

                \score {
                    {
                        c'4
                    }
                }

        Uses operating-specific text editor.

        Set ``target=-2`` to open the next-to-last LilyPond output file
        produced by Abjad, and so on.

        Returns none.
        '''
        from abjad import abjad_configuration
        ABJADOUTPUT = abjad_configuration['abjad_output_directory']
        text_editor = abjad_configuration.get_text_editor()
        if isinstance(target, int) and target < 0:
            last_lilypond = IOManager.get_last_output_file_name()
            if last_lilypond:
                last_number = last_lilypond
                last_number = last_number.replace('.ly', '')
                last_number = last_number.replace('.pdf', '')
                last_number = last_number.replace('.midi', '')
                last_number = last_number.replace('.mid', '')
                target_number = int(last_number) + (target + 1)
                target_str = '%04d' % target_number
                target_ly = os.path.join(ABJADOUTPUT, target_str + '.ly')
            else:
                print('Target LilyPond input file does not exist.')
        elif isinstance(target, int) and 0 <= target:
            target_str = '%04d' % target
            target_ly = os.path.join(ABJADOUTPUT, target_str + '.ly')
        elif isinstance(target, str):
            target_ly = os.path.join(ABJADOUTPUT, target)
        else:
            message = 'can not get target LilyPond input from {}.'
            message = message.format(target)
            raise ValueError(message)
        if os.stat(target_ly):
            command = '{} {}'.format(text_editor, target_ly)
            IOManager.spawn_subprocess(command)
        else:
            message = 'Target LilyPond input file {} does not exist.'
            message = message.format(target_ly)
            print(message)