コード例 #1
0
def write_expr_to_pdf(expr, file_name, print_status=False, tagline=False):
    r"""Writes `expr` to PDF `file_name`.

    ::

        >>> note = Note("c'4")
        >>> iotools.write_expr_to_pdf(note, 'one_note.pdf') # doctest: +SKIP

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

    # massage file_name
    file_name = os.path.expanduser(file_name)
    if not file_name.endswith(".pdf"):
        file_name += ".pdf"

    name, actual_format_time, actual_lilypond_file = iotools.log_render_lilypond_input(expr, tagline=tagline)

    # copy PDF file to file_name
    pdf_name = name[:-3] + ".pdf"
    ABJADOUTPUT = abjad_configuration["abjad_output"]
    full_path_pdf_name = os.path.join(ABJADOUTPUT, pdf_name)
    shutil.move(full_path_pdf_name, file_name)

    if print_status:
        print "PDF written to %r ..." % os.path.basename(file_name)
コード例 #2
0
ファイル: show.py プロジェクト: Alwnikrotikz/abjad
def show(expr, return_timing=False, suppress_pdf=False, docs=False):
    r'''Shows `expr`.

    ..  container:: example

        **Example 1.** Show a note:
            
        ::

            >>> note = Note("c'4")
            >>> show(note) # doctest: +SKIP

    ..  container:: example

        **Example 2.** Show a note and return Abjad and LilyPond processing
        times in seconds:

        ::

            >>> staff = Staff(Note("c'4") * 200)
            >>> show(note, return_timing=True) # doctest: +SKIP
            (0, 3)

    Wraps `expr` in a LilyPond file with settings and overrides suitable
    for the Abjad reference manual When `docs` is true.

    Abjad writes LilyPond input files to the ``~/.abjad/output`` 
    directory by default.

    You may change this by setting the ``abjad_output`` variable in 
    the ``config.py`` file.

    Returns none or timing tuple.
    '''
    from abjad import abjad_configuration
    from abjad.tools import iotools

    name, actual_format_time, actual_lily_time = \
        iotools.log_render_lilypond_input(expr, docs=docs)

    # do not open PDF if we're running py.test regression battery
    if not suppress_pdf:
        pdf_viewer = abjad_configuration['pdf_viewer']
        ABJADOUTPUT = abjad_configuration['abjad_output']
        name = os.path.join(ABJADOUTPUT, name)
        iotools.open_file('%s.pdf' % name[:-3], pdf_viewer)

    # return timing if requested
    if return_timing:
        return actual_format_time, actual_lily_time