LilyPondFile

class lilypondfiletools.LilyPondFile(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)

A LilyPond file.

Example 1. Makes LilyPond file:

>>> staff = Staff("c'8 d'8 e'8 f'8")
>>> comments = [
...     'File construct as an example.',
...     'Parts shown here for positioning.',
...     ]
>>> includes = [
...     'external-settings-file-1.ly',
...     'external-settings-file-2.ly',
...     ]
>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file(
...     music=staff,
...     default_paper_size=('a5', 'portrait'),
...     comments=comments,
...     includes=includes,
...     global_staff_size=16,
...     )
>>> lilypond_file.header_block.composer = Markup('Josquin')
>>> lilypond_file.header_block.title = Markup('Missa sexti tonus')
>>> lilypond_file.layout_block.indent = 0
>>> lilypond_file.layout_block.left_margin = 15
>>> lilypond_file
LilyPondFile(comments=('File construct as an example.', 'Parts shown here for positioning.'), date_time_token=DateTimeToken(date_string='2016-10-22 15:20'), default_paper_size=('a5', 'portrait'), global_staff_size=16, includes=('external-settings-file-1.ly', 'external-settings-file-2.ly'), items=[<Block(name='header')>, <Block(name='layout')>, <Block(name='paper')>, <Block(name='score')>], lilypond_language_token=LilyPondLanguageToken(), lilypond_version_token=LilyPondVersionToken(version_string='2.19.44'))
>>> print(format(lilypond_file)) 
% 2016-10-22 15:20

% File construct as an example.
% Parts shown here for positioning.

\version "2.19.44"
\language "english"

\include "external-settings-file-1.ly"
\include "external-settings-file-2.ly"

#(set-default-paper-size "a5" 'portrait)
#(set-global-staff-size 16)

\header {
    composer = \markup { Josquin }
    title = \markup { "Missa sexti tonus" }
}

\layout {
    indent = #0
    left-margin = #15
}

\paper {}

\score {
    \new Staff {
        c'8
        d'8
        e'8
        f'8
    }
}
>>> show(lilypond_file) 

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_lilypondfiletools { graph [label=lilypondfiletools]; "abjad.tools.lilypondfiletools.LilyPondFile.LilyPondFile" [color=black, fontcolor=white, group=2, label=<<B>LilyPondFile</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.lilypondfiletools.LilyPondFile.LilyPondFile"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

comments Gets comments of Lilypond file.
date_time_token Gets date-time token.
default_paper_size Gets default paper size of LilyPond file.
global_staff_size Gets global staff size of LilyPond file.
header_block Gets header block.
includes Gets includes of LilyPond file.
items Gets items in LilyPond file.
layout_block Gets layout block.
lilypond_language_token Gets LilyPond language token.
lilypond_version_token Gets LilyPond version token.
new([music, date_time_token, ...]) Makes basic LilyPond file.
paper_block Gets paper block.
score_block Gets score block.
use_relative_includes Is true when LilyPond file should use relative includes.
__eq__(expr) Is true when ID of expr equals ID of Abjad object.
__format__([format_specification]) Formats LilyPond file.
__getitem__(name) Gets LilyPond file item with name.
__hash__() Hashes Abjad object.
__illustrate__() Illustrates LilyPond file.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of LilyPond file.

Read-only properties

LilyPondFile.comments

Gets comments of Lilypond file.

Example 1. Gets comments:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.comments
()

Returns list.

LilyPondFile.date_time_token

Gets date-time token.

Example 1. Gets date-time token:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.date_time_token
DateTimeToken()

Returns date-time token or none.

LilyPondFile.default_paper_size

Gets default paper size of LilyPond file.

Example 1. Gets default paper size:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.default_paper_size is None
True

Set to pair or none.

Defaults to none.

Returns pair or none.

LilyPondFile.global_staff_size

Gets global staff size of LilyPond file.

Example 1. Gets global staff size:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.global_staff_size is None
True

Set to number or none.

Defaults to none.

Returns number or none.

LilyPondFile.header_block

Gets header block.

Example 1. Gets header block:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.header_block
<Block(name='header')>

Returns block or none.

LilyPondFile.includes

Gets includes of LilyPond file.

Example 1. Gets includes:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.includes
()

Returns list.

LilyPondFile.items

Gets items in LilyPond file.

Example 1. Gets items:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> for item in lilypond_file.items:
...     item
...
<Block(name='header')>
<Block(name='layout')>
<Block(name='paper')>
<Block(name='score')>

Returns list.

LilyPondFile.layout_block

Gets layout block.

Example 1. Gets layout block:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.layout_block
<Block(name='layout')>

Returns block or none.

LilyPondFile.lilypond_language_token

Gets LilyPond language token.

Example 1. Gets LilyPond language token:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.lilypond_language_token
LilyPondLanguageToken()

Returns LilyPond language token or none.

LilyPondFile.lilypond_version_token

Gets LilyPond version token.

Example 1. Gets LilyPond version token:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.lilypond_version_token 
LilyPondVersionToken('2.19.44')

Returns LilyPond version token or none.

LilyPondFile.paper_block

Gets paper block.

Example 1. Gets paper block:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.paper_block
<Block(name='paper')>

Returns block or none.

LilyPondFile.score_block

Gets score block.

Example 1. Gets score block:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.score_block
<Block(name='score')>

Returns block or none.

LilyPondFile.use_relative_includes

Is true when LilyPond file should use relative includes.

Example 1. Gets relative include flag:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file.use_relative_includes is None
True

Set to true, false or none.

Returns true, false or none.

Class & static methods

classmethod LilyPondFile.new(music=None, date_time_token=None, default_paper_size=None, comments=None, includes=None, global_staff_size=None, lilypond_language_token=None, lilypond_version_token=None, use_relative_includes=None)

Makes basic LilyPond file.

Return LilyPond file.

Special methods

(AbjadObject).__eq__(expr)

Is true when ID of expr equals ID of Abjad object. Otherwise false.

Returns true or false.

LilyPondFile.__format__(format_specification='')

Formats LilyPond file.

Example 1. Gets format:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> print(format(lilypond_file)) 
% 2016-10-22 15:20

\version "2.19.44"
\language "english"

\header {}

\layout {}

\paper {}

Returns string.

LilyPondFile.__getitem__(name)

Gets LilyPond file item with name.

Example 1. Gets header block:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file['header']
<Block(name='header')>

Raises key error when no item with name is found.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

LilyPondFile.__illustrate__()

Illustrates LilyPond file.

Returns LilyPond file unchanged.

(AbjadObject).__ne__(expr)

Is true when Abjad object does not equal expr. Otherwise false.

Returns true or false.

LilyPondFile.__repr__()

Gets interpreter representation of LilyPond file.

Example 1. Gets interpreter representation:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file()
>>> lilypond_file
LilyPondFile(comments=(), date_time_token=DateTimeToken(date_string='2016-10-22 15:20'), includes=(), items=[<Block(name='header')>, <Block(name='layout')>, <Block(name='paper')>, <Block(name='score')>], lilypond_language_token=LilyPondLanguageToken(), lilypond_version_token=LilyPondVersionToken(version_string='2.19.44'))

Returns string.