Welcome to python-ly’s documentation!¶
This package provides a Python library ly containing various Python modules to parse, manipulate or create documents in LilyPond format. A command line program ly is also provided that can be used to do various manipulations with LilyPond files.
The LilyPond format is a plain text input format that is used by the GNU music typesetter LilyPond (www.lilypond.org).
The python-ly package is Free Software, licensed under the GPL. This package is written by the Frescobaldi developers and is used extensively by the Frescobaldi project. The main author is Wilbert Berendsen.
This documentation describes python-ly 0.9.5.
Contents:
The ly
command¶
Usage:
ly [options] commands file, ...
A tool for manipulating LilyPond source files
Options¶
-v, --version show version number and exit -h, --help show this help text and exit -i, --in-place overwrite input files -o, --output NAME output file name -e, --encoding ENC (input) encoding (default UTF-8) --output-encoding ENC output encoding (default to input encoding) -l, --language NAME default pitch name language (default to “nederlands”) -d <variable=value> set a variable
The special option --
considers the remaining arguments to be file names.
Arguments¶
The command is one argument with semicolon-separated commands. In most cases you’ll quote the command so that it is seen as one argument.
You can specify more than one LilyPond file. If you want to process many
files and write the results of the operations on each file to a separate
output file, you can use two special characters in the output filename: a
‘*’ will be replaced with the full path name of the current input file
(without extension), and a ‘?’ will be replaced with the input filename
(without path and extension). If you don’t want to have ‘*’ or ‘?’ replaced
in the output filename, you can set -d replace-pattern=false
.
If you don’t specify input or output filenames, standard input is read and standard output is written to.
Commands¶
Informative commands that write information to standard output and do not change the file:
mode
- print the mode (guessing if not given) of the document
version
- print the LilyPond version, if set in the document
language
- print the pitch name language, if set in the document
Commands that change the file:
indent
- re-indent the file
reformat
- reformat the file
translate <language>
- translate the pitch names to the language
transpose <from> <to>
- transpose the file like LilyPond would do, pitches are given in the ‘nederlands’ language
abs2rel
- convert absolute music to relative
rel2abs
- convert relative music to absolute
simplify-accidentals
- replace notes with accidentals as much as possible with their natural neighbors
write [filename]
- write the file to the given filename or the output variable. If the last command was an editing command, write is automatically called.
Commands that export the file to another format:
musicxml [filename]
- export to MusicXML (in development, far from complete)
highlight [filename]
- export the document as syntax colored HTML
hl [filename]
- alias for highlight
Between commands, you can set or unset a variable using:
variable=value
- set a variable to value. Special values are true, false, which are interpreted as boolean values, or digits, which will be interpreted as integer values.
variable=
- unset a variable
Variables¶
The following variables can be set to influence the behaviour of commands. If there is a default value, it is written between brackets:
mode
- mode of the file to read (default automatic) can be one of: lilypond, scheme, latex, html, docbook, texinfo.
output
[-]- the output filename (also set by -o argument)
encoding
[UTF-8]- encoding to read (also set by -e argument)
default-language
[nederlands]- the pitch names language to use by default, when not specified otherwise in the document
output-encoding
- encoding to write (defaults to
encoding
, also set by the--output-encoding
argument)in-place
[false
]- whether to overwrite input files (same as
-i
)backup-suffix
[~]- suffix to use when editing files in-place, if set, backs up the original file before overwriting it
replace-pattern
[true
]- whether to replace ‘*’ and ‘?’ in the output filename.
rel-startpitch
[true
]- whether to write relative music with a startpitch
rel-absolute
- whether to assume that the first pitch in a relative expression without specified startpitch is absolute. If
false
, it is assumed to be relative toc'
. Iftrue
, it is assumed to be absolute (in fact relative tof
. If not set, this variable defaults totrue
only when the LilyPond version in the document >= 2.18.indent-tabs
[false
]- whether to use tabs for indent
indent-width
[2]- how many spaces for each indent level (if not using tabs)
full-html
[True
]- if set to True a full document with syntax-highlighted HTML will be exported, otherwise only the bare content wrapped in an element configured by the
wrapper-
variables.stylesheet
- filename to reference as an external stylesheet for syntax-highlighted HTML. This filename is literally used in the
<link rel="stylesheet">
tag.inline-style
[false
]- whether to use inline style attributes for syntax-highlighted HTML. By default a css stylesheet is embedded.
number-lines
[false
]- whether to add line numbers when creating syntax-highlighted HTML.
wrapper-tag
[pre
]- which tag syntax highlighted HTML will be wrapped in. Possible values:
div
,pre
,id
andcode
wrapper-attribute
[class
]- attribute used for the wrapper tag. Possible values:
id
andclass
.document-id
[lilypond
]- name applied to the wrapper-attribute. If the three last options use their default settings the highlighted HTML elements are wrapped in an element
<pre class="lilypond"></pre>
linenumbers-id
[linenumbers
]- if linenumbers are exported this is the name used for the
<td>
elements
These variables influence the output of information commands:
with-filename
- prints the filename next to information like version, etc. This is
true
by default if there is more than one file specified.
Examples¶
Here is an example to re-indent and transpose a LilyPond file:
ly "indent; transpose c d" -o output.ly file.ly
Examples using the ‘*’ in the output file name:
ly "transpose c d" *.ly -o '*-transposed.ly'
ly highlight *.ly -o 'html/?.html'
The ly-server
command¶
Usage:
ly-server [options]
An HTTP server for manipulating LilyPond input code
Server Options¶
-v, --version show version number and exit -h, --help show this help text and exit -p, --port PORT port server listens to (default 5432) -t, --timeout TIME If set, server shuts down automatically after -t seconds of inactivity NOT IMPLEMENTED YET!
Command Options¶
-e, --encoding ENC (input) encoding (default UTF-8) --output-encoding ENC output encoding (default to input encoding) -l, --language NAME default pitch name language (default to “nederlands”) -d <variable=value> set a variable (see below)
Command options define defaults for the execution of commands triggered by HTTP requests. These options can be overridden by the individual HTTP request.
HTTP Requests¶
GET Requests¶
Some GET requests will be implemented later to retrieve values or change some server settings based on the URL path.
POST Requests¶
The server accepts POST requests without (currently) making use of the URL path. As the request body it expects a single JSON string with the following elements:
commands
(mandatory)An array with one or more commands to be executed subsequently. Each entry contains:
command
(mandatory):- A name for the command. It has to be one out of the list of available commands below.
args
(optional):- If a command requires arguments (e.g. the
transpose
command) they are given as a single string value.variables
(optional):- A dictionary of variable assignments. Keys have to be from the list below, and proper value types are checked. If one or more variables are given they will be set before the command is executed. A variable may be modified again before the execution of the next command but it is not reset automatically. Giving a variable with a value of ‘’ unsets the variable.
options
(optional)- A dictionary of option assignments. Keys have to be from the above list of Command Options, taking the long name without the leading hyphens, e.g.
{ "encoding": "UTF-16" }
. If an option is given here it overrides the default option given on the command line, but only for the current command.data
(mandatory)- A single string containing the LilyPond input document.
The server will try to construct a series of commands from the request, and if anything is wrong with it send a “Bad Request” message with HTTP response code 400.
Response Object¶
If the commands execute successfully the response body will contain a serialized JSON object with the following elements:
info
- An array of entries with the result of “info” commands (see below). Each entry has a
command
and aninfo
field.doc
An object with two fields:
content
- A string with the content of the document with all “edit” commands applied consecutively. (If no edit commands have been specified this contains the original input.
commands
- An array with the names of the commands that have been applied.
exports
An array with entries for each applied “export” command. Each entry has the following fields:
doc
- A string with the content of the converted/exported document
command
- The name of the applied command
Commands¶
There are three types of commands whose results are handled independently:
- “info” commands retrieve metadata from the input document
- “edit” commands modify the document, subsequent edit commands cascade the modifications
- “export” commands that convert the input to another format. Subsequent commands are not affected by the result of export commands.
Informative commands that return information and do not change the file:
mode
- print the mode (guessing if not given) of the document
version
- print the LilyPond version, if set in the document
language
- print the pitch name language, if set in the document
Commands that modify the input:
indent
- re-indent the file
reformat
- reformat the file
translate <language>
- translate the pitch names to the language
transpose <from> <to>
- transpose the file like LilyPond would do, pitches are given in the ‘nederlands’ language
abs2rel
- convert absolute music to relative
rel2abs
- convert relative music to absolute
Commands that convert the input to another format:
musicxml
- convert to MusicXML (in development, far from complete)
highlight
- export the document as syntax colored HTML
Variables¶
The following variables can be set to influence the behaviour of commands. If there is a default value, it is written between brackets:
mode
- mode of the input to read (default automatic) can be one of: lilypond, scheme, latex, html, docbook, texinfo.
encoding
[UTF-8]- encoding to read (also set by -e argument)
default-language
[nederlands]- the pitch names language to use by default, when not specified otherwise in the document
output-encoding
- encoding to write (defaults to
encoding
, also set by the--output-encoding
argument)indent-tabs
[false
]- whether to use tabs for indent
indent-width
[2]- how many spaces for each indent level (if not using tabs)
full-html
[True
]- if set to True a full document with syntax-highlighted HTML will be exported, otherwise only the bare content wrapped in an element configured by the
wrapper-
variables.stylesheet
- filename to reference as an external stylesheet for syntax-highlighted HTML. This filename is literally used in the
<link rel="stylesheet">
tag.inline-style
[false
]- whether to use inline style attributes for syntax-highlighted HTML. By default a css stylesheet is embedded.
number-lines
[false
]- whether to add line numbers when creating syntax-highlighted HTML.
wrapper-tag
[pre
]- which tag syntax highlighted HTML will be wrapped in. Possible values:
div
,pre
,id
andcode
wrapper-attribute
[class
]- attribute used for the wrapper tag. Possible values:
id
andclass
.document-id
[lilypond
]- name applied to the wrapper-attribute. If the three last options use their default settings the highlighted HTML elements are wrapped in an element
<pre class="lilypond"></pre>
linenumbers-id
[linenumbers
]- if linenumbers are exported this is the name used for the
<td>
elements
Examples¶
Here is the basic invocation, listening on port 5432:
ly-server
Specifying port and a timeout:
ly-server -p 4000 -t 5000
Sample Requests¶
The simplest request, just applying one edit command. In this case the result
will be in result['doc']['content']
:
{
'commands': [
{
'command': 'indent'
}
],
'data' : "\relative c' { c ( d e f ) }"
}
Another simple request, this time applying an “info” command. The result will
be in result['info']
, containing lilypond
in the info
field and
mode
in the command
field:
{
'commands': [
{
'command': 'mode'
}
],
'data' : "\relative c' { c ( d e f ) }"
}
And a more complex example. This will first transpose the document and then
convert the transposed version independently to highlighted HTML and MusicXML.
Additionally it will retrieve the mode. This time the result will be in all
three places: the transposed document in doc.content
, the mode in
info.info
, and HTML and MusicXML in exports[0].doc
and exports[1].doc
.:
{
'commands': [
{
'command': 'transpose',
'args': 'c d'
},
{
'command': 'highlight',
'variables': { 'full-html': 'false' }
},
{ 'command': 'musicxml' },
{ 'command': 'mode' },
],
'options': {
'language': "deutsch"
},
'data': "\relative c' { c4 ( d e ) }"
}
The ly
package¶
Module contents¶
A package of modules dealing with LilyPond and the LilyPond format.
The ly module supports both Python2 and Python3. This is a short description of some modules:
- ly.slexer: generic tools to build parsers using regular expressions
- ly.node: a generic list-like node object to build tree structures with
- ly.document: a tokenized text document (LilyPond file)
- ly.docinfo: harvests and caches various information from a LilyPond document
- ly.lex: a parser for LilyPond, Scheme, and other formats, using slexer
- ly.music: a tree structure of the contents of a document
- ly.pitch: functions for translating, transposing etc
- ly.rhythm: functions dealing with rhythm
- ly.indent: indent LilyPond text
- ly.reformat: format LilyPond text
- ly.dom: (deprecated) tree structure to build LilyPond text from
- ly.words: words for highlighting and autocompletion
- ly.data: layout objects, properties, interfaces, font glyphs etc extracted from LilyPond
- ly.cli: the implementation of the command-line ‘ly’ script
A LilyPond document (source file) is held by a ly.document.Document. The Document class automatically parses and tokenizes the text, also when its contents are changed.
A music tree can be built from a document using the ly.music module. In the near future, music trees can be built from scratch and also generate LilyPond output from scratch. At that moment, ly.dom is deprecated.
The functions in ly.pitch, such as transpose and translate currently access the tokens in the document, but in the future they will work on the music tree.
Subpackages¶
ly.lex package¶
Module contents¶
This module is built on top of slexer and can parse LilyPond input and other formats.
The base functionality is delegated to modules with an underscore in this package. The modules describing parsing modes (filetypes) are the files without underscore.
Currently available are modes for lilypond, latex, html, texinfo, scheme, and docbook.
The ‘underscored’ modules should not be imported in application code. What is needed from them is available here, in the ly.lex namespace.
If you add new files for parsing other file types, you should add them in _mode.py. The _token.py module contains base Token types and Token mixin classes.
The State, Parser, FallthroughParser and Fridge classes from slexer are all slightly extended here,
Usage:
>>> import ly.lex
>>> txt = r"\relative c' { c d e f-^ g }"
>>> s = ly.lex.state("lilypond")
>>> for t in s.tokens(txt):
... print(t, t.__class__.__name__)
\relative Command
Space
c Name
' Unparsed
Space
{ SequentialStart
Space
c Note
Space
d Note
Space
e Note
Space
f Note
- Direction
^ ScriptAbbreviation
Space
g Note
Space
} SequentialEnd
A State() is used to parse text. The text is given to the tokens() method, that returns an iterator iterating over Token instances as they are found. Each token has a ‘pos’ and an ‘end’ attribute describing its position in the original string.
While iterating over the tokens(), the State maintains information about what kind of text is parsed. (So don’t iterate over more than one call to tokens() of the same State object at the same time.)
Use ly.lex.state(“name”) to get a state for a specific mode to start parsing with. If you don’t know the type of text, you can use ly.lex.guessState(text), where text is the text you want to parse. A quick heuristic is then used to determine the type of the text.
See for more information the documentation of the slexer module.
-
class
ly.lex.
State
(initialParserClass)[source]¶ Bases:
ly.slexer.State
-
class
ly.lex.
Parser
(argcount=None)[source]¶ Bases:
ly.slexer.Parser
-
argcount
= 0¶
-
default
¶ alias of
ly.lex._token.Unparsed
-
mode
= None¶
-
re_flags
= 40¶
-
-
class
ly.lex.
Fridge
(stateClass=<class 'ly.lex.State'>)[source]¶ Bases:
ly.slexer.Fridge
-
ly.lex.
guessMode
(text)[source]¶ Tries to guess the type of the input text, using a quite fast heuristic.
Returns one of the strings also present as key in the modes dictionary.
-
class
ly.lex.
Token
[source]¶ Bases:
ly.slexer.Token
-
class
ly.lex.
Unparsed
[source]¶ Bases:
ly.lex._token.Token
Represents an unparsed piece of input text.
-
class
ly.lex.
Newline
[source]¶ Bases:
ly.lex._token.Space
A token that is a single newline.
-
rx
= u'\\n'¶
-
-
class
ly.lex.
Comment
[source]¶ Bases:
ly.lex._token.Token
Base class for tokens that belong to a comment.
-
class
ly.lex.
LineComment
[source]¶ Bases:
ly.lex._token.Comment
Base class for items that are a whole line comment.
-
class
ly.lex.
BlockComment
[source]¶ Bases:
ly.lex._token.Comment
Base class for tokens that belong to a block/multiline comment.
-
class
ly.lex.
BlockCommentStart
[source]¶ Bases:
ly.lex._token.BlockComment
Base class for tokens that start a block/multiline comment.
-
class
ly.lex.
BlockCommentEnd
[source]¶ Bases:
ly.lex._token.BlockComment
Base class for tokens that end a block/multiline comment.
-
class
ly.lex.
String
[source]¶ Bases:
ly.lex._token.Token
Base class for tokens that belong to a quote-delimited string.
-
class
ly.lex.
StringStart
[source]¶ Bases:
ly.lex._token.String
Base class for tokens that start a quote-delimited string.
-
class
ly.lex.
StringEnd
[source]¶ Bases:
ly.lex._token.String
Base class for tokens that end a quote-delimited string.
-
class
ly.lex.
Character
[source]¶ Bases:
ly.lex._token.Token
Base class for tokens that are an (escaped) character.
-
class
ly.lex.
Numeric
[source]¶ Bases:
ly.lex._token.Token
Base class for tokens that are a numerical value.
-
class
ly.lex.
Error
[source]¶ Bases:
ly.lex._token.Token
Base class for tokens that represent erroneous input.
-
class
ly.lex.
MatchStart
[source]¶ Bases:
object
Mixin class for tokens that have a matching token forward in the text.
The matchname attribute should give a unique name.
-
matchname
= u''¶
-
-
class
ly.lex.
MatchEnd
[source]¶ Bases:
object
Mixin class for tokens that have a matching token backward in the text.
The matchname attribute should give a unique name.
-
matchname
= u''¶
-
Submodules¶
ly.lex.docbook module¶
Parses and tokenizes DocBook input, recognizing LilyPond in DocBook.
ly.lex.html module¶
Parses and tokenizes HTML input, recognizing LilyPond in HTML.
-
class
ly.lex.html.
CommentEnd
[source]¶ Bases:
ly.lex.html.Comment
,ly.lex._token.Leaver
,ly.lex._token.BlockCommentEnd
-
rx
= u'-->'¶
-
-
class
ly.lex.html.
CommentStart
[source]¶ Bases:
ly.lex.html.Comment
,ly.lex._token.BlockCommentStart
-
rx
= u'<!--'¶
-
-
class
ly.lex.html.
EntityRef
[source]¶ Bases:
ly.lex._token.Character
-
rx
= u'\\&(#\\d+|#[xX][0-9A-Fa-f]+|[A-Za-z_:][\\w.:_-]*);'¶
-
-
class
ly.lex.html.
LilyPondCloseTag
[source]¶ Bases:
ly.lex.html.LilyPondTag
,ly.lex._token.Leaver
-
rx
= u'</lilypond>'¶
-
-
class
ly.lex.html.
LilyPondFileTag
[source]¶ Bases:
ly.lex.html.LilyPondTag
-
rx
= u'</?lilypondfile\\b'¶
-
-
class
ly.lex.html.
LilyPondFileTagEnd
[source]¶ Bases:
ly.lex.html.LilyPondTag
,ly.lex._token.Leaver
-
rx
= u'/?>'¶
-
-
class
ly.lex.html.
LilyPondInlineTag
[source]¶ Bases:
ly.lex.html.LilyPondTag
-
rx
= u'<lilypond\\b'¶
-
-
class
ly.lex.html.
LilyPondInlineTagEnd
[source]¶ Bases:
ly.lex.html.LilyPondTag
,ly.lex._token.Leaver
-
rx
= u'/?>'¶
-
-
class
ly.lex.html.
LilyPondTag
[source]¶ Bases:
ly.lex.html.Tag
-
class
ly.lex.html.
LilyPondTagEnd
[source]¶ Bases:
ly.lex.html.LilyPondTag
-
rx
= u'>'¶
-
-
class
ly.lex.html.
LilyPondVersionTag
[source]¶ Bases:
ly.lex.html.LilyPondTag
-
rx
= u'<lilypondversion/?>'¶
-
-
class
ly.lex.html.
ParseAttr
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.html.TagEnd'>, <class 'ly.lex.html.AttrName'>, <class 'ly.lex.html.EqualSign'>, <class 'ly.lex.html.StringDQStart'>, <class 'ly.lex.html.StringSQStart'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x24c0b70>¶
-
-
class
ly.lex.html.
ParseComment
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.html.CommentEnd'>,)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.html.
ParseHTML
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.html.LilyPondVersionTag'>, <class 'ly.lex.html.LilyPondFileTag'>, <class 'ly.lex.html.LilyPondInlineTag'>, <class 'ly.lex.html.CommentStart'>, <class 'ly.lex.html.TagStart'>, <class 'ly.lex.html.EntityRef'>)¶
-
mode
= u'html'¶
-
pattern
= <_sre.SRE_Pattern object at 0x326e080>¶
-
-
class
ly.lex.html.
ParseLilyPond
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseGlobal
-
items
= (<class 'ly.lex.html.LilyPondCloseTag'>, <class 'ly.lex.lilypond.Book'>, <class 'ly.lex.lilypond.BookPart'>, <class 'ly.lex.lilypond.Score'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.Paper'>, <class 'ly.lex.lilypond.Header'>, <class 'ly.lex.lilypond.Layout'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>, <class 'ly.lex.lilypond.Name'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.DecimalValue'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3277040>¶
-
-
class
ly.lex.html.
ParseLilyPondAttr
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.html.AttrName'>, <class 'ly.lex.html.EqualSign'>, <class 'ly.lex.html.StringDQStart'>, <class 'ly.lex.html.StringSQStart'>, <class 'ly.lex.html.LilyPondTagEnd'>, <class 'ly.lex.html.SemiColon'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2b2df50>¶
-
-
class
ly.lex.html.
ParseLilyPondFileOptions
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.html.AttrName'>, <class 'ly.lex.html.EqualSign'>, <class 'ly.lex.html.StringDQStart'>, <class 'ly.lex.html.StringSQStart'>, <class 'ly.lex.html.LilyPondFileTagEnd'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x306ad10>¶
-
-
class
ly.lex.html.
ParseLilyPondInline
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseMusic
-
items
= (<class 'ly.lex.html.LilyPondInlineTagEnd'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.Dynamic'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Spacer'>, <class 'ly.lex.lilypond.Q'>, <class 'ly.lex.lilypond.Rest'>, <class 'ly.lex.lilypond.Note'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.Octave'>, <class 'ly.lex.lilypond.OctaveCheck'>, <class 'ly.lex.lilypond.AccidentalCautionary'>, <class 'ly.lex.lilypond.AccidentalReminder'>, <class 'ly.lex.lilypond.PipeSymbol'>, <class 'ly.lex.lilypond.VoiceSeparator'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SequentialEnd'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.SimultaneousEnd'>, <class 'ly.lex.lilypond.ChordStart'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.SlurStart'>, <class 'ly.lex.lilypond.SlurEnd'>, <class 'ly.lex.lilypond.PhrasingSlurStart'>, <class 'ly.lex.lilypond.PhrasingSlurEnd'>, <class 'ly.lex.lilypond.Tie'>, <class 'ly.lex.lilypond.BeamStart'>, <class 'ly.lex.lilypond.BeamEnd'>, <class 'ly.lex.lilypond.LigatureStart'>, <class 'ly.lex.lilypond.LigatureEnd'>, <class 'ly.lex.lilypond.Direction'>, <class 'ly.lex.lilypond.StringNumber'>, <class 'ly.lex.lilypond.IntegerValue'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>, <class 'ly.lex.lilypond.TremoloColon'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x327e4d0>¶
-
-
class
ly.lex.html.
ParseStringDQ
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.html.StringDQEnd'>, <class 'ly.lex.html.EntityRef'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3002d30>¶
-
-
class
ly.lex.html.
ParseStringSQ
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.html.StringSQEnd'>, <class 'ly.lex.html.EntityRef'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x30026e0>¶
-
-
class
ly.lex.html.
ParseValue
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
Finds a value or drops back.
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.html.Value'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.html.
StringDQEnd
[source]¶ Bases:
ly.lex.html.String
,ly.lex._token.StringEnd
,ly.lex._token.Leaver
-
rx
= u'"'¶
-
-
class
ly.lex.html.
StringDQStart
[source]¶ Bases:
ly.lex.html.String
,ly.lex._token.StringStart
-
rx
= u'"'¶
-
-
class
ly.lex.html.
StringSQEnd
[source]¶ Bases:
ly.lex.html.String
,ly.lex._token.StringEnd
,ly.lex._token.Leaver
-
rx
= u"'"¶
-
-
class
ly.lex.html.
StringSQStart
[source]¶ Bases:
ly.lex.html.String
,ly.lex._token.StringStart
-
rx
= u"'"¶
-
-
class
ly.lex.html.
TagEnd
[source]¶ Bases:
ly.lex.html.Tag
,ly.lex._token.Leaver
-
rx
= u'/?>'¶
-
-
class
ly.lex.html.
TagStart
[source]¶ Bases:
ly.lex.html.Tag
-
rx
= u'</?\\w[-_:\\w]*\\b'¶
-
ly.lex.latex module¶
Parses and tokenizes LaTeX input, recognizing LilyPond in LaTeX.
ly.lex.lilypond module¶
Parses and tokenizes LilyPond input.
-
class
ly.lex.lilypond.
AccidentalCautionary
[source]¶ Bases:
ly.lex.lilypond.Accidental
-
rx
= u'\\?'¶
-
-
class
ly.lex.lilypond.
AccidentalReminder
[source]¶ Bases:
ly.lex.lilypond.Accidental
-
rx
= u'!'¶
-
-
class
ly.lex.lilypond.
AccidentalStyle
[source]¶ Bases:
ly.lex.lilypond.Command
-
rx
= u'\\\\accidentalStyle\\b'¶
-
-
class
ly.lex.lilypond.
AccidentalStyleSpecifier
[source]¶ Bases:
ly.lex.lilypond.Specifier
-
rx
= u'\\b(default|voice|modern|modern-cautionary|modern-voice|modern-voice-cautionary|piano|piano-cautionary|neo-modern|neo-modern-cautionary|neo-modern-voice|neo-modern-voice-cautionary|dodecaphonic|teaching|no-reset|forget)(?!-?\\w)'¶
-
-
class
ly.lex.lilypond.
AlterBroken
[source]¶ Bases:
ly.lex.lilypond.Command
-
rx
= u'\\\\alterBroken\\b'¶
-
-
class
ly.lex.lilypond.
Articulation
[source]¶ Bases:
ly.lex._token.Token
Base class for articulation things.
-
class
ly.lex.lilypond.
ArticulationCommand
[source]¶ Bases:
ly.lex.lilypond.Articulation
,ly.lex.lilypond.IdentifierRef
-
class
ly.lex.lilypond.
BackSlashedContextName
[source]¶ Bases:
ly.lex.lilypond.ContextName
-
rx
= u'\\\\(ChoirStaff|ChordNames|CueVoice|Devnull|DrumStaff|DrumVoice|Dynamics|FiguredBass|FretBoards|Global|GrandStaff|GregorianTranscriptionStaff|GregorianTranscriptionVoice|KievanStaff|KievanVoice|Lyrics|MensuralStaff|MensuralVoice|NoteNames|NullVoice|PetrucciStaff|PetrucciVoice|PianoStaff|RhythmicStaff|Score|Staff|StaffGroup|TabStaff|TabVoice|Timing|VaticanaStaff|VaticanaVoice|Voice)\\b'¶
-
-
class
ly.lex.lilypond.
BeamEnd
[source]¶ Bases:
ly.lex.lilypond.Beam
,ly.lex._token.MatchEnd
-
matchname
= u'beam'¶
-
rx
= u'\\]'¶
-
-
class
ly.lex.lilypond.
BeamStart
[source]¶ Bases:
ly.lex.lilypond.Beam
,ly.lex._token.MatchStart
-
matchname
= u'beam'¶
-
rx
= u'\\['¶
-
-
class
ly.lex.lilypond.
BlockComment
[source]¶ Bases:
ly.lex.lilypond.Comment
,ly.lex._token.BlockComment
-
class
ly.lex.lilypond.
BlockCommentEnd
[source]¶ Bases:
ly.lex.lilypond.Comment
,ly.lex._token.BlockCommentEnd
,ly.lex._token.Leaver
-
rx
= u'%}'¶
-
-
class
ly.lex.lilypond.
BlockCommentStart
[source]¶ Bases:
ly.lex.lilypond.Comment
,ly.lex._token.BlockCommentStart
-
rx
= u'%{'¶
-
-
class
ly.lex.lilypond.
Book
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\book\\b'¶
-
-
class
ly.lex.lilypond.
BookPart
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\bookpart\\b'¶
-
-
class
ly.lex.lilypond.
Change
[source]¶ Bases:
ly.lex.lilypond.Translator
-
rx
= u'\\\\change\\b'¶
-
-
class
ly.lex.lilypond.
ChordEnd
[source]¶ Bases:
ly.lex.lilypond.Chord
,ly.lex._token.Leaver
-
rx
= u'>'¶
-
-
class
ly.lex.lilypond.
ChordMode
[source]¶ Bases:
ly.lex.lilypond.InputMode
-
rx
= u'\\\\(chords|chordmode)\\b'¶
-
-
class
ly.lex.lilypond.
ChordModifier
[source]¶ Bases:
ly.lex.lilypond.ChordItem
-
rx
= u'((?<![a-z])|^)(aug|dim|sus|min|maj|m)(?![a-z])'¶
-
-
class
ly.lex.lilypond.
ChordSeparator
[source]¶ Bases:
ly.lex.lilypond.ChordItem
-
rx
= u':|\\^|/\\+?'¶
-
-
class
ly.lex.lilypond.
ChordStart
[source]¶ Bases:
ly.lex.lilypond.Chord
-
rx
= u'<'¶
-
-
class
ly.lex.lilypond.
ChordStepNumber
[source]¶ Bases:
ly.lex.lilypond.ChordItem
-
rx
= u'\\d+[-+]?'¶
-
-
class
ly.lex.lilypond.
Clef
[source]¶ Bases:
ly.lex.lilypond.Command
-
rx
= u'\\\\clef\\b'¶
-
-
class
ly.lex.lilypond.
ClefSpecifier
[source]¶ Bases:
ly.lex.lilypond.Specifier
-
rx
= u'\\b(alto|baritone|bass|C|F|french|G|GG|mezzosoprano|percussion|soprano|subbass|tab|tenor|tenorG|treble|varbaritone|varC|varpercussion|violin)\\b'¶
-
-
class
ly.lex.lilypond.
CloseBracket
[source]¶ Bases:
ly.lex.lilypond.Delimiter
,ly.lex._token.MatchEnd
,ly.lex._token.Dedent
-
matchname
= u'bracket'¶
-
rx
= u'\\}'¶
-
-
class
ly.lex.lilypond.
CloseBracketMarkup
[source]¶ Bases:
ly.lex.lilypond.CloseBracket
-
class
ly.lex.lilypond.
CloseSimultaneous
[source]¶ Bases:
ly.lex.lilypond.Delimiter
,ly.lex._token.MatchEnd
,ly.lex._token.Dedent
-
matchname
= u'simultaneous'¶
-
rx
= u'>>'¶
-
-
class
ly.lex.lilypond.
Command
[source]¶ Bases:
ly.lex._token.Item
,ly.lex.lilypond.IdentifierRef
-
class
ly.lex.lilypond.
Context
[source]¶ Bases:
ly.lex.lilypond.Translator
-
rx
= u'\\\\context\\b'¶
-
-
class
ly.lex.lilypond.
ContextName
[source]¶ Bases:
ly.lex._token.Token
-
rx
= u'\\b(ChoirStaff|ChordNames|CueVoice|Devnull|DrumStaff|DrumVoice|Dynamics|FiguredBass|FretBoards|Global|GrandStaff|GregorianTranscriptionStaff|GregorianTranscriptionVoice|KievanStaff|KievanVoice|Lyrics|MensuralStaff|MensuralVoice|NoteNames|NullVoice|PetrucciStaff|PetrucciVoice|PianoStaff|RhythmicStaff|Score|Staff|StaffGroup|TabStaff|TabVoice|Timing|VaticanaStaff|VaticanaVoice|Voice)\\b'¶
-
-
class
ly.lex.lilypond.
ContextProperty
[source]¶ Bases:
ly.lex.lilypond.Variable
-
rx
= u'\\b(aDueText|accidentalGrouping|additionalPitchPrefix|alignAboveContext|alignBassFigureAccidentals|alignBelowContext|alternativeNumberingStyle|associatedVoice|autoAccidentals|autoBeamCheck|autoBeaming|autoCautionaries|automaticBars|barAlways|barCheckSynchronize|barNumberFormatter|barNumberVisibility|baseMoment|bassFigureFormatFunction|bassStaffProperties|beamExceptions|beamHalfMeasure|beatStructure|chordChanges|chordNameExceptions|chordNameExceptionsFull|chordNameExceptionsPartial|chordNameFunction|chordNameLowercaseMinor|chordNameSeparator|chordNoteNamer|chordPrefixSpacer|chordRootNamer|clefGlyph|clefPosition|clefTransposition|clefTranspositionFormatter|clefTranspositionStyle|completionBusy|completionUnit|connectArpeggios|countPercentRepeats|createKeyOnClefChange|createSpacing|crescendoSpanner|crescendoText|cueClefGlyph|cueClefPosition|cueClefTransposition|cueClefTranspositionFormatter|cueClefTranspositionStyle|currentBarNumber|decrescendoSpanner|decrescendoText|defaultBarType|defaultStrings|doubleRepeatSegnoType|doubleRepeatType|doubleSlurs|drumPitchTable|drumStyleTable|endRepeatSegnoType|endRepeatType|explicitClefVisibility|explicitCueClefVisibility|explicitKeySignatureVisibility|extendersOverRests|extraNatural|figuredBassAlterationDirection|figuredBassCenterContinuations|figuredBassFormatter|figuredBassPlusDirection|fingeringOrientations|firstClef|followVoice|fontSize|forbidBreak|forceClef|fretLabels|glissandoMap|gridInterval|handleNegativeFrets|harmonicAccidentals|harmonicDots|highStringOne|ignoreBarChecks|ignoreFiguredBassRest|ignoreMelismata|implicitBassFigures|implicitTimeSignatureVisibility|includeGraceNotes|instrumentCueName|instrumentEqualizer|instrumentName|instrumentTransposition|internalBarNumber|keepAliveInterfaces|keyAlterationOrder|keySignature|lyricMelismaAlignment|majorSevenSymbol|markFormatter|maximumFretStretch|measureLength|measurePosition|melismaBusyProperties|metronomeMarkFormatter|middleCClefPosition|middleCCuePosition|middleCOffset|middleCPosition|midiBalance|midiChannelMapping|midiChorusLevel|midiInstrument|midiMaximumVolume|midiMergeUnisons|midiMinimumVolume|midiPanPosition|midiReverbLevel|minimumFret|minimumPageTurnLength|minimumRepeatLengthForPageTurn|minorChordModifier|noChordSymbol|noteToFretFunction|ottavation|output|partCombineTextsOnNote|pedalSostenutoStrings|pedalSostenutoStyle|pedalSustainStrings|pedalSustainStyle|pedalUnaCordaStrings|pedalUnaCordaStyle|predefinedDiagramTable|printKeyCancellation|printOctaveNames|printPartCombineTexts|proportionalNotationDuration|rehearsalMark|repeatCommands|repeatCountVisibility|restCompletionBusy|restNumberThreshold|restrainOpenStrings|searchForVoice|segnoType|shapeNoteStyles|shortInstrumentName|shortVocalName|skipBars|skipTypesetting|slashChordSeparator|soloIIText|soloText|squashedPosition|staffLineLayoutFunction|stanza|startRepeatSegnoType|startRepeatType|stemLeftBeamCount|stemRightBeamCount|strictBeatBeaming|stringNumberOrientations|stringOneTopmost|stringTunings|strokeFingerOrientations|subdivideBeams|suggestAccidentals|supportNonIntegerFret|systemStartDelimiter|systemStartDelimiterHierarchy|tabStaffLineLayoutFunction|tablatureFormat|tempoHideNote|tempoWholesPerMinute|tieWaitForNote|timeSignatureFraction|timeSignatureSettings|timing|tonic|topLevelAlignment|trebleStaffProperties|tremoloFlags|tupletFullLength|tupletFullLengthNote|tupletSpannerDuration|useBassFigureExtenders|vocalName|voltaSpannerDuration|whichBar)\\b'¶
-
-
class
ly.lex.lilypond.
DecimalValue
[source]¶ Bases:
ly.lex.lilypond.Value
-
rx
= u'-?\\d+(\\.\\d+)?'¶
-
-
class
ly.lex.lilypond.
Dot
[source]¶ Bases:
ly.lex.lilypond.Duration
-
rx
= u'\\.'¶
-
-
class
ly.lex.lilypond.
DotChord
[source]¶ Bases:
ly.lex.lilypond.ChordItem
-
rx
= u'\\.'¶
-
-
class
ly.lex.lilypond.
DotPath
[source]¶ Bases:
ly.lex.lilypond.Delimiter
A dot in dotted path notation.
-
rx
= u'\\.'¶
-
-
class
ly.lex.lilypond.
DrumChordEnd
[source]¶ Bases:
ly.lex.lilypond.ChordEnd
-
class
ly.lex.lilypond.
DrumChordStart
[source]¶ Bases:
ly.lex.lilypond.ChordStart
-
class
ly.lex.lilypond.
DrumMode
[source]¶ Bases:
ly.lex.lilypond.InputMode
-
rx
= u'\\\\(drums|drummode)\\b'¶
-
-
class
ly.lex.lilypond.
DrumNote
[source]¶ Bases:
ly.lex.lilypond.MusicItem
-
rx
= u'[a-z]+(?![A-Za-z])'¶
-
-
class
ly.lex.lilypond.
Dynamic
[source]¶ Bases:
ly.lex._token.Token
-
rx
= u'\\\\[<!>]|\\\\(f{1,5}|p{1,5}|mf|mp|fp|spp?|sff?|sfz|rfz|cresc|decresc|dim|cr|decr)(?![A-Za-z])'¶
-
-
class
ly.lex.lilypond.
ErrorInChord
[source]¶ Bases:
ly.lex.lilypond.Error
-
rx
= u'[-_^][_.>|!+^-]|<<|>>|\\\\[\\\\\\]\\[\\(\\)()]|(\\\\(maxima|longa|breve)\\b|(1|2|4|8|16|32|64|128|256|512|1024|2048)(?!\\d))|\\*[\\t ]*\\d+(/\\d+)?'¶
-
-
class
ly.lex.lilypond.
ExpectBook
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectOpenBracket
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ExpectBookPart
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectOpenBracket
-
pattern
= <_sre.SRE_Pattern object>¶
-
replace
¶ alias of
ParseBookPart
-
-
class
ly.lex.lilypond.
ExpectChordMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectMusicList
-
pattern
= <_sre.SRE_Pattern object at 0x2c99c30>¶
-
replace
¶ alias of
ParseChordMode
-
-
class
ly.lex.lilypond.
ExpectContext
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectOpenBracket
-
pattern
= <_sre.SRE_Pattern object>¶
-
replace
¶ alias of
ParseContext
-
-
class
ly.lex.lilypond.
ExpectDrumMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectMusicList
-
pattern
= <_sre.SRE_Pattern object at 0x2c99c30>¶
-
replace
¶ alias of
ParseDrumMode
-
-
class
ly.lex.lilypond.
ExpectFigureMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectMusicList
-
pattern
= <_sre.SRE_Pattern object at 0x2c99c30>¶
-
replace
¶ alias of
ParseFigureMode
-
-
class
ly.lex.lilypond.
ExpectGrobProperty
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.GrobProperty'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x31a2370>¶
-
-
class
ly.lex.lilypond.
ExpectHeader
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectOpenBracket
-
pattern
= <_sre.SRE_Pattern object>¶
-
replace
¶ alias of
ParseHeader
-
-
class
ly.lex.lilypond.
ExpectLayout
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectOpenBracket
-
pattern
= <_sre.SRE_Pattern object>¶
-
replace
¶ alias of
ParseLayout
-
-
class
ly.lex.lilypond.
ExpectLyricMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectMusicList
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.OpenBracket'>, <class 'ly.lex.lilypond.OpenSimultaneous'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.Name'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x344f4d0>¶
-
replace
¶ alias of
ParseLyricMode
-
-
class
ly.lex.lilypond.
ExpectMidi
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectOpenBracket
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ExpectMusicList
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
,ly.lex.lilypond.ParseLilyPond
Waits for an OpenBracket or << and then replaces the parser with the class set in the replace attribute.
Subclass this to set the destination for the OpenBracket.
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.OpenBracket'>, <class 'ly.lex.lilypond.OpenSimultaneous'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2c99c30>¶
-
-
class
ly.lex.lilypond.
ExpectNoteMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectMusicList
-
replace
¶ alias of
ParseNoteMode
-
-
class
ly.lex.lilypond.
ExpectOpenBracket
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
,ly.lex.lilypond.ParseLilyPond
Waits for an OpenBracket and then replaces the parser with the class set in the replace attribute.
Subclass this to set the destination for the OpenBracket.
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.OpenBracket'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ExpectPaper
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectOpenBracket
-
replace
¶ alias of
ParsePaper
-
-
class
ly.lex.lilypond.
ExpectScore
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ExpectOpenBracket
-
replace
¶ alias of
ParseScore
-
-
class
ly.lex.lilypond.
ExpectTranslatorId
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.EqualSign'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
FigureAccidental
[source]¶ Bases:
ly.lex.lilypond.Figure
A figure accidental.
-
rx
= u'[-+!]+'¶
-
-
class
ly.lex.lilypond.
FigureBracket
[source]¶ Bases:
ly.lex.lilypond.Figure
-
rx
= u'[][]'¶
-
-
class
ly.lex.lilypond.
FigureEnd
[source]¶ Bases:
ly.lex.lilypond.Figure
,ly.lex._token.Leaver
-
rx
= u'>'¶
-
-
class
ly.lex.lilypond.
FigureMode
[source]¶ Bases:
ly.lex.lilypond.InputMode
-
rx
= u'\\\\(figures|figuremode)\\b'¶
-
-
class
ly.lex.lilypond.
FigureModifier
[source]¶ Bases:
ly.lex.lilypond.Figure
A figure modifier.
-
rx
= u'\\\\[\\\\!+]|/'¶
-
-
class
ly.lex.lilypond.
FigureStart
[source]¶ Bases:
ly.lex.lilypond.Figure
-
rx
= u'<'¶
-
-
class
ly.lex.lilypond.
FigureStep
[source]¶ Bases:
ly.lex.lilypond.Figure
A step figure number or the underscore.
-
rx
= u'_|\\d+'¶
-
-
class
ly.lex.lilypond.
Fingering
[source]¶ Bases:
ly.lex.lilypond.Articulation
,ly.lex._token.Leaver
-
rx
= u'\\d+'¶
-
-
class
ly.lex.lilypond.
Fraction
[source]¶ Bases:
ly.lex.lilypond.Value
-
rx
= u'\\d+/\\d+'¶
-
-
class
ly.lex.lilypond.
GrobName
[source]¶ Bases:
ly.lex._token.Token
-
rx
= u'\\b(Accidental|AccidentalCautionary|AccidentalPlacement|AccidentalSuggestion|Ambitus|AmbitusAccidental|AmbitusLine|AmbitusNoteHead|Arpeggio|BalloonTextItem|BarLine|BarNumber|BassFigure|BassFigureAlignment|BassFigureAlignmentPositioning|BassFigureBracket|BassFigureContinuation|BassFigureLine|Beam|BendAfter|BreakAlignGroup|BreakAlignment|BreathingSign|ChordName|Clef|ClefModifier|ClusterSpanner|ClusterSpannerBeacon|CombineTextScript|CueClef|CueEndClef|Custos|DotColumn|Dots|DoublePercentRepeat|DoublePercentRepeatCounter|DoubleRepeatSlash|DynamicLineSpanner|DynamicText|DynamicTextSpanner|Episema|Fingering|FingeringColumn|Flag|FootnoteItem|FootnoteSpanner|FretBoard|Glissando|GraceSpacing|GridLine|GridPoint|Hairpin|HorizontalBracket|InstrumentName|InstrumentSwitch|KeyCancellation|KeySignature|KievanLigature|LaissezVibrerTie|LaissezVibrerTieColumn|LedgerLineSpanner|LeftEdge|LigatureBracket|LyricExtender|LyricHyphen|LyricSpace|LyricText|MeasureCounter|MeasureGrouping|MelodyItem|MensuralLigature|MetronomeMark|MultiMeasureRest|MultiMeasureRestNumber|MultiMeasureRestText|NonMusicalPaperColumn|NoteCollision|NoteColumn|NoteHead|NoteName|NoteSpacing|OttavaBracket|PaperColumn|ParenthesesItem|PercentRepeat|PercentRepeatCounter|PhrasingSlur|PianoPedalBracket|RehearsalMark|RepeatSlash|RepeatTie|RepeatTieColumn|Rest|RestCollision|Script|ScriptColumn|ScriptRow|Slur|SostenutoPedal|SostenutoPedalLineSpanner|SpacingSpanner|SpanBar|SpanBarStub|StaffGrouper|StaffSpacing|StaffSymbol|StanzaNumber|Stem|StemStub|StemTremolo|StringNumber|StrokeFinger|SustainPedal|SustainPedalLineSpanner|System|SystemStartBar|SystemStartBrace|SystemStartBracket|SystemStartSquare|TabNoteHead|TextScript|TextSpanner|Tie|TieColumn|TimeSignature|TrillPitchAccidental|TrillPitchGroup|TrillPitchHead|TrillSpanner|TupletBracket|TupletNumber|UnaCordaPedal|UnaCordaPedalLineSpanner|VaticanaLigature|VerticalAlignment|VerticalAxisGroup|VoiceFollower|VoltaBracket|VoltaBracketSpanner)\\b'¶
-
-
class
ly.lex.lilypond.
GrobProperty
[source]¶ Bases:
ly.lex.lilypond.Variable
-
rx
= u'\\b([a-z]+|[XY])(-([a-z]+|[XY]))*(?![\\w])'¶
-
-
class
ly.lex.lilypond.
Header
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\header\\b'¶
-
-
class
ly.lex.lilypond.
HeaderVariable
[source]¶ Bases:
ly.lex.lilypond.Variable
A variable inside Header. Always follow this one by UserVariable.
-
class
ly.lex.lilypond.
Hide
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\hide\\b'¶
-
-
class
ly.lex.lilypond.
Identifier
[source]¶ Bases:
ly.lex._token.Token
A variable name, like
some-variable
.-
rx
= u'(?<![^\\W\\d])[^\\W\\d_]+([_-][^\\W\\d_]+)*(?![_-]?[^\\W\\d])'¶
-
-
class
ly.lex.lilypond.
IdentifierRef
[source]¶ Bases:
ly.lex._token.Token
A reference to an identifier, e.g.
\some-variable
.-
rx
= u'\\\\[^\\W\\d_]+([_-][^\\W\\d_]+)*(?![_-]?[^\\W\\d])'¶
-
-
class
ly.lex.lilypond.
InputMode
[source]¶ Bases:
ly.lex.lilypond.Command
-
class
ly.lex.lilypond.
IntegerValue
[source]¶ Bases:
ly.lex.lilypond.DecimalValue
-
rx
= u'\\d+'¶
-
-
class
ly.lex.lilypond.
KeySignatureMode
[source]¶ Bases:
ly.lex.lilypond.Command
-
rx
= u'\\\\(major|minor|ionian|dorian|phrygian|lydian|mixolydian|aeolian|locrian)(?![A-Za-z])'¶
-
-
class
ly.lex.lilypond.
Keyword
[source]¶ Bases:
ly.lex._token.Item
,ly.lex.lilypond.IdentifierRef
-
class
ly.lex.lilypond.
Layout
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\layout\\b'¶
-
-
class
ly.lex.lilypond.
LayoutContext
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\context\\b'¶
-
-
class
ly.lex.lilypond.
LayoutVariable
[source]¶ Bases:
ly.lex.lilypond.Variable
A variable inside Header. Always follow this one by UserVariable.
-
class
ly.lex.lilypond.
Length
[source]¶ Bases:
ly.lex.lilypond.Duration
-
rx
= u'(\\\\(maxima|longa|breve)\\b|(1|2|4|8|16|32|64|128|256|512|1024|2048)(?!\\d))'¶
-
-
class
ly.lex.lilypond.
LigatureEnd
[source]¶ Bases:
ly.lex.lilypond.Ligature
,ly.lex._token.MatchEnd
-
matchname
= u'ligature'¶
-
rx
= u'\\\\\\]'¶
-
-
class
ly.lex.lilypond.
LigatureStart
[source]¶ Bases:
ly.lex.lilypond.Ligature
,ly.lex._token.MatchStart
-
matchname
= u'ligature'¶
-
rx
= u'\\\\\\['¶
-
-
class
ly.lex.lilypond.
LineComment
[source]¶ Bases:
ly.lex.lilypond.Comment
,ly.lex._token.LineComment
-
rx
= u'%.*$'¶
-
-
class
ly.lex.lilypond.
LyricExtender
[source]¶ Bases:
ly.lex.lilypond.Lyric
-
rx
= u'__(?=($|[\\s\\\\]))'¶
-
-
class
ly.lex.lilypond.
LyricHyphen
[source]¶ Bases:
ly.lex.lilypond.Lyric
-
rx
= u'--(?=($|[\\s\\\\]))'¶
-
-
class
ly.lex.lilypond.
LyricMode
[source]¶ Bases:
ly.lex.lilypond.InputMode
-
rx
= u'\\\\(lyricmode|((old)?add)?lyrics|lyricsto)\\b'¶
-
-
class
ly.lex.lilypond.
LyricSkip
[source]¶ Bases:
ly.lex.lilypond.Lyric
-
rx
= u'_(?=($|[\\s\\\\]))'¶
-
-
class
ly.lex.lilypond.
LyricText
[source]¶ Bases:
ly.lex.lilypond.Lyric
-
rx
= u'[^\\\\\\s\\d\\"]+'¶
-
-
class
ly.lex.lilypond.
MarkupCommand
[source]¶ Bases:
ly.lex.lilypond.Markup
,ly.lex.lilypond.IdentifierRef
A markup command.
-
class
ly.lex.lilypond.
MarkupLines
[source]¶ Bases:
ly.lex.lilypond.Markup
-
rx
= u'\\\\markuplines(?![_-]?[^\\W\\d])'¶
-
-
class
ly.lex.lilypond.
MarkupList
[source]¶ Bases:
ly.lex.lilypond.Markup
-
rx
= u'\\\\markuplist(?![_-]?[^\\W\\d])'¶
-
-
class
ly.lex.lilypond.
MarkupScore
[source]¶ Bases:
ly.lex.lilypond.Markup
-
rx
= u'\\\\score\\b'¶
-
-
class
ly.lex.lilypond.
MarkupStart
[source]¶ Bases:
ly.lex.lilypond.Markup
,ly.lex.lilypond.Command
-
rx
= u'\\\\markup(?![_-]?[^\\W\\d])'¶
-
-
class
ly.lex.lilypond.
MarkupUserCommand
[source]¶ Bases:
ly.lex.lilypond.Markup
,ly.lex.lilypond.IdentifierRef
A user-defined markup (i.e. not in the words markupcommands list).
-
class
ly.lex.lilypond.
Midi
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\midi\\b'¶
-
-
class
ly.lex.lilypond.
MusicItem
[source]¶ Bases:
ly.lex._token.Token
A note, rest, spacer,
\skip
orq
.
-
class
ly.lex.lilypond.
Name
[source]¶ Bases:
ly.lex.lilypond.UserVariable
A variable name without prefix.
-
class
ly.lex.lilypond.
New
[source]¶ Bases:
ly.lex.lilypond.Translator
-
rx
= u'\\\\new\\b'¶
-
-
class
ly.lex.lilypond.
Note
[source]¶ Bases:
ly.lex.lilypond.MusicItem
-
rx
= u'[a-x]+(?![A-Za-z])'¶
-
-
class
ly.lex.lilypond.
NoteMode
[source]¶ Bases:
ly.lex.lilypond.InputMode
-
rx
= u'\\\\(notes|notemode)\\b'¶
-
-
class
ly.lex.lilypond.
Omit
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\omit\\b'¶
-
-
class
ly.lex.lilypond.
OpenBracket
[source]¶ Bases:
ly.lex.lilypond.Delimiter
,ly.lex._token.MatchStart
,ly.lex._token.Indent
An open bracket, does not enter different parser, subclass or reimplement Parser.update_state().
-
matchname
= u'bracket'¶
-
rx
= u'\\{'¶
-
-
class
ly.lex.lilypond.
OpenBracketMarkup
[source]¶ Bases:
ly.lex.lilypond.OpenBracket
-
class
ly.lex.lilypond.
OpenSimultaneous
[source]¶ Bases:
ly.lex.lilypond.Delimiter
,ly.lex._token.MatchStart
,ly.lex._token.Indent
An open double French quote, does not enter different parser, subclass or reimplement Parser.update_state().
-
matchname
= u'simultaneous'¶
-
rx
= u'<<'¶
-
-
class
ly.lex.lilypond.
Override
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\override\\b'¶
-
-
class
ly.lex.lilypond.
Paper
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\paper\\b'¶
-
-
class
ly.lex.lilypond.
PaperVariable
[source]¶ Bases:
ly.lex.lilypond.Variable
A variable inside Paper. Always follow this one by UserVariable.
-
class
ly.lex.lilypond.
ParseAccidentalStyle
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.AccidentalStyleSpecifier'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x348c850>¶
-
-
class
ly.lex.lilypond.
ParseAlterBroken
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.GrobProperty'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x31a2370>¶
-
-
class
ly.lex.lilypond.
ParseBlockComment
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
default
¶ alias of
BlockComment
-
items
= (<class 'ly.lex.lilypond.BlockCommentEnd'>,)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ParseBook
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses the expression after
\book {
, leaving at}
-
items
= (<class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.BookPart'>, <class 'ly.lex.lilypond.Score'>, <class 'ly.lex.lilypond.Paper'>, <class 'ly.lex.lilypond.Header'>, <class 'ly.lex.lilypond.Layout'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34a5bb0>¶
-
-
class
ly.lex.lilypond.
ParseBookPart
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses the expression after
\bookpart {
, leaving at}
-
items
= (<class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.Score'>, <class 'ly.lex.lilypond.Paper'>, <class 'ly.lex.lilypond.Header'>, <class 'ly.lex.lilypond.Layout'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34ae0b0>¶
-
-
class
ly.lex.lilypond.
ParseChord
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseMusic
LilyPond inside chords
< >
-
items
= (<class 'ly.lex.lilypond.ErrorInChord'>, <class 'ly.lex.lilypond.ChordEnd'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.Dynamic'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Spacer'>, <class 'ly.lex.lilypond.Q'>, <class 'ly.lex.lilypond.Rest'>, <class 'ly.lex.lilypond.Note'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.Octave'>, <class 'ly.lex.lilypond.OctaveCheck'>, <class 'ly.lex.lilypond.AccidentalCautionary'>, <class 'ly.lex.lilypond.AccidentalReminder'>, <class 'ly.lex.lilypond.PipeSymbol'>, <class 'ly.lex.lilypond.VoiceSeparator'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SequentialEnd'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.SimultaneousEnd'>, <class 'ly.lex.lilypond.ChordStart'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.SlurStart'>, <class 'ly.lex.lilypond.SlurEnd'>, <class 'ly.lex.lilypond.PhrasingSlurStart'>, <class 'ly.lex.lilypond.PhrasingSlurEnd'>, <class 'ly.lex.lilypond.Tie'>, <class 'ly.lex.lilypond.BeamStart'>, <class 'ly.lex.lilypond.BeamEnd'>, <class 'ly.lex.lilypond.LigatureStart'>, <class 'ly.lex.lilypond.LigatureEnd'>, <class 'ly.lex.lilypond.Direction'>, <class 'ly.lex.lilypond.StringNumber'>, <class 'ly.lex.lilypond.IntegerValue'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34c55f0>¶
-
-
class
ly.lex.lilypond.
ParseChordItems
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex.lilypond.ChordSeparator'>, <class 'ly.lex.lilypond.ChordModifier'>, <class 'ly.lex.lilypond.ChordStepNumber'>, <class 'ly.lex.lilypond.DotChord'>, <class 'ly.lex.lilypond.Note'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34b7010>¶
-
-
class
ly.lex.lilypond.
ParseChordMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseInputMode
,ly.lex.lilypond.ParseMusic
Parser for
\chords
and\chordmode
.-
items
= (<class 'ly.lex.lilypond.OpenBracket'>, <class 'ly.lex.lilypond.OpenSimultaneous'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.Dynamic'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Spacer'>, <class 'ly.lex.lilypond.Q'>, <class 'ly.lex.lilypond.Rest'>, <class 'ly.lex.lilypond.Note'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.Octave'>, <class 'ly.lex.lilypond.OctaveCheck'>, <class 'ly.lex.lilypond.AccidentalCautionary'>, <class 'ly.lex.lilypond.AccidentalReminder'>, <class 'ly.lex.lilypond.PipeSymbol'>, <class 'ly.lex.lilypond.VoiceSeparator'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SequentialEnd'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.SimultaneousEnd'>, <class 'ly.lex.lilypond.ChordStart'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.SlurStart'>, <class 'ly.lex.lilypond.SlurEnd'>, <class 'ly.lex.lilypond.PhrasingSlurStart'>, <class 'ly.lex.lilypond.PhrasingSlurEnd'>, <class 'ly.lex.lilypond.Tie'>, <class 'ly.lex.lilypond.BeamStart'>, <class 'ly.lex.lilypond.BeamEnd'>, <class 'ly.lex.lilypond.LigatureStart'>, <class 'ly.lex.lilypond.LigatureEnd'>, <class 'ly.lex.lilypond.Direction'>, <class 'ly.lex.lilypond.StringNumber'>, <class 'ly.lex.lilypond.IntegerValue'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>, <class 'ly.lex.lilypond.ChordSeparator'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34db8c0>¶
-
-
class
ly.lex.lilypond.
ParseClef
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
argcount
= 1¶
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.ClefSpecifier'>, <class 'ly.lex.lilypond.StringQuotedStart'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34ac6d0>¶
-
-
class
ly.lex.lilypond.
ParseContext
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses the expression after (
\layout {
)\context {
, leaving at}
-
items
= (<class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.BackSlashedContextName'>, <class 'ly.lex.lilypond.ContextProperty'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x30763a0>¶
-
-
class
ly.lex.lilypond.
ParseDecimalValue
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
Parses a decimal value without a # before it (if present).
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.DecimalValue'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x29946f0>¶
-
-
class
ly.lex.lilypond.
ParseDrumChord
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseMusic
LilyPond inside chords in drummode
< >
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.ErrorInChord'>, <class 'ly.lex.lilypond.DrumChordEnd'>, <class 'ly.lex.lilypond.Dynamic'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Spacer'>, <class 'ly.lex.lilypond.Q'>, <class 'ly.lex.lilypond.Rest'>, <class 'ly.lex.lilypond.DrumNote'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.PipeSymbol'>, <class 'ly.lex.lilypond.VoiceSeparator'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SequentialEnd'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.SimultaneousEnd'>, <class 'ly.lex.lilypond.ChordStart'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.SlurStart'>, <class 'ly.lex.lilypond.SlurEnd'>, <class 'ly.lex.lilypond.PhrasingSlurStart'>, <class 'ly.lex.lilypond.PhrasingSlurEnd'>, <class 'ly.lex.lilypond.Tie'>, <class 'ly.lex.lilypond.BeamStart'>, <class 'ly.lex.lilypond.BeamEnd'>, <class 'ly.lex.lilypond.LigatureStart'>, <class 'ly.lex.lilypond.LigatureEnd'>, <class 'ly.lex.lilypond.Direction'>, <class 'ly.lex.lilypond.StringNumber'>, <class 'ly.lex.lilypond.IntegerValue'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3495fb0>¶
-
-
class
ly.lex.lilypond.
ParseDrumMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseInputMode
,ly.lex.lilypond.ParseMusic
Parser for
\drums
and\drummode
.-
items
= (<class 'ly.lex.lilypond.OpenBracket'>, <class 'ly.lex.lilypond.OpenSimultaneous'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.Dynamic'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Spacer'>, <class 'ly.lex.lilypond.Q'>, <class 'ly.lex.lilypond.Rest'>, <class 'ly.lex.lilypond.DrumNote'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.PipeSymbol'>, <class 'ly.lex.lilypond.VoiceSeparator'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SequentialEnd'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.SimultaneousEnd'>, <class 'ly.lex.lilypond.DrumChordStart'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.SlurStart'>, <class 'ly.lex.lilypond.SlurEnd'>, <class 'ly.lex.lilypond.PhrasingSlurStart'>, <class 'ly.lex.lilypond.PhrasingSlurEnd'>, <class 'ly.lex.lilypond.Tie'>, <class 'ly.lex.lilypond.BeamStart'>, <class 'ly.lex.lilypond.BeamEnd'>, <class 'ly.lex.lilypond.LigatureStart'>, <class 'ly.lex.lilypond.LigatureEnd'>, <class 'ly.lex.lilypond.Direction'>, <class 'ly.lex.lilypond.StringNumber'>, <class 'ly.lex.lilypond.IntegerValue'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3081fe0>¶
-
-
class
ly.lex.lilypond.
ParseDuration
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.Dot'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ParseDurationScaling
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseDuration
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.Scaling'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ParseFigure
(argcount=None)[source]¶ Bases:
ly.lex.Parser
Parse inside
< >
in figure mode.-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.FigureEnd'>, <class 'ly.lex.lilypond.FigureBracket'>, <class 'ly.lex.lilypond.FigureStep'>, <class 'ly.lex.lilypond.FigureAccidental'>, <class 'ly.lex.lilypond.FigureModifier'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x32fb0f0>¶
-
-
class
ly.lex.lilypond.
ParseFigureMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseInputMode
,ly.lex.lilypond.ParseMusic
Parser for
\figures
and\figuremode
.-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.CloseSimultaneous'>, <class 'ly.lex.lilypond.OpenBracket'>, <class 'ly.lex.lilypond.OpenSimultaneous'>, <class 'ly.lex.lilypond.PipeSymbol'>, <class 'ly.lex.lilypond.FigureStart'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Spacer'>, <class 'ly.lex.lilypond.Rest'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x33652a0>¶
-
-
class
ly.lex.lilypond.
ParseGlobal
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses LilyPond from the toplevel of a file.
-
items
= (<class 'ly.lex.lilypond.Book'>, <class 'ly.lex.lilypond.BookPart'>, <class 'ly.lex.lilypond.Score'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.Paper'>, <class 'ly.lex.lilypond.Header'>, <class 'ly.lex.lilypond.Layout'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>, <class 'ly.lex.lilypond.Name'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.DecimalValue'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2e78030>¶
-
-
class
ly.lex.lilypond.
ParseGlobalAssignment
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
,ly.lex.lilypond.ParseLilyPond
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Spacer'>, <class 'ly.lex.lilypond.Q'>, <class 'ly.lex.lilypond.Rest'>, <class 'ly.lex.lilypond.Note'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.DecimalValue'>, <class 'ly.lex.lilypond.Direction'>, <class 'ly.lex.lilypond.StringNumber'>, <class 'ly.lex.lilypond.Dynamic'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x309e520>¶
-
-
class
ly.lex.lilypond.
ParseGrobPropertyPath
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.DotPath'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ParseHeader
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses the expression after
\header {
, leaving at}
-
items
= (<class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.HeaderVariable'>, <class 'ly.lex.lilypond.UserVariable'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x31ba5a0>¶
-
-
class
ly.lex.lilypond.
ParseHideOmit
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.GrobName'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x302ceb0>¶
-
-
class
ly.lex.lilypond.
ParseInputMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Base class for parser for mode-changing music commands.
-
class
ly.lex.lilypond.
ParseLayout
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses the expression after
\layout {
, leaving at}
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.LayoutContext'>, <class 'ly.lex.lilypond.LayoutVariable'>, <class 'ly.lex.lilypond.UserVariable'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.DecimalValue'>, <class 'ly.lex.lilypond.Unit'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34e27d0>¶
-
-
class
ly.lex.lilypond.
ParseLilyPond
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
mode
= u'lilypond'¶
-
-
class
ly.lex.lilypond.
ParseLyricMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseInputMode
Parser for
\lyrics
,\lyricmode
,\addlyrics
, etc.-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.CloseSimultaneous'>, <class 'ly.lex.lilypond.OpenBracket'>, <class 'ly.lex.lilypond.OpenSimultaneous'>, <class 'ly.lex.lilypond.PipeSymbol'>, <class 'ly.lex.lilypond.LyricHyphen'>, <class 'ly.lex.lilypond.LyricExtender'>, <class 'ly.lex.lilypond.LyricSkip'>, <class 'ly.lex.lilypond.LyricText'>, <class 'ly.lex.lilypond.Dynamic'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2e65dd0>¶
-
-
class
ly.lex.lilypond.
ParseMarkup
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.lilypond.MarkupScore'>, <class 'ly.lex.lilypond.MarkupCommand'>, <class 'ly.lex.lilypond.MarkupUserCommand'>, <class 'ly.lex.lilypond.OpenBracketMarkup'>, <class 'ly.lex.lilypond.CloseBracketMarkup'>, <class 'ly.lex.lilypond.MarkupWord'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2d30530>¶
-
-
class
ly.lex.lilypond.
ParseMidi
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses the expression after
\midi {
, leaving at}
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.LayoutContext'>, <class 'ly.lex.lilypond.LayoutVariable'>, <class 'ly.lex.lilypond.UserVariable'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.DecimalValue'>, <class 'ly.lex.lilypond.Unit'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34e27d0>¶
-
-
class
ly.lex.lilypond.
ParseMusic
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses LilyPond music expressions.
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.Dynamic'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Spacer'>, <class 'ly.lex.lilypond.Q'>, <class 'ly.lex.lilypond.Rest'>, <class 'ly.lex.lilypond.Note'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.Octave'>, <class 'ly.lex.lilypond.OctaveCheck'>, <class 'ly.lex.lilypond.AccidentalCautionary'>, <class 'ly.lex.lilypond.AccidentalReminder'>, <class 'ly.lex.lilypond.PipeSymbol'>, <class 'ly.lex.lilypond.VoiceSeparator'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SequentialEnd'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.SimultaneousEnd'>, <class 'ly.lex.lilypond.ChordStart'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.SlurStart'>, <class 'ly.lex.lilypond.SlurEnd'>, <class 'ly.lex.lilypond.PhrasingSlurStart'>, <class 'ly.lex.lilypond.PhrasingSlurEnd'>, <class 'ly.lex.lilypond.Tie'>, <class 'ly.lex.lilypond.BeamStart'>, <class 'ly.lex.lilypond.BeamEnd'>, <class 'ly.lex.lilypond.LigatureStart'>, <class 'ly.lex.lilypond.LigatureEnd'>, <class 'ly.lex.lilypond.Direction'>, <class 'ly.lex.lilypond.StringNumber'>, <class 'ly.lex.lilypond.IntegerValue'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>, <class 'ly.lex.lilypond.TremoloColon'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x30b4c50>¶
-
-
class
ly.lex.lilypond.
ParseNoteMode
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseMusic
Parser for
\notes
and\notemode
. Same as Music itself.
-
class
ly.lex.lilypond.
ParseOverride
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
-
argcount
= 0¶
-
items
= (<class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.GrobProperty'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x30511b0>¶
-
-
class
ly.lex.lilypond.
ParsePaper
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses the expression after
\paper {
, leaving at}
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.PaperVariable'>, <class 'ly.lex.lilypond.UserVariable'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.DecimalValue'>, <class 'ly.lex.lilypond.Unit'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2f01e00>¶
-
-
class
ly.lex.lilypond.
ParsePitchCommand
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
argcount
= 1¶
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.Note'>, <class 'ly.lex.lilypond.Octave'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x28587c0>¶
-
-
class
ly.lex.lilypond.
ParseRepeat
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.RepeatSpecifier'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.RepeatCount'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2c773f0>¶
-
-
class
ly.lex.lilypond.
ParseRevert
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
parse the arguments of
\revert
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.GrobProperty'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3107390>¶
-
-
class
ly.lex.lilypond.
ParseScore
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses the expression after
\score {
, leaving at}
-
items
= (<class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.Header'>, <class 'ly.lex.lilypond.Layout'>, <class 'ly.lex.lilypond.Midi'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2f17410>¶
-
-
class
ly.lex.lilypond.
ParseScriptAbbreviationOrFingering
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
argcount
= 1¶
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.ScriptAbbreviation'>, <class 'ly.lex.lilypond.Fingering'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ParseSet
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
-
argcount
= 0¶
-
items
= (<class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.ContextProperty'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.Name'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34f9a80>¶
-
-
class
ly.lex.lilypond.
ParseString
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.lilypond.StringQuotedEnd'>, <class 'ly.lex.lilypond.StringQuoteEscape'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ParseTempo
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.EqualSign'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2ea4380>¶
-
-
class
ly.lex.lilypond.
ParseTempoAfterEqualSign
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.IntegerValue'>, <class 'ly.lex.lilypond.TempoSeparator'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ParseTranslator
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.Name'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2f0f690>¶
-
-
class
ly.lex.lilypond.
ParseTranslatorId
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
argcount
= 1¶
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.Name'>, <class 'ly.lex.lilypond.StringQuotedStart'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x2d9df40>¶
-
-
class
ly.lex.lilypond.
ParseTremolo
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex.lilypond.TremoloDuration'>,)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.lilypond.
ParseTweak
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.GrobProperty'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x30644d0>¶
-
-
class
ly.lex.lilypond.
ParseTweakGrobProperty
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.DecimalValue'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3391100>¶
-
-
class
ly.lex.lilypond.
ParseUnset
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.ContextProperty'>, <class 'ly.lex.lilypond.Name'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x34ecaa0>¶
-
-
class
ly.lex.lilypond.
ParseWith
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseLilyPond
Parses the expression after
\with {
, leaving at}
-
items
= (<class 'ly.lex.lilypond.CloseBracket'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.ContextProperty'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3523650>¶
-
-
class
ly.lex.lilypond.
Partial
[source]¶ Bases:
ly.lex.lilypond.Command
-
rx
= u'\\\\partial\\b'¶
-
-
class
ly.lex.lilypond.
PhrasingSlurEnd
[source]¶ Bases:
ly.lex.lilypond.SlurEnd
-
matchname
= u'phrasingslur'¶
-
rx
= u'\\\\\\)'¶
-
-
class
ly.lex.lilypond.
PhrasingSlurStart
[source]¶ Bases:
ly.lex.lilypond.SlurStart
-
matchname
= u'phrasingslur'¶
-
rx
= u'\\\\\\('¶
-
-
class
ly.lex.lilypond.
PipeSymbol
[source]¶ Bases:
ly.lex.lilypond.Delimiter
-
rx
= u'\\|'¶
-
-
class
ly.lex.lilypond.
PitchCommand
[source]¶ Bases:
ly.lex.lilypond.Command
-
rx
= u'\\\\(relative|transpose|transposition|key|octaveCheck)\\b'¶
-
-
class
ly.lex.lilypond.
Q
[source]¶ Bases:
ly.lex.lilypond.MusicItem
-
rx
= u'q(?![A-Za-z])'¶
-
-
class
ly.lex.lilypond.
Repeat
[source]¶ Bases:
ly.lex.lilypond.Command
-
rx
= u'\\\\repeat(?![A-Za-z])'¶
-
-
class
ly.lex.lilypond.
RepeatCount
[source]¶ Bases:
ly.lex.lilypond.IntegerValue
,ly.lex._token.Leaver
-
class
ly.lex.lilypond.
RepeatSpecifier
[source]¶ Bases:
ly.lex.lilypond.Specifier
-
rx
= u'\\b(unfold|percent|volta|tremolo)(?![A-Za-z])'¶
-
-
class
ly.lex.lilypond.
Rest
[source]¶ Bases:
ly.lex.lilypond.MusicItem
-
rx
= u'[Rr](?![A-Za-z])'¶
-
-
class
ly.lex.lilypond.
Revert
[source]¶ Bases:
ly.lex.lilypond.Override
-
rx
= u'\\\\revert\\b'¶
-
-
class
ly.lex.lilypond.
Scaling
[source]¶ Bases:
ly.lex.lilypond.Duration
-
rx
= u'\\*[\\t ]*\\d+(/\\d+)?'¶
-
-
class
ly.lex.lilypond.
Score
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\score\\b'¶
-
-
class
ly.lex.lilypond.
ScriptAbbreviation
[source]¶ Bases:
ly.lex.lilypond.Articulation
,ly.lex._token.Leaver
-
rx
= u'[+|!>._^-]'¶
-
-
class
ly.lex.lilypond.
SequentialEnd
[source]¶ Bases:
ly.lex.lilypond.CloseBracket
-
class
ly.lex.lilypond.
SequentialStart
[source]¶ Bases:
ly.lex.lilypond.OpenBracket
-
class
ly.lex.lilypond.
Set
[source]¶ Bases:
ly.lex.lilypond.Override
-
rx
= u'\\\\set\\b'¶
-
-
class
ly.lex.lilypond.
SimultaneousOrSequentialCommand
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\(simultaneous|sequential)\\b'¶
-
-
class
ly.lex.lilypond.
Skip
[source]¶ Bases:
ly.lex.lilypond.MusicItem
-
rx
= u'\\\\skip(?![_-]?[^\\W\\d])'¶
-
-
class
ly.lex.lilypond.
SlurEnd
[source]¶ Bases:
ly.lex.lilypond.Slur
,ly.lex._token.MatchEnd
-
matchname
= u'slur'¶
-
rx
= u'\\)'¶
-
-
class
ly.lex.lilypond.
SlurStart
[source]¶ Bases:
ly.lex.lilypond.Slur
,ly.lex._token.MatchStart
-
matchname
= u'slur'¶
-
rx
= u'\\('¶
-
-
class
ly.lex.lilypond.
Spacer
[source]¶ Bases:
ly.lex.lilypond.MusicItem
-
rx
= u's(?![A-Za-z])'¶
-
-
class
ly.lex.lilypond.
StringNumber
[source]¶ Bases:
ly.lex.lilypond.Articulation
-
rx
= u'\\\\\\d+'¶
-
-
class
ly.lex.lilypond.
StringQuoteEscape
[source]¶ Bases:
ly.lex._token.Character
-
rx
= u'\\\\[\\\\"]'¶
-
-
class
ly.lex.lilypond.
StringQuotedEnd
[source]¶ Bases:
ly.lex.lilypond.String
,ly.lex._token.StringEnd
-
rx
= u'"'¶
-
-
class
ly.lex.lilypond.
StringQuotedStart
[source]¶ Bases:
ly.lex.lilypond.String
,ly.lex._token.StringStart
-
rx
= u'"'¶
-
-
class
ly.lex.lilypond.
Tempo
[source]¶ Bases:
ly.lex.lilypond.Command
-
rx
= u'\\\\tempo\\b'¶
-
-
class
ly.lex.lilypond.
TempoSeparator
[source]¶ Bases:
ly.lex.lilypond.Delimiter
-
rx
= u'[-~](?=\\s*\\d)'¶
-
-
class
ly.lex.lilypond.
Tie
[source]¶ Bases:
ly.lex.lilypond.Slur
-
rx
= u'~'¶
-
-
class
ly.lex.lilypond.
Translator
[source]¶ Bases:
ly.lex.lilypond.Command
-
class
ly.lex.lilypond.
TremoloColon
[source]¶ Bases:
ly.lex.lilypond.Tremolo
-
rx
= u':'¶
-
-
class
ly.lex.lilypond.
TremoloDuration
[source]¶ Bases:
ly.lex.lilypond.Tremolo
,ly.lex._token.Leaver
-
rx
= u'\\b(8|16|32|64|128|256|512|1024|2048)(?!\\d)'¶
-
-
class
ly.lex.lilypond.
Tweak
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\tweak\\b'¶
-
-
class
ly.lex.lilypond.
Unit
[source]¶ Bases:
ly.lex.lilypond.Command
-
rx
= u'\\\\(mm|cm|in|pt)\\b'¶
-
-
class
ly.lex.lilypond.
Unset
[source]¶ Bases:
ly.lex.lilypond.Keyword
-
rx
= u'\\\\unset\\b'¶
-
-
class
ly.lex.lilypond.
UserVariable
[source]¶ Bases:
ly.lex.lilypond.Identifier
-
class
ly.lex.lilypond.
Variable
[source]¶ Bases:
ly.lex.lilypond.Identifier
-
class
ly.lex.lilypond.
VoiceSeparator
[source]¶ Bases:
ly.lex.lilypond.Delimiter
-
rx
= u'\\\\\\\\'¶
-
ly.lex.scheme module¶
Parses and tokenizes Scheme input.
-
class
ly.lex.scheme.
BlockComment
[source]¶ Bases:
ly.lex.scheme.Comment
,ly.lex._token.BlockComment
-
class
ly.lex.scheme.
BlockCommentEnd
[source]¶ Bases:
ly.lex.scheme.Comment
,ly.lex._token.BlockCommentEnd
,ly.lex._token.Leaver
-
rx
= u'!#'¶
-
-
class
ly.lex.scheme.
BlockCommentStart
[source]¶ Bases:
ly.lex.scheme.Comment
,ly.lex._token.BlockCommentStart
-
rx
= u'#!'¶
-
-
class
ly.lex.scheme.
Bool
[source]¶ Bases:
ly.lex.scheme.Scheme
,ly.lex._token.Item
-
rx
= u'#[tf]\\b'¶
-
-
class
ly.lex.scheme.
Char
[source]¶ Bases:
ly.lex.scheme.Scheme
,ly.lex._token.Item
-
rx
= u'#\\\\([a-z]+|.)'¶
-
-
class
ly.lex.scheme.
CloseParen
[source]¶ Bases:
ly.lex.scheme.Scheme
,ly.lex._token.MatchEnd
,ly.lex._token.Dedent
-
matchname
= u'schemeparen'¶
-
rx
= u'\\)'¶
-
-
class
ly.lex.scheme.
Constant
[source]¶ Bases:
ly.lex.scheme.Word
-
class
ly.lex.scheme.
Dot
[source]¶ Bases:
ly.lex.scheme.Scheme
-
rx
= u'\\.(?!\\S)'¶
-
-
class
ly.lex.scheme.
Float
[source]¶ Bases:
ly.lex.scheme.Number
-
rx
= u'-?((\\d+(\\.\\d*)|\\.\\d+)(E\\d+)?)(?=$|[)\\s])'¶
-
-
class
ly.lex.scheme.
Fraction
[source]¶ Bases:
ly.lex.scheme.Number
-
rx
= u'-?\\d+/\\d+(?=$|[)\\s])'¶
-
-
class
ly.lex.scheme.
Function
[source]¶ Bases:
ly.lex.scheme.Word
-
class
ly.lex.scheme.
Keyword
[source]¶ Bases:
ly.lex.scheme.Word
-
class
ly.lex.scheme.
LilyPondEnd
[source]¶ Bases:
ly.lex.scheme.LilyPond
,ly.lex._token.Leaver
,ly.lex._token.MatchEnd
,ly.lex._token.Dedent
-
matchname
= u'schemelily'¶
-
rx
= u'#}'¶
-
-
class
ly.lex.scheme.
LilyPondStart
[source]¶ Bases:
ly.lex.scheme.LilyPond
,ly.lex._token.MatchStart
,ly.lex._token.Indent
-
matchname
= u'schemelily'¶
-
rx
= u'#{'¶
-
-
class
ly.lex.scheme.
LineComment
[source]¶ Bases:
ly.lex.scheme.Comment
,ly.lex._token.LineComment
-
rx
= u';.*$'¶
-
-
class
ly.lex.scheme.
Number
[source]¶ Bases:
ly.lex._token.Item
,ly.lex._token.Numeric
-
rx
= u'(-?\\d+|#(b[0-1]+|o[0-7]+|x[0-9a-fA-F]+)|[-+]inf.0|[-+]?nan.0)(?=$|[)\\s])'¶
-
-
class
ly.lex.scheme.
OpenParen
[source]¶ Bases:
ly.lex.scheme.Scheme
,ly.lex._token.MatchStart
,ly.lex._token.Indent
-
matchname
= u'schemeparen'¶
-
rx
= u'\\('¶
-
-
class
ly.lex.scheme.
ParseBlockComment
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
default
¶ alias of
BlockComment
-
items
= (<class 'ly.lex.scheme.BlockCommentEnd'>,)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.scheme.
ParseLilyPond
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseMusic
-
items
= (<class 'ly.lex.scheme.LilyPondEnd'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.Dynamic'>, <class 'ly.lex.lilypond.Skip'>, <class 'ly.lex.lilypond.Spacer'>, <class 'ly.lex.lilypond.Q'>, <class 'ly.lex.lilypond.Rest'>, <class 'ly.lex.lilypond.Note'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.Length'>, <class 'ly.lex.lilypond.Octave'>, <class 'ly.lex.lilypond.OctaveCheck'>, <class 'ly.lex.lilypond.AccidentalCautionary'>, <class 'ly.lex.lilypond.AccidentalReminder'>, <class 'ly.lex.lilypond.PipeSymbol'>, <class 'ly.lex.lilypond.VoiceSeparator'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SequentialEnd'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.SimultaneousEnd'>, <class 'ly.lex.lilypond.ChordStart'>, <class 'ly.lex.lilypond.ContextName'>, <class 'ly.lex.lilypond.GrobName'>, <class 'ly.lex.lilypond.SlurStart'>, <class 'ly.lex.lilypond.SlurEnd'>, <class 'ly.lex.lilypond.PhrasingSlurStart'>, <class 'ly.lex.lilypond.PhrasingSlurEnd'>, <class 'ly.lex.lilypond.Tie'>, <class 'ly.lex.lilypond.BeamStart'>, <class 'ly.lex.lilypond.BeamEnd'>, <class 'ly.lex.lilypond.LigatureStart'>, <class 'ly.lex.lilypond.LigatureEnd'>, <class 'ly.lex.lilypond.Direction'>, <class 'ly.lex.lilypond.StringNumber'>, <class 'ly.lex.lilypond.IntegerValue'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>, <class 'ly.lex.lilypond.TremoloColon'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3ace850>¶
-
-
class
ly.lex.scheme.
ParseScheme
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex._token.Space'>, <class 'ly.lex.scheme.OpenParen'>, <class 'ly.lex.scheme.CloseParen'>, <class 'ly.lex.scheme.LineComment'>, <class 'ly.lex.scheme.BlockCommentStart'>, <class 'ly.lex.scheme.LilyPondStart'>, <class 'ly.lex.scheme.VectorStart'>, <class 'ly.lex.scheme.Dot'>, <class 'ly.lex.scheme.Bool'>, <class 'ly.lex.scheme.Char'>, <class 'ly.lex.scheme.Quote'>, <class 'ly.lex.scheme.Fraction'>, <class 'ly.lex.scheme.Float'>, <class 'ly.lex.scheme.Number'>, <class 'ly.lex.scheme.Constant'>, <class 'ly.lex.scheme.Keyword'>, <class 'ly.lex.scheme.Function'>, <class 'ly.lex.scheme.Variable'>, <class 'ly.lex.scheme.Word'>, <class 'ly.lex.scheme.StringQuotedStart'>)¶
-
mode
= u'scheme'¶
-
pattern
= <_sre.SRE_Pattern object at 0x35111c0>¶
-
-
class
ly.lex.scheme.
ParseString
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.scheme.StringQuotedEnd'>, <class 'ly.lex.scheme.StringQuoteEscape'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.scheme.
Quote
[source]¶ Bases:
ly.lex.scheme.Scheme
-
rx
= u"['`,]"¶
-
-
class
ly.lex.scheme.
StringQuotedEnd
[source]¶ Bases:
ly.lex.scheme.String
,ly.lex._token.StringEnd
-
rx
= u'"'¶
-
-
class
ly.lex.scheme.
StringQuotedStart
[source]¶ Bases:
ly.lex.scheme.String
,ly.lex._token.StringStart
-
rx
= u'"'¶
-
-
class
ly.lex.scheme.
Variable
[source]¶ Bases:
ly.lex.scheme.Word
-
class
ly.lex.scheme.
VectorStart
[source]¶ Bases:
ly.lex.scheme.OpenParen
-
rx
= u'#\\('¶
-
-
class
ly.lex.scheme.
Word
[source]¶ Bases:
ly.lex.scheme.Scheme
,ly.lex._token.Item
-
rx
= u'[^()"{}\\s]+'¶
-
ly.lex.texinfo module¶
Parses and tokenizes Texinfo input, recognizing LilyPond in Texinfo.
-
class
ly.lex.texinfo.
Accent
[source]¶ Bases:
ly.lex.texinfo.EscapeChar
-
rx
= u'@[\'"\',=^`~](\\{[a-zA-Z]\\}|[a-zA-Z]\\b)'¶
-
-
class
ly.lex.texinfo.
BlockCommentEnd
[source]¶ Bases:
ly.lex.texinfo.Comment
,ly.lex._token.Leaver
,ly.lex._token.BlockCommentEnd
-
rx
= u'@end\\s+ignore\\b'¶
-
-
class
ly.lex.texinfo.
BlockCommentStart
[source]¶ Bases:
ly.lex.texinfo.Comment
,ly.lex._token.BlockCommentStart
-
rx
= u'@ignore\\b'¶
-
-
class
ly.lex.texinfo.
BlockEnd
[source]¶ Bases:
ly.lex.texinfo.Block
,ly.lex._token.Leaver
-
rx
= u'\\}'¶
-
-
class
ly.lex.texinfo.
BlockStart
[source]¶ Bases:
ly.lex.texinfo.Block
-
rx
= u'@[a-zA-Z]+\\{'¶
-
-
class
ly.lex.texinfo.
LilyPondAttrEnd
[source]¶ Bases:
ly.lex.texinfo.Attribute
,ly.lex._token.Leaver
-
rx
= u'\\]'¶
-
-
class
ly.lex.texinfo.
LilyPondAttrStart
[source]¶ Bases:
ly.lex.texinfo.Attribute
-
rx
= u'\\['¶
-
-
class
ly.lex.texinfo.
LilyPondBlockEnd
[source]¶ Bases:
ly.lex.texinfo.Block
,ly.lex._token.Leaver
-
rx
= u'\\}'¶
-
-
class
ly.lex.texinfo.
LilyPondBlockStart
[source]¶ Bases:
ly.lex.texinfo.Block
-
rx
= u'@lilypond(?=(\\[[a-zA-Z,=0-9\\\\\\s]+\\])?\\{)'¶
-
-
class
ly.lex.texinfo.
LilyPondBlockStartBrace
[source]¶ Bases:
ly.lex.texinfo.Block
-
rx
= u'\\{'¶
-
-
class
ly.lex.texinfo.
LilyPondEnvEnd
[source]¶ Bases:
ly.lex.texinfo.Keyword
,ly.lex._token.Leaver
-
rx
= u'@end\\s+lilypond\\b'¶
-
-
class
ly.lex.texinfo.
LilyPondEnvStart
[source]¶ Bases:
ly.lex.texinfo.Keyword
-
rx
= u'@lilypond\\b'¶
-
-
class
ly.lex.texinfo.
LilyPondFileStart
[source]¶ Bases:
ly.lex.texinfo.Block
-
rx
= u'@lilypondfile\\b'¶
-
-
class
ly.lex.texinfo.
LilyPondFileStartBrace
[source]¶ Bases:
ly.lex.texinfo.Block
-
rx
= u'\\{'¶
-
-
class
ly.lex.texinfo.
LineComment
[source]¶ Bases:
ly.lex.texinfo.Comment
,ly.lex._token.LineComment
-
rx
= u'@c\\b.*$'¶
-
-
class
ly.lex.texinfo.
ParseBlock
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.texinfo.BlockEnd'>, <class 'ly.lex.texinfo.Accent'>, <class 'ly.lex.texinfo.EscapeChar'>, <class 'ly.lex.texinfo.BlockStart'>, <class 'ly.lex.texinfo.Keyword'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x272a0c0>¶
-
-
class
ly.lex.texinfo.
ParseComment
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.texinfo.BlockCommentEnd'>,)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.texinfo.
ParseLilyPondAttr
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.texinfo.LilyPondAttrEnd'>,)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.texinfo.
ParseLilyPondBlock
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseGlobal
-
items
= (<class 'ly.lex.texinfo.LilyPondBlockEnd'>, <class 'ly.lex.lilypond.Book'>, <class 'ly.lex.lilypond.BookPart'>, <class 'ly.lex.lilypond.Score'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.Paper'>, <class 'ly.lex.lilypond.Header'>, <class 'ly.lex.lilypond.Layout'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>, <class 'ly.lex.lilypond.Name'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.DecimalValue'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3bbafd0>¶
-
-
class
ly.lex.texinfo.
ParseLilyPondBlockAttr
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.texinfo.LilyPondAttrStart'>, <class 'ly.lex.texinfo.LilyPondBlockStartBrace'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.texinfo.
ParseLilyPondEnv
(argcount=None)[source]¶ Bases:
ly.lex.lilypond.ParseGlobal
-
items
= (<class 'ly.lex.texinfo.LilyPondEnvEnd'>, <class 'ly.lex.lilypond.Book'>, <class 'ly.lex.lilypond.BookPart'>, <class 'ly.lex.lilypond.Score'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.Paper'>, <class 'ly.lex.lilypond.Header'>, <class 'ly.lex.lilypond.Layout'>, <class 'ly.lex._token.Space'>, <class 'ly.lex.lilypond.BlockCommentStart'>, <class 'ly.lex.lilypond.LineComment'>, <class 'ly.lex.lilypond.SchemeStart'>, <class 'ly.lex.lilypond.StringQuotedStart'>, <class 'ly.lex.lilypond.SequentialStart'>, <class 'ly.lex.lilypond.SimultaneousStart'>, <class 'ly.lex.lilypond.Repeat'>, <class 'ly.lex.lilypond.PitchCommand'>, <class 'ly.lex.lilypond.Override'>, <class 'ly.lex.lilypond.Revert'>, <class 'ly.lex.lilypond.Set'>, <class 'ly.lex.lilypond.Unset'>, <class 'ly.lex.lilypond.Hide'>, <class 'ly.lex.lilypond.Omit'>, <class 'ly.lex.lilypond.Tweak'>, <class 'ly.lex.lilypond.New'>, <class 'ly.lex.lilypond.Context'>, <class 'ly.lex.lilypond.Change'>, <class 'ly.lex.lilypond.With'>, <class 'ly.lex.lilypond.Clef'>, <class 'ly.lex.lilypond.Tempo'>, <class 'ly.lex.lilypond.Partial'>, <class 'ly.lex.lilypond.KeySignatureMode'>, <class 'ly.lex.lilypond.AccidentalStyle'>, <class 'ly.lex.lilypond.AlterBroken'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.ChordMode'>, <class 'ly.lex.lilypond.DrumMode'>, <class 'ly.lex.lilypond.FigureMode'>, <class 'ly.lex.lilypond.LyricMode'>, <class 'ly.lex.lilypond.NoteMode'>, <class 'ly.lex.lilypond.MarkupStart'>, <class 'ly.lex.lilypond.MarkupLines'>, <class 'ly.lex.lilypond.MarkupList'>, <class 'ly.lex.lilypond.ArticulationCommand'>, <class 'ly.lex.lilypond.Keyword'>, <class 'ly.lex.lilypond.Command'>, <class 'ly.lex.lilypond.SimultaneousOrSequentialCommand'>, <class 'ly.lex.lilypond.UserCommand'>, <class 'ly.lex.lilypond.Name'>, <class 'ly.lex.lilypond.DotPath'>, <class 'ly.lex.lilypond.EqualSign'>, <class 'ly.lex.lilypond.Fraction'>, <class 'ly.lex.lilypond.DecimalValue'>)¶
-
pattern
= <_sre.SRE_Pattern object at 0x3b397a0>¶
-
-
class
ly.lex.texinfo.
ParseLilyPondEnvAttr
(argcount=None)[source]¶ Bases:
ly.lex.FallthroughParser
-
items
= (<class 'ly.lex.texinfo.LilyPondAttrStart'>,)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.texinfo.
ParseLilyPondFile
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.texinfo.LilyPondAttrStart'>, <class 'ly.lex.texinfo.LilyPondFileStartBrace'>)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.texinfo.
ParseTexinfo
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.texinfo.LineComment'>, <class 'ly.lex.texinfo.BlockCommentStart'>, <class 'ly.lex.texinfo.Accent'>, <class 'ly.lex.texinfo.EscapeChar'>, <class 'ly.lex.texinfo.LilyPondBlockStart'>, <class 'ly.lex.texinfo.LilyPondEnvStart'>, <class 'ly.lex.texinfo.LilyPondFileStart'>, <class 'ly.lex.texinfo.BlockStart'>, <class 'ly.lex.texinfo.VerbatimStart'>, <class 'ly.lex.texinfo.Keyword'>)¶
-
mode
= u'texinfo'¶
-
pattern
= <_sre.SRE_Pattern object at 0x3b8e730>¶
-
-
class
ly.lex.texinfo.
ParseVerbatim
(argcount=None)[source]¶ Bases:
ly.lex.Parser
-
items
= (<class 'ly.lex.texinfo.VerbatimEnd'>,)¶
-
pattern
= <_sre.SRE_Pattern object>¶
-
-
class
ly.lex.texinfo.
VerbatimEnd
[source]¶ Bases:
ly.lex.texinfo.Keyword
,ly.lex._token.Leaver
-
rx
= u'@end\\s+verbatim\\b'¶
-
ly.music package¶
Module contents¶
An api to read music from the tokens of a ly.document.Document into a tree structure.
This is meant to quickly read music from a document, to perform modifications on the document, and to interpret music and markup and to convert or export it to other formats.
All nodes are a subclass of items.Item, (which inherits from node.WeakNode).
Tree structures are created from nested LilyPond structures, markup and scheme code. Some Item types have special methods to query information. The Music type, for example, has a length() method that returns the duration of the music fragment.
Using the Music.events() method and the events module, it is possible to iterate in musical time over the music tree, e.g. to convert music to another format.
This package is not yet capable to construct documents entirely from scratch. This needs to be developed. Until that time, the ly.dom module can be used instead.
Some Item types can have a list of child items, but the tree structure is as linear as possible.
A convenience function is available to create a ly.music.items.Document instance for the specified ly.document.Document.
Here is an example:
>>> import ly.document
>>> import ly.music
>>> d=ly.document.Document(r'''
\version "2.18.0"
music = \relative {
\time 4/4
\key d \minor
d4 e f g
a g f e
d2
}
\score {
\new Staff <<
\music
>>
}
''')
>>> m=ly.music.document(d)
>>> print m.dump()
<Document>
<Version u'\\version'>
<String u'"'>
<Assignment u'music'>
<Relative u'\\relative'>
<MusicList u'{'>
<TimeSignature u'\\time'>
<KeySignature u'\\key'>
<Note u'd'>
<Command u'\\minor'>
<Note u'd'>
<Note u'e'>
<Note u'f'>
<Note u'g'>
<Note u'a'>
<Note u'g'>
<Note u'f'>
<Note u'e'>
<Note u'd'>
<Score u'\\score'>
<Context u'\\new'>
<MusicList u'<<'>
<UserCommand u'\\music'>
>>> m[2][0][0]
<MusicList u'<<'>
>>> m[2][0][0].length()
Fraction(5, 2)
>>>
Submodules¶
ly.music.event module¶
Translates a music.items.Document tree into lists of events.
-
class
ly.music.event.
Events
[source]¶ Bases:
object
Traverses a music tree and records music events from it.
-
read
(node, time=0, scaling=1)[source]¶ Read events from the node and all its child nodes; return time.
-
traverse
(node, time, scaling)[source]¶ Traverse node and call event handlers; record and return the time.
-
unfold_repeats
= False¶
-
ly.music.items module¶
The items a music expression is constructed with in a tree structure.
Whitespace and comments are left out.
All nodes (instances of Item) have a ‘position’ attribute that indicates where the item starts in the source text. Almost all items have the token that starts the expression in the ‘token’ attribute and possibly other tokens in the ‘tokens’ attribute, as a tuple.
The ‘end_position()’ method returns the position where the node (including its child nodes) ends.
You can get the whole tree structure of a LilyPond document by instantiating a Document with the ly.document.Document instance. (It will read all the tokens from the document using the Reader from the read module.) As a convenience, the ly.music.document(doc) function does this.
If you want to add new Item types, you should also add a method to read.Reader to construct those items.
-
class
ly.music.items.
Absolute
(parent=None)[source]¶ Bases:
ly.music.items.Music
An absolute music expression. Has one child (normally Music).
-
class
ly.music.items.
AfterGrace
(parent=None)[source]¶ Bases:
ly.music.items.Music
The afterGrace function with its two arguments.
Only the duration of the first is counted.
-
class
ly.music.items.
Alternative
(parent=None)[source]¶ Bases:
ly.music.items.Music
An alternative expression.
-
class
ly.music.items.
Articulation
(parent=None)[source]¶ Bases:
ly.music.items.Item
An articulation, fingering, string number, or other symbol.
-
class
ly.music.items.
Assignment
(parent=None)[source]¶ Bases:
ly.music.items.Item
A variable = value construct.
-
class
ly.music.items.
Beam
(parent=None)[source]¶ Bases:
ly.music.items.Item
A [ or ].
-
event
= None¶
-
-
class
ly.music.items.
Book
(parent=None)[source]¶ Bases:
ly.music.items.Container
A book { … } construct.
-
class
ly.music.items.
BookPart
(parent=None)[source]¶ Bases:
ly.music.items.Container
A bookpart { … } construct.
-
class
ly.music.items.
Change
(parent=None)[source]¶ Bases:
ly.music.items.Translator
A change music expression.
-
class
ly.music.items.
ChordItem
(parent=None)[source]¶ Bases:
ly.music.items.Item
An item inside a ChordSpecifier, e.g. a number or modifier.
-
class
ly.music.items.
ChordMode
(parent=None)[source]¶ Bases:
ly.music.items.InputMode
A chordmode or chords expression.
-
class
ly.music.items.
ChordSpecifier
(parent=None)[source]¶ Bases:
ly.music.items.Item
Chord specifications after a note in chord mode.
Has children of Note or ChordItem class.
-
class
ly.music.items.
Clef
(parent=None)[source]¶ Bases:
ly.music.items.Item
A clef item.
-
class
ly.music.items.
Command
(parent=None)[source]¶ Bases:
ly.music.items.Item
A LilyPond command.
-
class
ly.music.items.
Container
(parent=None)[source]¶ Bases:
ly.music.items.Item
An item having a list of child items.
-
class
ly.music.items.
Context
(parent=None)[source]¶ Bases:
ly.music.items.Translator
,ly.music.items.Music
A new or context music expression.
-
class
ly.music.items.
Document
(doc)[source]¶ Bases:
ly.music.items.Item
A toplevel item representing a ly.document.Document.
-
get_music
(filename)[source]¶ Return the music Document for the specified filename.
This implementation loads a ly.document.Document using utf-8 encoding. Inherit from this class to implement other loading mechanisms or caching.
-
music_events_til_position
(position)[source]¶ Return a list of tuples.
Every tuple is a (parent, nodes, scaling). If an empty list is returned, there is no music expression at this position.
-
substitute_for_node
(node)[source]¶ Returns a node that replaces the specified node (e.g. in music).
For example: a variable reference returns its value. Returns nothing if the node is not substitutable. Returns the node itself if it was substitutable, but the substitution failed.
-
-
class
ly.music.items.
DrumMode
(parent=None)[source]¶ Bases:
ly.music.items.InputMode
A drummode or drums expression.
-
class
ly.music.items.
DrumNote
(parent=None)[source]¶ Bases:
ly.music.items.Durable
-
class
ly.music.items.
Durable
(parent=None)[source]¶ Bases:
ly.music.items.Item
An Item that has a musical duration, in the duration attribute.
-
duration
= (0, 1)¶
-
-
class
ly.music.items.
Duration
(parent=None)[source]¶ Bases:
ly.music.items.Item
A written duration
-
class
ly.music.items.
Dynamic
(parent=None)[source]¶ Bases:
ly.music.items.Item
Any dynamic symbol.
-
class
ly.music.items.
FigureMode
(parent=None)[source]¶ Bases:
ly.music.items.InputMode
A figuremode or figures expression.
-
class
ly.music.items.
Grace
(parent=None)[source]¶ Bases:
ly.music.items.Music
Music that has grace timing, i.e. 0 as far as computation is concerned.
-
class
ly.music.items.
Header
(parent=None)[source]¶ Bases:
ly.music.items.Container
A header { … } construct.
-
class
ly.music.items.
Include
(parent=None)[source]¶ Bases:
ly.music.items.Item
An include command (not changing the language).
-
class
ly.music.items.
InputMode
(parent=None)[source]¶ Bases:
ly.music.items.Music
Base class for inputmode-changing commands.
-
class
ly.music.items.
Item
(parent=None)[source]¶ Bases:
ly.node.WeakNode
Represents any item in the music of a document.
This can be just a token, or an interpreted construct such as a note, rest or sequential or simultaneous construct , etc.
Some Item instances just have one responsible token, but others have a list or tuple to tokens.
An Item also has a pointer to the Document it originates from.
-
document
= None¶
-
has_output
(_seen_docs=None)[source]¶ Return True if this node has toplevel music, markup, book etc.
I.e. returns True when LilyPond would likely generate output. Usually you’ll call this method on a Document, Score, BookPart or Book node.
You should not supply the _seen_docs argument; it is used internally to avoid traversing recursively nested include files.
-
iter_toplevel_items
()[source]¶ Yield the toplevel items of our Document node in backward direction.
Iteration starts with the node just before the node “self” is a descendant of.
-
music_children
(depth=-1)[source]¶ Yield all the children that are new music expressions
(i.e. that are inside other constructions).
-
music_parent
()[source]¶ Walk up the parent tree until Music is found; return the outermost Music node.
Returns None is the node does not belong to any music expression (e.g. a toplevel Markup or Scheme object).
-
plaintext
()[source]¶ Return a plaintext value for this node.
This only makes sense for items like Markup or String. For other types, an empty string is returned
-
position
= -1¶
-
token
= None¶
-
tokens
= ()¶
-
-
class
ly.music.items.
KeySignature
(parent=None)[source]¶ Bases:
ly.music.items.Item
A key pitch mode command.
-
class
ly.music.items.
Keyword
(parent=None)[source]¶ Bases:
ly.music.items.Item
A LilyPond keyword.
-
class
ly.music.items.
Language
(parent=None)[source]¶ Bases:
ly.music.items.Item
A command (language or certain include commands) that changes the pitch language.
-
language
= None¶
-
-
class
ly.music.items.
Layout
(parent=None)[source]¶ Bases:
ly.music.items.Container
A layout { … } construct.
-
class
ly.music.items.
LayoutContext
(parent=None)[source]¶ Bases:
ly.music.items.Container
A context { … } construct within Layout or Midi.
-
class
ly.music.items.
LyricItem
(parent=None)[source]¶ Bases:
ly.music.items.Item
Another lyric item (skip, extender, hyphen or tie).
-
class
ly.music.items.
LyricMode
(parent=None)[source]¶ Bases:
ly.music.items.InputMode
A lyricmode, lyrics or addlyrics expression.
-
class
ly.music.items.
LyricText
(parent=None)[source]¶ Bases:
ly.music.items.Durable
A lyric text (word, markup or string), with a Duration.
-
class
ly.music.items.
LyricsTo
(parent=None)[source]¶ Bases:
ly.music.items.InputMode
A lyricsto expression.
-
class
ly.music.items.
Markup
(parent=None)[source]¶ Bases:
ly.music.items.Item
A command starting markup (markup, -lines and -list).
-
class
ly.music.items.
MarkupCommand
(parent=None)[source]¶ Bases:
ly.music.items.Item
A markup command, such as italic etc.
-
class
ly.music.items.
MarkupList
(parent=None)[source]¶ Bases:
ly.music.items.Item
The group of markup items inside { and }. NOTE: not a markuplist.
-
class
ly.music.items.
MarkupScore
(parent=None)[source]¶ Bases:
ly.music.items.Item
A score inside Markup.
-
class
ly.music.items.
MarkupUserCommand
(parent=None)[source]¶ Bases:
ly.music.items.Item
A user-defined markup command
-
class
ly.music.items.
MarkupWord
(parent=None)[source]¶ Bases:
ly.music.items.Item
A MarkupWord token.
-
class
ly.music.items.
Midi
(parent=None)[source]¶ Bases:
ly.music.items.Container
A midi { … } construct.
-
class
ly.music.items.
Music
(parent=None)[source]¶ Bases:
ly.music.items.Container
Any music expression, to be inherited of.
-
class
ly.music.items.
MusicList
(parent=None)[source]¶ Bases:
ly.music.items.Music
A music expression, either << >> or { }.
-
preceding
(node=None)[source]¶ Return a two-tuple (nodes, scaling).
The nodes are the nodes in time before the node (which must be a child), and the scaling is the scaling this node applies (normally 1).
If node is None, all nodes that would precede a fictive node at the end are returned.
-
simultaneous
= False¶
-
-
class
ly.music.items.
Note
(parent=None)[source]¶ Bases:
ly.music.items.Durable
A Note that has a ly.pitch.Pitch
-
accidental_token
= None¶
-
octave_token
= None¶
-
octavecheck_token
= None¶
-
pitch
= None¶
-
-
class
ly.music.items.
NoteMode
(parent=None)[source]¶ Bases:
ly.music.items.InputMode
A notemode or notes expression.
-
class
ly.music.items.
Number
(parent=None)[source]¶ Bases:
ly.music.items.Item
A numerical value, directly entered.
-
class
ly.music.items.
Override
(parent=None)[source]¶ Bases:
ly.music.items.Item
An override command.
-
class
ly.music.items.
Paper
(parent=None)[source]¶ Bases:
ly.music.items.Container
A paper { … } construct.
-
class
ly.music.items.
PartCombine
(parent=None)[source]¶ Bases:
ly.music.items.Music
The partcombine command with 2 music arguments.
-
class
ly.music.items.
Partial
(parent=None)[source]¶ Bases:
ly.music.items.Item
A partial command.
-
duration
= (0, 1)¶
-
-
class
ly.music.items.
PathItem
(parent=None)[source]¶ Bases:
ly.music.items.Item
An item in the path of an override or revert command.
-
class
ly.music.items.
PhrasingSlur
(parent=None)[source]¶ Bases:
ly.music.items.Item
A ( or ).
-
event
= None¶
-
-
class
ly.music.items.
PipeSymbol
(parent=None)[source]¶ Bases:
ly.music.items.Item
A pipe symbol: |
-
class
ly.music.items.
Postfix
(parent=None)[source]¶ Bases:
ly.music.items.Item
Any item that is prefixed with a _, - or ^ direction token.
-
class
ly.music.items.
Q
(parent=None)[source]¶ Bases:
ly.music.items.Durable
-
class
ly.music.items.
Relative
(parent=None)[source]¶ Bases:
ly.music.items.Music
A relative music expression. Has one or two children (Note, Music).
-
class
ly.music.items.
Repeat
(parent=None)[source]¶ Bases:
ly.music.items.Music
A repeat expression.
-
class
ly.music.items.
Rest
(parent=None)[source]¶ Bases:
ly.music.items.Durable
-
class
ly.music.items.
Revert
(parent=None)[source]¶ Bases:
ly.music.items.Item
A revert command.
-
class
ly.music.items.
Scaler
(parent=None)[source]¶ Bases:
ly.music.items.Music
A music construct that scales the duration of its contents.
In the numerator and denominator attributes the values specified for LilyPond are stored, e.g. with times 3/2 { c d e }, the numerator is integer 3 and the denominator is integer 2. Note that for tuplet and times the meaning of these numbers is reversed.
The algebraic scaling is stored in the scaling attribute.
-
denominator
= 0¶
-
numerator
= 0¶
-
preceding
(node=None)[source]¶ Return a two-tuple (nodes, scaling).
The nodes are the nodes in time before the node (which must be a child), and the scaling is the scaling this node applies.
If node is None, all nodes that would precede a fictive node at the end are returned.
-
scaling
= 1¶
-
-
class
ly.music.items.
Scheme
(parent=None)[source]¶ Bases:
ly.music.items.Item
A Scheme expression inside LilyPond.
-
class
ly.music.items.
SchemeItem
(parent=None)[source]¶ Bases:
ly.music.items.Item
Any scheme token.
-
class
ly.music.items.
SchemeLily
(parent=None)[source]¶ Bases:
ly.music.items.Container
A music expression inside #{ and #}.
-
class
ly.music.items.
SchemeList
(parent=None)[source]¶ Bases:
ly.music.items.Container
A ( … ) expression.
-
class
ly.music.items.
SchemeQuote
(parent=None)[source]¶ Bases:
ly.music.items.Item
A ‘ in scheme.
-
class
ly.music.items.
Score
(parent=None)[source]¶ Bases:
ly.music.items.Container
A score { … } construct.
-
class
ly.music.items.
Set
(parent=None)[source]¶ Bases:
ly.music.items.Item
A set command.
-
class
ly.music.items.
Skip
(parent=None)[source]¶ Bases:
ly.music.items.Durable
-
class
ly.music.items.
Slur
(parent=None)[source]¶ Bases:
ly.music.items.Item
A ( or ).
-
event
= None¶
-
-
class
ly.music.items.
String
(parent=None)[source]¶ Bases:
ly.music.items.Item
A double-quoted string.
-
class
ly.music.items.
StringTuning
(parent=None)[source]¶ Bases:
ly.music.items.Item
A stringTuning command (with a chord as argument).
-
class
ly.music.items.
Tag
(parent=None)[source]¶ Bases:
ly.music.items.Music
A tag, keepWithTag or removeWithTag command.
-
class
ly.music.items.
Tempo
(parent=None)[source]¶ Bases:
ly.music.items.Item
-
duration
= (0, 1)¶
-
-
class
ly.music.items.
Tie
(parent=None)[source]¶ Bases:
ly.music.items.Item
A tie.
-
class
ly.music.items.
TimeSignature
(parent=None)[source]¶ Bases:
ly.music.items.Item
A time command.
-
class
ly.music.items.
Token
(parent=None)[source]¶ Bases:
ly.music.items.Item
Any token that is not otherwise recognized
-
class
ly.music.items.
Translator
(parent=None)[source]¶ Bases:
ly.music.items.Item
Base class for a change, new, or context music expression.
-
class
ly.music.items.
Transpose
(parent=None)[source]¶ Bases:
ly.music.items.Music
A transpose music expression. Has normally three children (Note, Note, Music).
-
class
ly.music.items.
Tremolo
(parent=None)[source]¶ Bases:
ly.music.items.Item
A tremolo item “:”. The duration attribute is a tuple (base, scaling).
-
duration
= (0, 1)¶
-
-
class
ly.music.items.
Tweak
(parent=None)[source]¶ Bases:
ly.music.items.Item
A tweak command.
-
class
ly.music.items.
Unpitched
(parent=None)[source]¶ Bases:
ly.music.items.Durable
A “note” without pitch, just a standalone duration.
-
pitch
= None¶
-
-
class
ly.music.items.
Unset
(parent=None)[source]¶ Bases:
ly.music.items.Item
An unset command.
-
class
ly.music.items.
UserCommand
(parent=None)[source]¶ Bases:
ly.music.items.Music
A user command, most probably referring to music.
-
class
ly.music.items.
Version
(parent=None)[source]¶ Bases:
ly.music.items.Item
A version command.
-
class
ly.music.items.
VoiceSeparator
(parent=None)[source]¶ Bases:
ly.music.items.Item
A voice separator: \
-
class
ly.music.items.
With
(parent=None)[source]¶ Bases:
ly.music.items.Container
A with … construct.
ly.music.read module¶
The Reader is used to construct a tree structure of (musical and other) items in a LilyPond document. The item types that are used are in the items module.
You instantiate a Reader with a ly.document.Source that reads tokens from any (part of a) ly.document.Document.
Whitespace and comments are left out.
All nodes (instances of Item) have a ‘position’ attribute that indicates where the item starts in the source text. Almost all items have the token that starts the expression in the ‘token’ attribute and possibly other tokens in the ‘tokens’ attribute, as a tuple.
The ‘end_position()’ method returns the position where the node (including its child nodes) ends.
-
class
ly.music.read.
Reader
(source)[source]¶ Bases:
object
Reads tokens from a Source and builds a meaningful tree structure.
-
add_bracketed
(item, source)[source]¶ Append the arguments between brackets to the item.
Returns True if that succeeded, else False.
-
add_duration
(item, token=None, source=None)[source]¶ Add a duration attribute to the item.
When there are tokens, a Duration item is also appended to the item.
-
consume
(last_token=None)[source]¶ Yield the tokens from our source until a parser is exit.
If last_token is given, it is called with the last token that is read.
-
factory
(cls, token=None, consume=False, position=None)[source]¶ Create Item instance for token.
If consume is True, consume()s the source into item.tokens. If you don’t specify a token, you must specify the position (>= 0).
-
handle_bracketed
(t, source)[source]¶ handle with, layout, paper, context, book, bookpart, score, midi, header
-
handle_direct_items
(t, source)[source]¶ Tokens that directly translate to an Item.
handle Tie, PipeSymbol, Dynamic, VoiceSeparator
-
handle_inputmode
(t, source)[source]¶ handle notes, figuremode, notemode, drums, chords, drummode, chordmode, figures
-
handle_music_list
(t, source)[source]¶ handle OpenBracket, OpenSimultaneous, SimultaneousOrSequentialCommand
-
handle_string_start
(t, source=None)[source]¶ handle StringStart
handle StringStart
handle StringStart
-
handle_variable_assignment
(t, source)[source]¶ handle PaperVariable, LayoutVariable, HeaderVariable, UserVariable
-
read_chord_specifier
(t, source=None)[source]¶ Read stuff behind notes in chordmode.
handle ChordSeparator
-
read_command
(t, source)[source]¶ Read the rest of a command given in t from the source.
handle Command
-
read_keyword
(t, source)[source]¶ Read the rest of a keyword given in t from the source.
handle Keyword
-
read_music_item
(t, source)[source]¶ Read one music item (note, rest, s, skip, or q) from t and source.
-
read_user_command
(t, source)[source]¶ Read a user command, this can be a variable reference.
handle UserCommand
-
set_language
(lang)[source]¶ Changes the pitch name language to use.
Called internally when language or include tokens are encountered with a valid language name/file.
Sets the language attribute to the language name.
-
test_music_list
(t)[source]¶ Test whether a music list ({ … }, << … >>, starts here.
Also handles simultaneous { … } and sequential { … } correctly. These obscure commands are not even highlighted by lex, but they exist in LilyPond… simultaneous { … } is like << … >> but sequential << … >> just behaves like << … >>
Returns a two-tuple(item; iterable), both may be None. If item is not None, it can be either a UserCommand or a MusicList. If iterable is None, the item is a UserCommand (namely simultaneous or sequential, but not followed by a { or <<); else the item is a MusicList, and the iterable should be read fully to get all the tokens inside the MusicList. If item is None, there is no MusicList and no token is read.
This way you can handle the { … } and << … >> transparently in every input mode.
-
-
class
ly.music.read.
dispatcher
[source]¶ Bases:
object
Decorator creator to dispatch commands, keywords, etc. to a method.
-
class
ly.music.read.
dispatcher_class
[source]¶ Bases:
ly.music.read.dispatcher
Decorator creator to dispatch the class of a token to a method.
ly.musicxml package¶
Module contents¶
MusicXML functionality.
This subpackage is created to convert LilyPond text to MusicXML with the help of the tree structure created by ly.music. But it is constructed in such a way that you can use some of the submodules for generic MusicXML creation and manipulation.
Submodules¶
ly.musicxml.create_musicxml module¶
Uses xml.etree to create a Music XML document.
Example:
musxml = create_musicxml.CreateMusicXML()
musxml.create_part()
musxml.create_measure(divs=1)
musxml.new_note('C', 4, 'whole', 4)
xml = musxml.musicxml()
xml.write(filename)
-
class
ly.musicxml.create_musicxml.
CreateMusicXML
[source]¶ Creates the XML nodes according to the Music XML standard.
-
add_tuplet_type
(nr, ttype, actnr=0, acttype=u'', normnr=0, normtype=u'')[source]¶ Create tuplet with type attribute
-
create_new_node
(parentnode, nodename, txt)[source]¶ The Music XML language is extensive. This function can be used to create a non basic node not covered elsewhere in this script.
TODO: add attributes
-
new_bar_attr
(clef=0, mustime=0, key=None, mode=0, divs=0, multirest=0)[source]¶ Create all bar attributes set.
-
new_note
(step, octave, durtype, divdur, alter=0, acc_token=0, voice=1, dot=0, chord=0, grace=(0, 0), stem_dir=0)[source]¶ Create all nodes needed for a normal note.
-
ly.musicxml.ly2xml_mediator module¶
The information of the parsed source is organised into an object structure with help of the classes in ly.musicxml.xml_objs.
-
class
ly.musicxml.ly2xml_mediator.
Mediator
[source]¶ Help class that acts as mediator between the ly source parser and the XML creating modules.
-
add_snippet
(snippet_name)[source]¶ Adds snippet to previous barlist. A snippet can be shorter than a full bar, so this can also mean continuing a previous bar.
-
calc_tupl_den
(tfraction, length)[source]¶ Calculate the tuplet denominator from fraction and duration of tuplet.
-
change_to_tuplet
(tfraction, ttype, nr, length=None)[source]¶ Change the current note into a tuplet note.
-
check_current_note
(rel=False, rest=False, is_unpitched=False)[source]¶ Perform checks common for all new notes and rests.
-
check_lyrics
(voice_id)[source]¶ Check the finished lyrics section and merge it into the referenced voice.
-
check_score
()[source]¶ Check score
If no part were created, place first variable (fallback) as part.
Apply the latest global section.
-
check_voices
()[source]¶ Checks active sections. The two latest created are merged. Also checks for empty sections.
-
check_voices_by_nr
()[source]¶ Used for snippets. Merges all active snippets created after the stored voice number.
-
new_articulation
(art_token)[source]¶ An articulation, fingering, string number, or other symbol.
Grouped as articulations, ornaments, technical and others.
-
new_iso_dura
(note, rel=False, is_unpitched=False)[source]¶ Isolated durations in music sequences.
An isolated duration in LilyPond is rendered as a normal note but the pitch information is missing and has to be filled in by some other means, usually by the previous pitch. (RhythmicStaff is an exception since it ignores specified pitches anyway).
-
sections
= None¶ default and initial values
-
set_slur
(nr, slur_type, phrasing=False)[source]¶ Set the slur start or stop for the current note. phrasing should be set to True if the slur is meant to be a phrasing mark.
-
-
ly.musicxml.ly2xml_mediator.
artic_token2xml_name
(art_token)[source]¶ From Articulations in ly.music.items. Grouped as articulations, ornaments and others.
To add an articulation look up the name or abbreviation in LilyPond and the corresponding node name in musicXML. Add it to the python dictionary below.
-
ly.musicxml.ly2xml_mediator.
calc_trem_dur
(repeats, base_scaling, duration)[source]¶ Calculate tremolo duration from number of repeats and initial duration.
-
ly.musicxml.ly2xml_mediator.
clefname2clef
(clefname)[source]¶ To add a clef look up the clef name in LilyPond and the corresponding definition in musicXML. Add it to the python dictionary below.
ly.musicxml.lymus2musxml module¶
Using the tree structure from ly.music to initiate the conversion to MusicXML.
Uses functions similar to ly.music.items.Document.iter_music() to iter through the node tree. But information about where a node branch ends is also added. During the iteration the information needed for the conversion is captured.
-
class
ly.musicxml.lymus2musxml.
End
(node)[source]¶ Extra class that gives information about the end of Container elements in the node list.
-
class
ly.musicxml.lymus2musxml.
ParseSource
[source]¶ creates the XML-file from the source code according to the Music XML standard
-
Assignment
(a)[source]¶ Variables should already have been substituted so this need only cover other types of assignments.
-
DrumMode
(drummode)[source]¶ A drummode or drums expression.
If the shorthand form drums is found, DrumStaff is implicit.
-
check_context
(context, context_id=None, token=u'')[source]¶ Check context and do appropriate action (e.g. create new part).
-
find_score_sub
(doc)[source]¶ Find substitute for scorenode. Takes first music node that isn’t an assignment.
-
get_previous_node
(node)[source]¶ Returns the nodes previous node or false if the node is first in its branch.
-
iter_score
(scorenode, doc)[source]¶ Iter over score.
Similarly to items.Document.iter_music user commands are substituted.
Furthermore repeat unfold expressions are unfolded.
-
look_ahead
(node, find_node)[source]¶ Looks ahead in a container node and returns True if the search is successful.
-
look_behind
(node, find_node)[source]¶ Looks behind on the parent node(s) and returns True if the search is successful.
-
parse_document
(ly_doc, relative_first_pitch_absolute=False)[source]¶ Parse the LilyPond source specified as a ly.document document.
If relative_first_pitch_absolute is set to True, the first pitch in a- elative expression without startpitch is considered to be absolute
- (LilyPond 2.18+ behaviour).
-
parse_nodes
(nodes)[source]¶ Work through all nodes by calling the function with the same name as the nodes class.
-
ly.musicxml.xml_objs module¶
Classes that holds information about a musical score, suitable for converting to musicXML.
When the score structure is built, it can easily be used to create a musicXML.
Example:
from ly.musicxml import create_musicxml, xml_objs
musxml = create_musicxml.CreateMusicXML()
score = xml_objs.Score()
part = xml_objs.ScorePart()
score.partlist.append(part)
bar = xml_objs.Bar()
part.barlist.append(bar)
ba = xml_objs.BarAttr()
ba.set_time([4,4])
bar.obj_list.append(ba)
c = xml_objs.BarNote('c', 0, 0, (1,1))
c.set_octave(4)
c.set_durtype(1)
bar.obj_list.append(c)
xml_objs.IterateXmlObjs(score, musxml, 1)
xml = musxml.musicxml()
xml.write(filename)
-
class
ly.musicxml.xml_objs.
Bar
[source]¶ Representing the bar/measure. Contains also information about how complete it is.
-
class
ly.musicxml.xml_objs.
BarAttr
[source]¶ object that keep track of bar attributes, e.g. time sign, clef, key etc
-
class
ly.musicxml.xml_objs.
BarNote
(pitch_note, alter, accidental, duration, voice=1)[source]¶ Bases:
ly.musicxml.xml_objs.BarMus
object to keep track of note parameters
-
class
ly.musicxml.xml_objs.
BarRest
(duration, voice=1, show_type=True, skip=False, pos=0)[source]¶ Bases:
ly.musicxml.xml_objs.BarMus
object to keep track of different rests and skips
-
class
ly.musicxml.xml_objs.
DynamicsDashes
(sign, before=True)[source]¶ Bases:
ly.musicxml.xml_objs.Dynamics
Dynamics dashes.
-
class
ly.musicxml.xml_objs.
DynamicsMark
(sign, before=True)[source]¶ Bases:
ly.musicxml.xml_objs.Dynamics
A dynamics mark.
-
class
ly.musicxml.xml_objs.
DynamicsText
(sign, before=True)[source]¶ Bases:
ly.musicxml.xml_objs.Dynamics
A dynamics text.
-
class
ly.musicxml.xml_objs.
DynamicsWedge
(sign, before=True)[source]¶ Bases:
ly.musicxml.xml_objs.Dynamics
A dynamics wedge/hairpin.
-
class
ly.musicxml.xml_objs.
IterateXmlObjs
(score, musxml, div)[source]¶ A ly.musicxml.xml_objs.Score object is iterated and the Music XML node tree is constructed.
-
class
ly.musicxml.xml_objs.
LyricsSection
(name, voice_id)[source]¶ Bases:
ly.musicxml.xml_objs.ScoreSection
Holds the lyrics information. Will eventually be merged to the corresponding note in the section set by the voice id.
-
class
ly.musicxml.xml_objs.
Score
[source]¶ Object that keep track of a whole score.
-
class
ly.musicxml.xml_objs.
ScorePart
(staves=0, part_id=None, to_part=None, name=u'')[source]¶ Bases:
ly.musicxml.xml_objs.ScoreSection
object to keep track of part
-
class
ly.musicxml.xml_objs.
ScorePartGroup
(num, bracket)[source]¶ Object to keep track of part group.
-
class
ly.musicxml.xml_objs.
ScoreSection
(name, glob=False)[source]¶ object to keep track of music section
-
class
ly.musicxml.xml_objs.
Slur
(nr, slurtype, phrasing=False, start_node=None)[source]¶ Stores information about slur. start_node is only interesting if slurtype is ‘stop’. start_node must be None or a Slur instance.
-
class
ly.musicxml.xml_objs.
SlurCount
[source]¶ Utility class meant for keeping count of started slurs in a section
-
class
ly.musicxml.xml_objs.
Snippet
(name, merge_into)[source]¶ Bases:
ly.musicxml.xml_objs.ScoreSection
Short section intended to be merged. Holds reference to the barlist to be merged into.
-
class
ly.musicxml.xml_objs.
TempoDir
(unit, unittype, beats, dots, text)[source]¶ Object that stores tempo direction information
-
class
ly.musicxml.xml_objs.
Tuplet
(fraction, ttype, nr, acttype, normtype)[source]¶ Stores information about tuplet.
-
class
ly.musicxml.xml_objs.
Unpitched
(duration, step=None, voice=1)[source]¶ Bases:
ly.musicxml.xml_objs.BarNote
Object to keep track of unpitched notes.
ly.pitch package¶
Module contents¶
Pitch manipulation.
-
class
ly.pitch.
LanguageName
[source]¶ Bases:
ly.lex._token.Token
A Token that denotes a language name.
-
class
ly.pitch.
Pitch
(note=0, alter=0, octave=0, accidental=u'', octavecheck=None)[source]¶ Bases:
object
A pitch with note, alter and octave attributes.
Attributes may be manipulated directly.
-
class
ly.pitch.
PitchIterator
(source, language=u'nederlands')[source]¶ Bases:
object
Iterate over notes or pitches in a source.
-
pitches
()[source]¶ Yields all tokens, but collects Note and Octave tokens.
When a Note is encountered, also reads octave and octave check and then a Pitch is yielded instead of the tokens.
-
-
exception
ly.pitch.
PitchNameNotAvailable
(language)[source]¶ Bases:
exceptions.Exception
Exception raised when there is no name for a pitch.
Can occur when translating pitch names, if the target language e.g. does not have quarter-tone names.
-
class
ly.pitch.
PitchWriter
(names, accs, replacements=())[source]¶ Bases:
object
-
language
= u'unknown'¶
-
-
ly.pitch.
octaveToNum
(octave)[source]¶ Converts string octave to an integer:
“” -> 0 ; “,” -> -1 ; “’‘’” -> 3 ; etc.
Submodules¶
ly.pitch.abs2rel module¶
Convert absolute music to relative music.
-
ly.pitch.abs2rel.
abs2rel
(cursor, language=u'nederlands', startpitch=True, first_pitch_absolute=False)[source]¶ Converts pitches from absolute to relative.
language: language to start reading pitch names in
- startpitch: if True, write a starting pitch before the opening bracket of
- a relative expression.
- first_pitch_absolute: this option only makes sense when startpitch is False.
If first_pitch_absolute is True, the first pitch of a relative expression is written as absolute. This mimics the behaviour of LilyPond >= 2.18. (In fact, the starting pitch is then assumed to be f.)
If False, the first pitch is written as relative to c’ (LilyPond < 2.18 behaviour).
Existing relative expressions are not changed.
ly.pitch.rel2abs module¶
Convert relative music to absolute music.
-
ly.pitch.rel2abs.
rel2abs
(cursor, language=u'nederlands', first_pitch_absolute=False)[source]¶ Converts pitches from relative to absolute.
language: language to start reading pitch names in
- first_pitch_absolute: if True, the first pitch of a relative expression
is regarded as absolute, when no starting pitch was given. This mimics the behaviour of LilyPond >= 2.18. (In fact, the starting pitch is then assumed to be f.)
If False, the starting pitch, when not given, is assumed to be c’ (LilyPond < 2.18 behaviour).
ly.pitch.translate module¶
Translating the language of pitch names
-
ly.pitch.translate.
insert_language
(document, language, version=None)[source]¶ Inserts a language command in the document.
The command is inserted at the top or just below the version line.
If the LilyPond version specified < (2, 13, 38), the include command is used, otherwise the newer language command.
-
ly.pitch.translate.
translate
(cursor, language, default_language=u'nederlands')[source]¶ Changes the language of the pitch names.
May raise ly.pitch.PitchNameNotAvailable if the current pitch language has no quarter tones.
Returns True if there also was a language or include language command that was changed. If not and the cursor specified only a part of the document, you could warn the user that a language or include command should be added to the document. Or you could call insert_language to add a language command to the top of the document.
ly.pitch.transpose module¶
Transposing music.
-
class
ly.pitch.transpose.
ModalTransposer
(numSteps=1, scaleIndex=0)[source]¶ Bases:
object
Transpose pitches by number of steps within a given scale.
Instantiate with the number of steps (+/-) in the scale to transpose by, and a mode index. The mode index is the index of the major scale in the circle of fifths (C Major = 0).
-
class
ly.pitch.transpose.
ModeShifter
(key, scale)[source]¶ Bases:
ly.pitch.transpose.Transposer
Shift pitches to optional mode/scale.
The scale should be formatted in analogy to the scale in the Transposer parent class.
The key should be an instance of ly.pitch.Pitch.
-
class
ly.pitch.transpose.
Simplifier
(scale=None)[source]¶ Bases:
ly.pitch.transpose.Transposer
Make complicated accidentals simpler by substituting naturals where possible.
-
class
ly.pitch.transpose.
Transposer
(fromPitch, toPitch, scale=None)[source]¶ Bases:
object
Transpose pitches.
Instantiate with a from- and to-Pitch, and optionally a scale. The scale is a list with the pitch height of the unaltered step (0 .. 6). The default scale is the normal scale: C, D, E, F, G, A, B.
-
scale
= (0, 1, 2, Fraction(5, 2), Fraction(7, 2), Fraction(9, 2), Fraction(11, 2))¶
-
-
ly.pitch.transpose.
transpose
(cursor, transposer, language=u'nederlands', relative_first_pitch_absolute=False)[source]¶ Transpose pitches using the specified transposer.
If relative_first_pitch_absolute is True, the first pitch in a relative expression is considered to be absolute, when a startpitch is not given. This is LilyPond >= 2.18 behaviour.
If relative_first_pitch_absolute is False, the first pitch in a relative expression is considered to be relative to c’, is no startpitch is given. This is LilyPond < 2.18 behaviour.
Currently, relative_first_pitch_absolute defaults to False.
ly.xml package¶
Introduction¶
This package is concerned with representing a LilyPond structure (e.g. music) as an XML tree.
The structure of the tree closely follows LilyPond’s data structures. The tree can be parsed or analysed, and could be used to convert the music to other formats like Mei of MusicXML.
This package tries to define the exact format (dtd or schema) of the tree.
There will be three ways to build the tree:
- by hand, by creating XML elements (maybe with use of some helper methods).
- from a tokenized document
- by LilyPond, using the
xml-export.ily
script that is included.
The latter case is very interesting as all the music parsing and handling is already done by LilyPond. The exported XML nearly contains all information of a score or music object. Below, some more information about the XML.
Note that this is all in heavy development.
Module contents¶
Routines that manipulate an XML mapping very similar to the Scheme music structure used by LilyPond itself.
The mapping can also be generated from within LilyPond and then parsed by other programs.
While designing the mapping, I decided to use xml elements for almost everything, only values that are very simple in all cases, are attributes.
Code could be written to convert such an XML music tree to other formats.
Also code is added to build such trees from scratch and from tokenized documents.
Code will be added to print LilyPond source. When all is finished, ly.dom is deprecated and ly.music will probably use these xml tree for storage.
A single LilyPond file xml-export.ily is also included with this module;
it can be included in a LilyPond document and exports the
\displayLilyXML
music function.
The xml-export.ily
file¶
Written by Wilbert Berendsen, jan-feb 2015
This LilyPond module defines a function (xml-export
) that converts LilyPond
datastructures to XML. For convenience, a \displayLilyXML
music function is
added that converts a music expression to XML.
Usage e.g.:
\include "/path/to/xml-export.ily"
\displayLilyXML { c d e f }
The XML closely follows the LilyPond music structure.
All (make-music 'MusicName ...)
objects translate to a
<music type="MusicName">
tag. The music in the 'element
and 'elements
properties is put in the <element>
and <elements>
tags. (LilyPond uses
'element
when there is a single music argument, and 'elements
for a list
of music arguments, but for example \repeat
uses both: 'element
for the
repeated music and 'elements
for the \alternatives
.)
Thus <element>
, if there, always has one <music>
child. <elements>
,
if there, can have more than one <music>
child.
Besides 'element
and 'elements
, the following properties of music
objects are handled specially:
'origin
=><origin>
element withfilename
,line
andchar
attributes'pitch
=><pitch>
element withoctave
,notename
andalteration
attributes'duration
=><duration>
element withlog
,dots
,numer
anddenom
attributes'articulations
=><articulations>
element containing<music>
elements'tweaks
=><tweaks>
element containing pairs(symbol . value)
All other properties a music object may have, are translated to a <property>
element with a name
attribute. The value is the child element and can be any
object (string, list, pair, symbol, number etc.). (Note that the LilyPond
command \displayMusic
does not display all properties.)
Markup objects are also converted to XML, where a toplevel <markup>
element
is used. The individual markup commands are converted to an <m>
element,
with the name in the name
attribute (e.g.
<m name="italic"><string value="Hi there!"/></m>
). Arguments to markup
commands may be other commands, or other objects (markup \score
even has
a score argument, which is also supported).
Example¶
This LilyPond music:
\relative {
c d e
}
maps to Scheme (using \displayMusic
):
(make-music
'RelativeOctaveMusic
'element
(make-music
'SequentialMusic
'elements
(list (make-music
'NoteEvent
'pitch
(ly:make-pitch -1 0 0)
'duration
(ly:make-duration 2 0 1))
(make-music
'NoteEvent
'pitch
(ly:make-pitch -1 1 0)
'duration
(ly:make-duration 2 0 1))
(make-music
'NoteEvent
'pitch
(ly:make-pitch -1 2 0)
'duration
(ly:make-duration 2 0 1)))))
and maps to XML (using \displayLilyXML
):
<music name="RelativeOctaveMusic">
<origin filename="/home/wilbert/dev/python-ly/ly/xml/xml-export.ily" line="244" char="17"/>
<element>
<music name="SequentialMusic">
<origin filename="/home/wilbert/dev/python-ly/ly/xml/xml-export.ily" line="244" char="27"/>
<elements>
<music name="NoteEvent">
<origin filename="/home/wilbert/dev/python-ly/ly/xml/xml-export.ily" line="245" char="4"/>
<pitch octave="-1" notename="0" alteration="0"/>
<duration log="2" dots="0" numer="1" denom="1"/>
</music>
<music name="NoteEvent">
<origin filename="/home/wilbert/dev/python-ly/ly/xml/xml-export.ily" line="245" char="6"/>
<pitch octave="-1" notename="1" alteration="0"/>
<duration log="2" dots="0" numer="1" denom="1"/>
</music>
<music name="NoteEvent">
<origin filename="/home/wilbert/dev/python-ly/ly/xml/xml-export.ily" line="245" char="8"/>
<pitch octave="-1" notename="2" alteration="0"/>
<duration log="2" dots="0" numer="1" denom="1"/>
</music>
</elements>
</music>
</element>
</music>
By default, the XML is written to standard output.
To automatically export a full LilyPond document to an XML representation,
use the xml-export-init.ly
script with the --init
LilyPond option.
That script automatically sets up LilyPond to output one XML document with a
<document>
root element, containing a <book>
element for every book
in the LilyPond file. (LilyPond always creates at least one book, collecting
all the music or markup at the toplevel.)
The xml-export-init.ly
script is intended to be used via the --init
option.
It automatically converts every \book
in the score to an XML document.
In this case the XML is also written to standard output by default, but you can
specify another file with -dxml-export=<filename>
.
So, to convert a LilyPond source file to an XML file containing the LilyPond music structure in XML format, use the following command:
lilypond --init /path/to/xml-export-init.ly -dxml-export=song.xml song.ly
The XML document has a <document>
root element, containing a <book>
element for every book in the LilyPond file.
ly.data package¶
Module contents¶
Query functions to get data from the LilyPond-generated _data.py module.
-
ly.data.
grob_interface_properties
(iface)[source]¶ Returns the list of properties an interface supports.
-
ly.data.
grob_interfaces
(grob, prop=None)[source]¶ Returns the list of interfaces a grob supports.
If prop is given, only returns the interfaces that define prop.
-
ly.data.
grob_interfaces_for_property
(prop)[source]¶ Returns the list of interfaces that define the property.
Most times returns one, but several interface names may be returned.
Submodules¶
ly.cli package¶
Module contents¶
The commandline interface of the ‘ly’ command.
Submodules¶
ly.cli.command module¶
The commands that are available to the command line.
-
class
ly.cli.command.
abs2rel
[source]¶ Bases:
ly.cli.command._edit_command
convert absolute music to relative
-
class
ly.cli.command.
highlight
(output=None)[source]¶ Bases:
ly.cli.command._export_command
write syntax colored HTML.
-
ly.cli.command.
hl
¶ alias of
ly.cli.command.highlight
-
class
ly.cli.command.
reformat
[source]¶ Bases:
ly.cli.command.indent
reformat the document
-
class
ly.cli.command.
rel2abs
[source]¶ Bases:
ly.cli.command._edit_command
convert relative music to absolute
-
class
ly.cli.command.
set_variable
(arg)[source]¶ Bases:
ly.cli.command._command
set a variable to a value
-
class
ly.cli.command.
simplify_accidentals
[source]¶ Bases:
ly.cli.command._edit_command
replace notes with accidentals as much as possible with their natural neighbors
-
class
ly.cli.command.
translate
(language)[source]¶ Bases:
ly.cli.command._edit_command
translate pitch names
ly.cli.main module¶
The entry point for the ‘ly’ command.
-
class
ly.cli.main.
Output
[source]¶ Bases:
object
Object living for a whole file/command operation, handling the output.
When opening a file it has already opened earlier, the file is appended to (like awk).
-
file
(**kwds)[source]¶ Return a context manager for writing to.
If you set encoding to “binary” or False, the file is opened in binary mode and you should encode the data you write yourself.
-
get_filename
(opts, filename)[source]¶ Queries the output attribute from the Options and returns it.
If replace_pattern is True (by default) and the attribute contains a ‘*’, it is replaced with the full path of the specified filename, but without extension. It the attribute contains a ‘?’, it is replaced with the filename without path and extension.
If ‘-‘ is returned, it denotes standard output.
-
-
ly.cli.main.
parse_command
(arg)[source]¶ Parse the command string, returning a list of command.command instances.
Exits when a command is invalid.
-
ly.cli.main.
parse_command_line
()[source]¶ Return a three-tuple(options, commands, files).
options is an Options instance with all the command-line options commands is a list of command.command instances files is the list of filename arguments
Also performs error handling and may exit on certain circumstances.
ly.server package¶
Module contents¶
A package implementing an HTTP server to process LilyPond input code.
Submodules¶
ly.server.command module¶
The commands that are available to the command line.
-
class
ly.server.command.
abs2rel
[source]¶ Bases:
ly.server.command._edit_command
convert absolute music to relative
-
class
ly.server.command.
highlight
[source]¶ Bases:
ly.server.command._export_command
convert source to syntax colored HTML.
-
class
ly.server.command.
language
[source]¶ Bases:
ly.server.command._info_command
retrieve language from document
-
class
ly.server.command.
mode
[source]¶ Bases:
ly.server.command._info_command
retrieve mode from document
-
class
ly.server.command.
musicxml
[source]¶ Bases:
ly.server.command._export_command
convert source to MusicXML
-
class
ly.server.command.
reformat
[source]¶ Bases:
ly.server.command.indent
reformat the document
-
class
ly.server.command.
rel2abs
[source]¶ Bases:
ly.server.command._edit_command
convert relative music to absolute
-
class
ly.server.command.
set_variable
(arg)[source]¶ Bases:
ly.server.command._command
set a configuration variable to a value
-
class
ly.server.command.
translate
(language)[source]¶ Bases:
ly.server.command._edit_command
translate pitch names
ly.server.handler module¶
HTTP request handler
-
class
ly.server.handler.
RequestHandler
(request, client_address, server)[source]¶ Bases:
BaseHTTPServer.BaseHTTPRequestHandler
-
create_command
(cmd)[source]¶ Parse one command from the JSON data, plus optionally some commands to set variables. Returns an array with command._command instances. Raises exceptions upon faulty data.
-
do_POST
()[source]¶ A POST request is expected to contain the task to be executed as a JSON object in the request body. The POST handler (currently) ignores the URL.
-
process_json_request
(request)[source]¶ Configure the action(s) to be taken, based on the JSON object. Raise errors when the JSON object can’t be properly understood. Run the commands and return a string (from cursor.text() ).
-
ly.server.main module¶
The entry point for the ‘ly-server’ command.
-
ly.server.main.
die
(message)[source]¶ Exit with message to STDERR. In ly-server this should only be called upon startup, not while processing requests. Then the error should be sent back to the client.
-
ly.server.main.
parse_command_line
()[source]¶ Returns a two-tuple(server_opts, cmd_opts)
server_opts is a ServerOptions instance configuring the server behaviour cmd_opts is an Options instance with default options for future command executions triggered by HTTP requests.
Also performs error handling and may exit on certain circumstances.
Submodules¶
ly.slexer module¶
slexer – Stateful Lexer¶
parses text, searching for tokens represented by a regular expression.
Only depends on the standard Python re module.
You need to create at least one subclass of Parser, and a subclass of Token for every type of text to search for. Then you list the token class names in the ‘items’ tuple of the Parser subclass definition.
Different contexts can be parsed by creating multiple Parser subclasses. A Parser searches for tokens using the list of Token classes. (Token is simply a subclass of str in Python 3 and of unicode in Python 2). Every Token subclass has the regular expression part to search for in its ‘rx’ class attribute.
You start parsing text by instantiating a State (you don’t need to subclass that) with the Parser subclass you want to parse the text with. Then you iterate over the generated tokens using the tokens(text) method of the State instance. You can use the tokens just as strings (e.g. if token == ‘text’…) but you can also test for the type of the token (e.g. if isinstance(token, Number)…). The tokens also carry a ‘pos’ and an ‘end’ attribute, specifying their position in the parsed text string.
A token may cause a different Parser to be entered, of the current Parser to be left, etc. This is done by implementing the update_state() method of the Token subclass. This method is called automatically when the Token is instantiated.
The State maintains the parsing state (the list of active Parser instances). A State can be frozen to be thawed later to resume parsing text starting in a particular context. A Fridge can be used to store and recover a state under a simple integer number.
How to use slexer:
from slexer import Token, Parser, State
# create token classes:
class Word(Token):
rx = r'\w+'
class Number(Token):
rx = r'\d+'
class String(Token):
pass
class StringStart(String):
rx = '"'
def update_state(self, state):
state.enter(PString())
class StringEnd(String):
rx = '"'
def update_state(self, state):
state.leave()
# create parsers:
class PTest(Parser):
'''Looks for numbers, words and the double quote.'''
items = (
Number,
Word,
StringStart,
)
class PString(Parser):
'''Returns String by default, quits at double quote.'''
default = String
items = (
StringEnd,
)
s = State(PTest)
for t in s.tokens(
'een tekst met 7 woorden, '
'een "tekst met 2 aanhalingstekens" '
'en 2 of 3 nummers'):
print(t.__class__, t)
Running the above code, the result is:
<class '__main__.Word'> een
<class '__main__.Word'> tekst
<class '__main__.Word'> met
<class '__main__.Number'> 7
<class '__main__.Word'> woorden
<class '__main__.Word'> een
<class '__main__.StringStart'> "
<class '__main__.String'> tekst met 2 aanhalingstekens
<class '__main__.StringEnd'> "
<class '__main__.Word'> en
<class '__main__.Number'> 2
<class '__main__.Word'> of
<class '__main__.Number'> 3
<class '__main__.Word'> nummers
-
class
ly.slexer.
Token
[source]¶ Bases:
unicode
Represents a parsed piece of text.
The subclass determines the type.
You should put the regular expression string in the rx class attribute. In the rx string, you may not use named groups starting with “g_”.
To add token types to a Parser class, list the token class in the items attribute of the Parser class.
-
end
¶
-
pos
¶
-
rx
= None¶
-
classmethod
test_match
(match)[source]¶ Should return True if the match should indeed instantiate this class.
This class method is only called if multiple Token classes in the Parser’s items list have the same rx attribute. This method is then called for every matching Token subclass until one returns True. That token is then instantiated. (The method is not called for the last class in the list that have the same rx attribute, and also not if there is only one class with that rx attribute.)
The default implementation always returns True.
-
update_state
(state)[source]¶ Lets the token update the state, e.g. enter a different parser.
This method is called by the State upon instantiation of the tokens.
Don’t use it later on to have a State follow already instantiated Tokens because the FallthroughParser type can also change the state without generating a Token. Use State.follow() to have a State follow instantiated Tokens.
The default implementation lets the Parser decide on state change.
-
-
class
ly.slexer.
Parser
[source]¶ Bases:
object
Abstract base class for Parsers.
When creating Parser subclasses, you should set the ‘items’ attribute to a tuple of Token subclasses. On class construction, a large regular expression pattern is built by combining the expressions from the ‘rx’ attributes of the Token subclasses.
Additionally, you may implement the update_state() method which is called by the default implementation of update_state() in Token.
-
default
= None¶
-
fallthrough
(state)[source]¶ Called when no match is returned by parse().
If this function returns True, the tokenizer stops parsing, assuming all text has been consumed. If this function returns False or None, it should alter the state (switch parsers) and parsing continues using the new Parser.
The default implementation simply returns True.
-
items
= ()¶
-
re_flags
= 0¶
-
-
class
ly.slexer.
FallthroughParser
[source]¶ Bases:
ly.slexer.Parser
Base class for parsers that ‘match’ instead of ‘search’ for a pattern.
You can also implement the fallthrough() method to do something with the state if there is no match. The default is to leave the current parser. See Parser().
-
class
ly.slexer.
State
(initialParserClass)[source]¶ Bases:
object
Maintains state while parsing text.
You instantiate a State object with an initial parser class. Then you use tokens(text) to start parsing for tokens.
The state is basically a list of Parser instances; the last one is the active one. The enter() and leave() methods respectively enter a new parser or leave the current parser.
You can’t leave() the initial parser instance.
-
depth
()[source]¶ Return the number of parsers currently active (1 or more).
You can use this e.g. to keep parsing until some context ends:
tokens = state.tokens(text) # iterator depth = state.depth() for token in tokens: if state.depth() < depth: break # do something
-
enter
(parser)[source]¶ Enter a new parser.
Note: ‘parser’ is an instantiated Parser subclass. Most times this method will be called from with the update_state() method of a Token subclass (or from a Parser subclass, which is also possible: the default implementation of Token.update_state() calls Parser.update_state(), which does nothing by default).
E.g. in the Token subclass:
def update_state(self, state): state.enter(SomeDifferentParser())
-
follow
(token)[source]¶ Act as if the token has been instantiated with the current state.
You need this when you already have the parsed tokens, (e.g. cached or saved somehow) but want to know which parser created them.
This method changes state according to the token. Basically it calls the update_state() method of the token instance, but it does some more work behind the scenes to ensure that the FallthroughParser type (see below) also is handled correctly.
-
leave
()[source]¶ Leave the current parser and pop back to the previous.
The first parser (specified on instantiation) will never be left.
-
replace
(parser)[source]¶ Replace the current parser with a new one.
Somewhat equivalent to:
state.leave() state.enter(SomeDifferentParser)
But using this method you can also replace the first parser.
-
tokens
(text, pos=0)[source]¶ Parse a text string using our state info.
Yields Token instances. All tokens are a subclass of str (or unicode in Python 2.x) and have a pos and an end attribute, describing their position in the original string. If the current parser defines a ‘default’ class attribute, it is the Token subclass to use for pieces of text that would otherwise be skipped.
-
ly.document module¶
DocumentBase and Document¶
Represents a LilyPond source document (the text contents).
The Document implementation keeps the document in a (unicode) text string, but you can inherit from the DocumentBase class to support other representations of the text content.
Modifying is preferably done inside a context (the with statement), e.g.:
d = Document('some string')
with d:
d[5:5] = 'different '
d.plaintext() --> 'some different string'
Changes are applied when the context is exited, also the modified part of the document is re-tokenized. Changes may not overlap.
You may modify the document outside a context, in which case the document is re-tokenized immediately. This is much slower however when performing multiple changes after each other.
The tokens(block) method returns a tuple of tokens for the specified block. Depending on the implementation, a block describes a line in the LilyPond source document. It is not expected to have any methods, except that the ‘==’ operator is supported between two blocks, and returns True if both refer to the same line of text in the source document.
Cursor¶
Defines a range or position in a Document.
Runner¶
A Runner allows iterating back and forth over the tokens of a document.
Source¶
Iterate over tokens in a (part of a) Document, with or without state.
-
class
ly.document.
Cursor
(doc, start=0, end=None)[source]¶ Bases:
object
Defines a certain range (selection) in a Document.
You may change the start and end attributes yourself. Both must be an integer, end may also be None, denoting the end of the document.
As long as you keep a reference to the Cursor, its positions are updated when the document changes. When text is inserted at the start position, it remains the same. But when text is inserted at the end of a cursor, the end position moves along with the new text. E.g.:
d = Document('hi there, folks!') c = Cursor(d, 8, 8) with d: d[8:8] = 'new text' c.start, c.end --> (8, 16)
Many tools in the ly module use this object to describe (part of) a document.
-
blocks
()[source]¶ Iterate over the selected blocks.
If there are multiple blocks and the cursor ends on the first position of the last selected block, that block is not included.
-
document
¶
-
-
class
ly.document.
Document
(text=u'', mode=None)[source]¶ Bases:
ly.document.DocumentBase
A plain text LilyPond source document that auto-updates the tokens.
The modified attribute is set to True as soon as the document is changed, but the setplaintext() method sets it to False.
-
classmethod
load
(filename, encoding=u'utf-8', mode=None)[source]¶ Load the document from a file, using the specified encoding and mode.
-
modified
= False¶
-
classmethod
-
class
ly.document.
DocumentBase
[source]¶ Bases:
object
Abstract base class for Document instances.
You should inherit the following methods:
setplaintext __len__ __getitem__ block index position text tokens isvalid initial_state state_end apply_changes
You may inherit (e.g. to get speed improvements):
plaintext next_block previous_block blocks_forward blocks_backward state
You may use the following attributes:
filename (None) # can represent the filename of the document on disk encoding (None) # can represent the encoding of the document when reading/writing to disk
-
block
(position)[source]¶ Return the text block at the specified character position.
The text block itself has no methods, but it can be used as an argument to other methods of this class.
(Blocks do have to support the ‘==’ operator.)
-
encoding
= None¶
-
filename
= None¶
-
tokens
(block)[source]¶ Return the tuple of tokens of the specified block.
The pos and end attributes of every token point to the position of the token in the block.
-
-
class
ly.document.
Runner
(doc, tokens_with_position=False)[source]¶ Bases:
object
Iterates back and forth over tokens.
A Runner can stop anywhere and remembers its current token.
-
classmethod
at
(cursor, after_token=False, tokens_with_position=False)[source]¶ Create and init from a Cursor.
The Runner is positioned so that yielding forward starts with the first complete token after the cursor’s start position.
Set after_token to True if you want to position the cursor after the token, so that it gets yielded when you go backward.
If tokens_with_position is True, uses the tokens_with_position() method to get the tokens, else (by default), the tokens() method is used.
-
document
¶ Return our Document.
-
move_to_block
(block, at_end=False)[source]¶ Positions the Runner at the start of the given text block.
If at_end == True, the iterator is positioned past the end of the block.
-
next
(current_block=False)[source]¶ Return the next token or False if there is no more token. If current_block=True stop at the end of the current block.
-
next_block
(at_end=False)[source]¶ Go to the next block, positioning the cursor at the start by default.
Returns False if there was no next block, else True.
-
previous
(current_block=False)[source]¶ Return the previous token or False if there is no more token. If current_block=True stop at the beginning of the current block.
-
previous_block
(at_end=True)[source]¶ Go to the previous block, positioning the cursor at the end by default.
Returns False if there was no previous block, else True.
-
classmethod
-
class
ly.document.
Source
(cursor, state=None, partial=1, tokens_with_position=False)[source]¶ Bases:
object
Helper iterator.
Iterates over the (block, tokens) tuples from a Document (or a part thereof). Stores the current block in the block attribute and the tokens (which also is a generator) in the tokens attribute.
Iterating over the source object itself just yields the tokens, while the block attribute contains the current block.
You can also iterate over the tokens attribute, which will yield the remaining tokens of the current block and then stop.
If you specify a state, the tokens will update the state. If you specify state = True, the state will be taken from the document.
-
consume
(iterable, position)[source]¶ Consumes iterable (supposed to be reading from us) until position.
Returns the last token if that overlaps position.
-
document
¶ Return our Document.
-
next
()¶
-
position
(token)[source]¶ Returns the position of the token in the current block.
If the iterator was instantiated with tokens_with_position == True, this position is the same as the token.pos attribute, and the current block does not matter. (In that case you’ll probably not use this method.)
-
ly.docinfo module¶
Harvest information from a ly.document.DocumentBase instance.
-
class
ly.docinfo.
DocInfo
(doc)[source]¶ Bases:
object
Harvest information from a ly.document.DocumentBase instance.
All tokens are saved in the tokens attribute as a tuple. Newline tokens are added between all lines. All corresponding classes are in the classes attribute as a tuple. This makes quick search and access possible.
The tokens are requested from the document using the tokens_with_position() method, so you can always locate them back in the original document using their pos attribute.
DocInfo does not update when the document changes, you should just instantiate a new one.
-
count_tokens
(cls)[source]¶ Return the number of tokens that are (a subclass) of the specified class.
If you only want the number of instances of the exact class (not a subclass of) you can use info.classes.count(cls), where info is a DocInfo instance.
-
counted_tokens
()[source]¶ Return a dictionary mapping classes to the number of instances of that class.
-
document
¶
-
find
(token=None, cls=None, pos=0, endpos=-1)[source]¶ Return the index of the first specified token and/or class after pos.
If token is None, the cls should be specified. If cls is given, the token should be an instance of the specified class. If endpos is given, never searches beyond endpos. Returns -1 if the token is not found.
-
find_all
(token=None, cls=None, pos=0, endpos=-1)[source]¶ Yield all indices of the first specified token and/or class after pos.
If token is None, the cls should be specified. If cls is given, the token should be an instance of the specified class. If endpos is given, never searches beyond endpos. Returns -1 if the token is not found.
-
has_output
()[source]¶ Return True when the document probably generates output.
I.e. has notes, rests, markup or other output-generating commands.
-
output_args
()[source]¶ The list of arguments of constructs defining the name of output documents.
This looks at the bookOutputName, bookOutputSuffix and define output-suffix commands.
Every argument is a two tuple(type, argument) where type is either “suffix” or “name”.
-
range
(start=0, end=None)[source]¶ Return a new instance of the DocInfo class for the selected range.
Only the tokens completely contained within the range start..end are added to the new instance. This can be used to perform fast searches on a subset of a document.
-
ly.barcheck module¶
Add, check or remove bar checks in selected music.
ly.colorize module¶
Classes and functions to colorize (syntax-highlight) parsed source.
Highlighting is based on CSS properties and their values, although the Mapping object can map a token’s class to any object or value.
The Mapping object normally maps a token’s class basically to a CSS class and possibly a base CSS class. This way you can define base styles (e.g. string, comment, etc) and have specific classes (e.g. LilyPond string, Scheme comment) inherit from that base style. This CSS class is described by the css_class named tuple, with its three fields: mode, name, base. E.g. (‘lilypond’, ‘articulation’, ‘keyword’). The base field may be None.
The css classes are mapped to dictionaries of css properties, like {‘font-weight’: ‘bold’, ‘color’: ‘#4800ff’}, etc.
A scheme (a collection of styles) is simply a dictionary mapping the mode to a dictionary of CSS dictionaries. The base styles are in the [None] item of the scheme dictionary.
-
class
ly.colorize.
HtmlWriter
[source]¶ Bases:
object
A do-it-all object to create syntax highlighted HTML.
You can set the instance attributes to configure the behaviour in all details. Then call the html(cursor) method to get the HTML.
-
bgcolor
= None¶
-
css_mapper
= None¶
-
css_scheme
= {None: {u'function': {u'color': u'#0000c0', u'font-weight': u'bold'}, u'comment': {u'color': u'#808080', u'font-style': u'italic'}, u'string': {u'color': u'#c00000'}, u'keyword': {u'font-weight': u'bold'}, u'escape': {u'color': u'#008080'}, u'variable': {u'color': u'#0000ff'}, u'error': {u'color': u'#ff0000', u'text-decoration-color': u'#ff0000', u'text-decoration': u'underline'}, u'value': {u'color': u'#808000'}}, u'html': {}, u'lilypond': {u'lyrictext': {u'color': u'#006000'}, u'articulation': {u'color': u'#ff8000', u'font-weight': u'bold'}, u'grob': {u'color': u'#c000c0'}, u'dynamic': {u'color': u'#ff8000', u'font-weight': u'bold'}, u'fingering': {u'color': u'#ff8000'}, u'duration': {u'color': u'#008080'}, u'lyricmode': {u'color': u'#006000'}, u'stringnumber': {u'color': u'#ff8000'}, u'markup': {u'color': u'#008000', u'font-weight': u'normal'}, u'slur': {u'font-weight': u'bold'}, u'context': {u'font-weight': u'bold'}}, u'mup': {}, u'scheme': {}, u'texinfo': {}}¶
-
document_id
= u'document'¶
-
encoding
= u'UTF-8'¶
-
fgcolor
= None¶
-
full_html
= True¶
-
inline_style
= False¶
-
linenumbers_bgcolor
= u'#eeeeee'¶
-
linenumbers_fgcolor
= None¶
-
linenumbers_id
= u'linenumbers'¶
-
number_lines
= False¶
-
stylesheet_ref
= None¶
-
title
= u''¶
-
wrapper_attribute
= u'id'¶
-
wrapper_tag
= u'pre'¶
-
-
class
ly.colorize.
Mapper
[source]¶ Bases:
dict
Maps token classes to arbitrary values, which can be highlighting styles.
Mapper behaves like a dict, you set items with a token class as key to an arbitrary value.
But getting items can be done using a token. The token class’s method resolution order is walked up and the value for the first available class found in the keys is returned. The class is also cached to speed up requests for other tokens.
-
ly.colorize.
add_line_numbers
(cursor, html, linenum_attrs=None, document_attrs=None)[source]¶ Combines the html (returned by html()) with the line numbers in a HTML table.
The linenum_attrs are put in the <td> tag for the line numbers. The default value is: {“style”: “background: #eeeeee;”}. The document_attrs are put in the <td> tag for the document. The default is empty.
By default, the id for the linenumbers <td> is set to “linenumbers”, and the id for the document <td> is set to “document”.
-
ly.colorize.
css_attr
(d)[source]¶ Return a dictionary with a ‘style’ key.
The value is the style items in d formatted with css_item() joined with spaces. If d is empty, an empty dictionary is returned.
-
class
ly.colorize.
css_class
(mode, name, base)¶ Bases:
tuple
-
base
¶ Alias for field number 2
-
mode
¶ Alias for field number 0
-
name
¶ Alias for field number 1
-
-
ly.colorize.
css_dict
(css_style, scheme={None: {u'function': {u'color': u'#0000c0', u'font-weight': u'bold'}, u'comment': {u'color': u'#808080', u'font-style': u'italic'}, u'string': {u'color': u'#c00000'}, u'keyword': {u'font-weight': u'bold'}, u'escape': {u'color': u'#008080'}, u'variable': {u'color': u'#0000ff'}, u'error': {u'color': u'#ff0000', u'text-decoration-color': u'#ff0000', u'text-decoration': u'underline'}, u'value': {u'color': u'#808000'}}, u'html': {}, u'lilypond': {u'lyrictext': {u'color': u'#006000'}, u'articulation': {u'color': u'#ff8000', u'font-weight': u'bold'}, u'grob': {u'color': u'#c000c0'}, u'dynamic': {u'color': u'#ff8000', u'font-weight': u'bold'}, u'fingering': {u'color': u'#ff8000'}, u'duration': {u'color': u'#008080'}, u'lyricmode': {u'color': u'#006000'}, u'stringnumber': {u'color': u'#ff8000'}, u'markup': {u'color': u'#008000', u'font-weight': u'normal'}, u'slur': {u'font-weight': u'bold'}, u'context': {u'font-weight': u'bold'}}, u'mup': {}, u'scheme': {}, u'texinfo': {}})[source]¶ Return the css properties dict for the style, taken from the scheme.
This can be used for inline style attributes.
-
ly.colorize.
css_mapper
(mapping=None)[source]¶ Return a Mapper dict, mapping token classes to two CSS classes.
By default the mapping returned by default_mapping() is used.
-
class
ly.colorize.
css_style_attribute_formatter
(scheme={None: {u'function': {u'color': u'#0000c0', u'font-weight': u'bold'}, u'comment': {u'color': u'#808080', u'font-style': u'italic'}, u'string': {u'color': u'#c00000'}, u'keyword': {u'font-weight': u'bold'}, u'escape': {u'color': u'#008080'}, u'variable': {u'color': u'#0000ff'}, u'error': {u'color': u'#ff0000', u'text-decoration-color': u'#ff0000', u'text-decoration': u'underline'}, u'value': {u'color': u'#808000'}}, u'html': {}, u'lilypond': {u'lyrictext': {u'color': u'#006000'}, u'articulation': {u'color': u'#ff8000', u'font-weight': u'bold'}, u'grob': {u'color': u'#c000c0'}, u'dynamic': {u'color': u'#ff8000', u'font-weight': u'bold'}, u'fingering': {u'color': u'#ff8000'}, u'duration': {u'color': u'#008080'}, u'lyricmode': {u'color': u'#006000'}, u'stringnumber': {u'color': u'#ff8000'}, u'markup': {u'color': u'#008000', u'font-weight': u'normal'}, u'slur': {u'font-weight': u'bold'}, u'context': {u'font-weight': u'bold'}}, u'mup': {}, u'scheme': {}, u'texinfo': {}})[source]¶ Bases:
object
Return the inline style attribute for a specified style.
-
ly.colorize.
default_mapping
()[source]¶ Return a good default mapping from token class(es) to style and default style, per group.
-
ly.colorize.
format_css_span_class
(css_style)[source]¶ Return a string like ‘class=”mode-style base”’ for the specified style.
-
ly.colorize.
format_html_document
(body, title=u'', stylesheet=None, stylesheet_ref=None, encoding=u'UTF-8')[source]¶ Return a complete HTML document.
The body is put inside body tags unchanged. The title is html-escaped. If stylesheet_ref is given, it is put as a <link> reference in the HTML; if stylesheet is given, it is put verbatim in a <style> section in the HTML. The encoding is set in the meta http-equiv field, but the returned HTML is in normal Python unicode (python2) or str (python3) format, you should encode it yourself in the same encoding (by default utf-8) when writing it to a file.
-
ly.colorize.
format_stylesheet
(scheme={None: {u'function': {u'color': u'#0000c0', u'font-weight': u'bold'}, u'comment': {u'color': u'#808080', u'font-style': u'italic'}, u'string': {u'color': u'#c00000'}, u'keyword': {u'font-weight': u'bold'}, u'escape': {u'color': u'#008080'}, u'variable': {u'color': u'#0000ff'}, u'error': {u'color': u'#ff0000', u'text-decoration-color': u'#ff0000', u'text-decoration': u'underline'}, u'value': {u'color': u'#808000'}}, u'html': {}, u'lilypond': {u'lyrictext': {u'color': u'#006000'}, u'articulation': {u'color': u'#ff8000', u'font-weight': u'bold'}, u'grob': {u'color': u'#c000c0'}, u'dynamic': {u'color': u'#ff8000', u'font-weight': u'bold'}, u'fingering': {u'color': u'#ff8000'}, u'duration': {u'color': u'#008080'}, u'lyricmode': {u'color': u'#006000'}, u'stringnumber': {u'color': u'#ff8000'}, u'markup': {u'color': u'#008000', u'font-weight': u'normal'}, u'slur': {u'font-weight': u'bold'}, u'context': {u'font-weight': u'bold'}}, u'mup': {}, u'scheme': {}, u'texinfo': {}})[source]¶ Return a formatted stylesheet for the stylesheet scheme dictionary.
-
ly.colorize.
get_tokens
(cursor)[source]¶ Return the list of tokens for the cursor.
Tokens that are partially inside the cursor’s selection are re-created so that they fall exactly within the selection.
This can be used to convert a highlighted part of a document to e.g. HTML.
-
ly.colorize.
html
(cursor, mapper, span=<function format_css_span_class>)[source]¶ Return a HTML string with the tokens wrapped in <span class=> elements.
The span argument is a function returning an attribute for the <span> tag for the specified style. By default the format_css_span_class() function is used, that returns a ‘class=”group style base”’ string. You’ll want to wrap the HTML inside <pre> tokens and add a CSS stylesheet.
-
ly.colorize.
html_format_attrs
(d)[source]¶ Format the attributes dict as a string.
The attributes are escaped correctly. A space is prepended for every assignment.
-
ly.colorize.
map_tokens
(cursor, mapper)[source]¶ Yield a two-tuple(token, style) for every token.
The style is what mapper[token] returns. Style may be None, which also happens with unparsed (not-tokenized) text.
ly.cursortools module¶
Routines manipulating ly.document.Cursor instances.
ly.dom module¶
This module is deprecated. When ly.music is able to generate LilyPond code from scratch, this module will be removed.
LilyPond DOM
(c) 2008-2011 Wilbert Berendsen License: GPL.
A simple Document Object Model for LilyPond documents.
The purpose is to easily build a LilyPond document with good syntax, not to fully understand all features LilyPond supports. (This DOM does not enforce a legal LilyPond file.)
All elements of a LilyPond document inherit Node.
Note: elements keep a weak reference to their parent.
-
class
ly.dom.
AddLyrics
(parent=None)[source]¶ Bases:
ly.dom.InputLyrics
-
after
= 1¶
-
before
= 1¶
-
may_remove_brackets
= False¶
-
name
= u'addlyrics'¶
-
-
class
ly.dom.
Assignment
(name=None, parent=None, valueObj=None)[source]¶ Bases:
ly.dom.Container
A varname = value construct with it’s value as its first child The name can be a string or a Reference object: so that everywhere where this varname is referenced, the name is the same.
-
after
= 1¶
-
before
= 1¶
-
-
class
ly.dom.
BlankLine
(parent=None)[source]¶ Bases:
ly.dom.Newline
A blank line.
-
before
= 1¶
-
-
class
ly.dom.
Block
(parent=None)[source]¶ Bases:
ly.dom.Container
A vertical container type that puts everything on a new line.
-
after
= 1¶
-
before
= 1¶
-
defaultSpace
= u'\n'¶
-
-
class
ly.dom.
BlockComment
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Comment
A block comment between %{ and %}
-
after
¶
-
before
¶
-
-
class
ly.dom.
Book
(parent=None)[source]¶ Bases:
ly.dom.Section
-
name
= u'book'¶
-
-
class
ly.dom.
BookPart
(parent=None)[source]¶ Bases:
ly.dom.Section
-
name
= u'bookpart'¶
-
-
class
ly.dom.
ChoirStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Chord
(parent=None)[source]¶ Bases:
ly.dom.Container
A chord containing one of more Pitches and optionally one Duration. This is a bit of a hack, awaiting real music object support.
-
class
ly.dom.
ChordMode
(parent=None)[source]¶ Bases:
ly.dom.InputMode
-
name
= u'chordmode'¶
-
-
class
ly.dom.
ChordNames
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Clef
(clef, parent=None)[source]¶ Bases:
ly.dom.Leaf
A clef.
-
class
ly.dom.
Command
(name, parent=None)[source]¶ Bases:
ly.dom.Statement
Use this to create a LilyPond command supplying the name (or a Reference) when instantiating.
-
class
ly.dom.
CommandEnclosed
(name, parent=None)[source]¶ Bases:
ly.dom.StatementEnclosed
Use this to print LilyPond commands that have a single bracket-enclosed list of arguments. The command name is supplied to the constructor.
-
class
ly.dom.
Comment
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Text
A LilyPond comment at the end of a line
-
after
= 1¶
-
-
class
ly.dom.
Container
(parent=None)[source]¶ Bases:
ly.dom.LyNode
A node that concatenates its children on output
-
after
¶
-
before
¶
-
defaultSpace
= u' '¶
-
-
class
ly.dom.
Context
(contextName=u'', parent=None)[source]¶ Bases:
ly.dom.HandleVars
,ly.dom.Section
A context section for use inside Layout or Midi sections.
-
name
= u'context'¶
-
-
class
ly.dom.
ContextName
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Text
Used to print a context name, like Score.
-
class
ly.dom.
ContextProperty
(prop, context=None, parent=None)[source]¶ Bases:
ly.dom.Leaf
A Context.property or Context.layoutObject construct. Call e.g. ContextProperty(‘aDueText’, ‘Staff’) to get ‘Staff.aDueText’.
-
class
ly.dom.
ContextType
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.Container
new or context Staff = ‘bla’ with { } << music >>
A with (With) element is added automatically as the first child as soon as you use our convenience methods that manipulate the variables in with. If the with element is empty, it does not print anything. You should add one other music object to this.
-
addInstrumentNameEngraverIfNecessary
()[source]¶ Adds the Instrument_name_engraver to the node if it would need it to print instrument names.
-
after
= 1¶
-
before
= 1¶
-
ctype
= None¶
-
isAtom
= True¶
-
-
class
ly.dom.
CueVoice
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Devnull
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Document
(parent=None)[source]¶ Bases:
ly.dom.Container
A container type that puts everything on a new line. To be used as a full LilyPond document.
-
after
= 1¶
-
defaultSpace
= u'\n'¶
-
-
class
ly.dom.
DrumMode
(parent=None)[source]¶ Bases:
ly.dom.InputMode
-
name
= u'drummode'¶
-
-
class
ly.dom.
DrumStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
DrumVoice
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Duration
(dur, dots=0, factor=1, parent=None)[source]¶ Bases:
ly.dom.Leaf
A duration with duration (in logarithmic form): (-2 … 8), where -2 = longa, -1 = breve, 0 = 1, 1 = 2, 2 = 4, 3 = 8, 4 = 16, etc, dots (number of dots), factor (Fraction giving the scaling of the duration).
-
class
ly.dom.
Dynamics
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Enclosed
(parent=None)[source]¶ Bases:
ly.dom.Container
Encloses all children between brackets: { … } If may_remove_brackets is True in subclasses, the brackets are removed if there is only one child and that child is an atom (i.e. a single LilyPond expression.
-
after
= 0¶
-
before
= 0¶
-
isAtom
= True¶
-
may_remove_brackets
= False¶
-
post
= u'}'¶
-
pre
= u'{'¶
-
-
class
ly.dom.
FigureMode
(parent=None)[source]¶ Bases:
ly.dom.InputMode
-
name
= u'figuremode'¶
-
-
class
ly.dom.
FiguredBass
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
FretBoards
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Global
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
GrandStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
GregorianTranscriptionStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
GregorianTranscriptionVoice
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
HandleVars
[source]¶ Bases:
object
A powerful mixin class to facilitate handling unique variable assignments inside a Container more. E.g.: >>> h = Header() >>> h[‘composer’] = “Johann Sebastian Bach” creates a subnode (by default Assignment) with the name ‘composer’, and that node again gets an autogenerated subnode of type QuotedString (if the argument wasn’t already a Node).
-
childClass
¶ alias of
Assignment
-
-
class
ly.dom.
Header
(parent=None)[source]¶ Bases:
ly.dom.HandleVars
,ly.dom.Section
-
name
= u'header'¶
-
-
class
ly.dom.
Identifier
(name=None, parent=None)[source]¶ Bases:
ly.dom.Leaf
An identifier, prints as name. Name may be a string or a Reference object.
-
isAtom
= True¶
-
-
class
ly.dom.
Include
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Line
a LilyPond include statement
-
class
ly.dom.
InnerChoirStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
InnerStaffGroup
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
InputChords
(parent=None)[source]¶ Bases:
ly.dom.ChordMode
-
name
= u'chords'¶
-
-
class
ly.dom.
InputDrums
(parent=None)[source]¶ Bases:
ly.dom.DrumMode
-
name
= u'drums'¶
-
-
class
ly.dom.
InputFigures
(parent=None)[source]¶ Bases:
ly.dom.FigureMode
-
name
= u'figures'¶
-
-
class
ly.dom.
InputLyrics
(parent=None)[source]¶ Bases:
ly.dom.LyricMode
-
name
= u'lyrics'¶
-
-
class
ly.dom.
InputMode
(parent=None)[source]¶ Bases:
ly.dom.StatementEnclosed
The abstract base class for input modes such as lyricmode/lyrics, chordmode/chords etc.
-
class
ly.dom.
InputNotes
(parent=None)[source]¶ Bases:
ly.dom.NoteMode
-
name
= u'notes'¶
-
-
class
ly.dom.
KeySignature
(note=0, alter=0, mode=u'major', parent=None)[source]¶ Bases:
ly.dom.Leaf
A key signature expression, like:
key c major The pitch should be given in the arguments note and alter and is written out in the document’s language.
-
class
ly.dom.
Layout
(parent=None)[source]¶ Bases:
ly.dom.HandleVars
,ly.dom.Section
-
name
= u'layout'¶
-
-
class
ly.dom.
Leaf
(parent=None)[source]¶ Bases:
ly.dom.LyNode
A leaf node without children
-
class
ly.dom.
Line
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Text
A text node that claims its own line.
-
after
= 1¶
-
before
= 1¶
-
-
class
ly.dom.
LineComment
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Comment
A LilyPond comment that takes a full line
-
before
= 1¶
-
-
class
ly.dom.
LyNode
(parent=None)[source]¶ Bases:
ly.node.WeakNode
Base class for LilyPond objects, based on Node, which takes care of the tree structure.
-
after
= 0¶
-
before
= 0¶
-
concat
(other)[source]¶ Returns a string with newlines to concat this node to another one. If zero newlines are requested, an empty string is returned.
-
isAtom
= False¶
-
-
class
ly.dom.
LyricMode
(parent=None)[source]¶ Bases:
ly.dom.InputMode
-
name
= u'lyricmode'¶
-
-
class
ly.dom.
Lyrics
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
LyricsTo
(cid, parent=None)[source]¶ Bases:
ly.dom.LyricMode
-
name
= u'lyricsto'¶
-
-
class
ly.dom.
Mark
(parent=None)[source]¶ Bases:
ly.dom.Statement
The mark command.
-
name
= u'mark'¶
-
-
class
ly.dom.
Markup
(parent=None)[source]¶ Bases:
ly.dom.StatementEnclosed
The markup command. You can add many children, in that case Markup automatically prints { and } around them.
-
name
= u'markup'¶
-
-
class
ly.dom.
MarkupCommand
(name, parent=None)[source]¶ Bases:
ly.dom.Command
A markup command with more or no arguments, that does not auto-enclose its arguments. Useful for commands like note-by-number or hspace.
You must supply the name. Its arguments are its children. If one argument can be a markup list, use a Enclosed() construct for that.
-
class
ly.dom.
MarkupEnclosed
(name, parent=None)[source]¶ Bases:
ly.dom.CommandEnclosed
A markup that auto-encloses all its arguments, like ‘italic’, ‘bold’ etc. You must supply the name.
-
class
ly.dom.
MensuralStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
MensuralVoice
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Midi
(parent=None)[source]¶ Bases:
ly.dom.HandleVars
,ly.dom.Section
-
name
= u'midi'¶
-
-
class
ly.dom.
Named
[source]¶ Bases:
object
Mixin to print a name before the contents of the container. format() is called on the self.name attribute, so it may also be a Reference.
-
name
= u''¶
-
-
class
ly.dom.
Newline
(parent=None)[source]¶ Bases:
ly.dom.LyNode
A newline.
-
after
= 1¶
-
-
class
ly.dom.
NoteMode
(parent=None)[source]¶ Bases:
ly.dom.InputMode
-
name
= u'notemode'¶
-
-
class
ly.dom.
NoteNames
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Paper
(parent=None)[source]¶ Bases:
ly.dom.HandleVars
,ly.dom.Section
-
name
= u'paper'¶
-
-
class
ly.dom.
Partial
(dur, dots=0, factor=1, parent=None)[source]¶ Bases:
ly.dom.Named
,ly.dom.Duration
partial <duration> You should add a Duration element
-
after
= 1¶
-
before
= 1¶
-
name
= u'partial'¶
-
-
class
ly.dom.
PianoStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Pitch
(octave=0, note=0, alter=0, parent=None)[source]¶ Bases:
ly.dom.Leaf
A pitch with octave, note, alter. octave is specified by an integer, zero for the octave containing middle C. note is a number from 0 to 6, with 0 corresponding to pitch C and 6 corresponding to pitch B. alter is the number of whole tones for alteration (can be int or Fraction)
-
class
ly.dom.
Printer
[source]¶ Bases:
object
Performs certain operations on behalf of a LyNode tree, like quoting strings or translating pitch names, etc.
-
indentGen
(node, startIndent=0)[source]¶ A generator that walks on the output of the given node, and returns properly indented LilyPond code.
-
primary_quote_left
= u'\u2018'¶
-
primary_quote_right
= u'\u2019'¶
-
secondary_quote_left
= u'\u201c'¶
-
secondary_quote_right
= u'\u201d'¶
-
-
class
ly.dom.
QuotedString
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Text
A string that is output inside double quotes.
-
isAtom
= True¶
-
-
class
ly.dom.
Reference
(name=u'')[source]¶ Bases:
object
A simple object that keeps a name, to use as a (context) identifier. Set the name attribute to the name you want to display, and on all places in the document the name will show up.
-
class
ly.dom.
Relative
(parent=None)[source]¶ Bases:
ly.dom.Statement
relative <pitch> music
You should add a Pitch (optionally) and another music object, e.g. Sim or Seq, etc.
-
name
= u'relative'¶
-
-
class
ly.dom.
RhythmicStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Scheme
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Text
A Scheme expression, without the extra # prepended
-
isAtom
= True¶
-
-
class
ly.dom.
SchemeLily
(parent=None)[source]¶ Bases:
ly.dom.Enclosed
A LilyPond expression between #{ #} (inside scheme)
-
post
= u'#}'¶
-
pre
= u'#{'¶
-
-
class
ly.dom.
SchemeList
(parent=None)[source]¶ Bases:
ly.dom.Enclosed
A list of items enclosed in parentheses
-
post
= u')'¶
-
pre
= u'('¶
-
-
class
ly.dom.
Score
(parent=None)[source]¶ Bases:
ly.dom.Section
-
name
= u'score'¶
-
-
class
ly.dom.
ScoreContext
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
Represents the Score context in LilyPond, but the name would collide with the Score class that represents score { } constructs.
Because the latter is used more often, use ScoreContext to get new Score etc.
-
ctype
= u'Score'¶
-
-
class
ly.dom.
Section
(parent=None)[source]¶ Bases:
ly.dom.StatementEnclosed
Very much like a Statement. Use as base class for book { }, score { } etc. By default never removes the brackets and always starts on a new line.
-
after
= 1¶
-
before
= 1¶
-
may_remove_brackets
= False¶
-
-
class
ly.dom.
Seq
(parent=None)[source]¶ Bases:
ly.dom.Enclosed
An SequentialMusic expression between { }
-
post
= u'}'¶
-
pre
= u'{'¶
-
-
class
ly.dom.
Seqr
(parent=None)[source]¶ Bases:
ly.dom.Seq
-
may_remove_brackets
= True¶
-
-
class
ly.dom.
Sim
(parent=None)[source]¶ Bases:
ly.dom.Enclosed
An SimultaneousMusic expression between << >>
-
post
= u'>>'¶
-
pre
= u'<<'¶
-
-
class
ly.dom.
Simr
(parent=None)[source]¶ Bases:
ly.dom.Sim
-
may_remove_brackets
= True¶
-
-
class
ly.dom.
Staff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
StaffGroup
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Statement
(parent=None)[source]¶ Bases:
ly.dom.Named
,ly.dom.Container
Base class for statements with arguments. The statement is read in the name attribute, the arguments are the children.
-
before
= 0¶
-
isAtom
= True¶
-
-
class
ly.dom.
StatementEnclosed
(parent=None)[source]¶ Bases:
ly.dom.Named
,ly.dom.Enclosed
Base class for LilyPond commands that have a single bracket-enclosed list of arguments.
-
may_remove_brackets
= True¶
-
-
class
ly.dom.
TabStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
TabVoice
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Tempo
(duration, value, parent=None)[source]¶ Bases:
ly.dom.Container
A tempo setting, like: tempo 4 = 100 May have a child markup or quoted string.
-
after
= 1¶
-
before
= 1¶
-
-
class
ly.dom.
Text
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Leaf
A leaf node with arbitrary text
-
class
ly.dom.
TextDur
(text=u'', parent=None)[source]¶ Bases:
ly.dom.AddDuration
,ly.dom.Text
A text note with an optional duration as child.
-
class
ly.dom.
TimeSignature
(num, beat, parent=None)[source]¶ Bases:
ly.dom.Leaf
A time signature, like: time 4/4
-
class
ly.dom.
Transposition
(parent=None)[source]¶ Bases:
ly.dom.Statement
transposition <pitch> You should add a Pitch.
-
name
= u'transposition'¶
-
-
class
ly.dom.
UserContext
(ctype, cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
Represents a context the user creates. e.g. new MyStaff = cid << music >>
-
class
ly.dom.
VaticanaStaff
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
VaticanaVoice
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
Version
(text=u'', parent=None)[source]¶ Bases:
ly.dom.Line
a LilyPond version instruction
-
class
ly.dom.
Voice
(cid=None, new=True, parent=None)[source]¶ Bases:
ly.dom.ContextType
-
class
ly.dom.
VoiceSeparator
(parent=None)[source]¶ Bases:
ly.dom.Leaf
A Voice Separator: \
-
class
ly.dom.
With
(parent=None)[source]¶ Bases:
ly.dom.HandleVars
,ly.dom.Section
If this item has no children, it prints nothing.
-
after
= 0¶
-
before
= 0¶
-
name
= u'with'¶
-
ly.duration module¶
LilyPond information and logic concerning durations
-
ly.duration.
base_scaling
(tokens)[source]¶ Return (base, scaling) as two Fractions for the list of tokens.
-
ly.duration.
base_scaling_string
(duration)[source]¶ Return (base, scaling) as two Fractions for the specified string.
ly.etreeutil module¶
Utility functions for use with xml.etree.ElementTree.
ly.indent module¶
Indent and auto-indent.
-
class
ly.indent.
Indenter
[source]¶ Bases:
object
-
compute_indent
(document, block)[source]¶ Return the indent the specified block should have.
Returns False if the block is not indentable, e.g. when it is part of a multiline string.
This method is used to determine the indent of one line, and just looks to previous lines, copying the indent of the line where the current indent depth starts, and/or adding a level of indent or alignment space.
Use this method only for one line or the first of a group you’re indenting.
-
get_indent
(document, block)[source]¶ Return the indent the block currently has.
Returns False if the block is not indentable, e.g. when it is part of a multiline string.
-
indent
(cursor, indent_blank_lines=False)[source]¶ Indent all lines in the cursor’s range.
If indent_blank_lines is True, the indent of blank lines is made larger if necessary. If False (the default), the indent of blank lines if not changed if it is shorter than it should be.
-
indent_tabs
= False¶
-
indent_width
= 2¶
-
ly.node module¶
The Node class.
(c) 2008-2011 Wilbert Berendsen License: GPL.
This module contains the Node class that can be used as a simple DOM (Document Object Model) for building a tree structure.
A Node has children with list-like access methods and keeps also a reference to its parent. A Node can have one parent; appending a Node to another Node causes it to be removed from its parent node (if any).
To iterate over the children of a Node:
for n in node:
do_something(n)
To get the list of children of a Node:
children = list(node)
Of course you can get the children directly using:
child = node[3]
You should inherit from Node to make meaningful tree node types, e.g. to add custom attributes or multiple sub-types.
A WeakNode class is provided as well, which uses a weak reference to the parent, so that no cyclic references are created which might improve garbage collection.
-
class
ly.node.
Node
(parent=None)[source]¶ Bases:
object
A list-like class to build tree structures with.
-
append
(node)[source]¶ Append a node to the current node.
It will be reparented, that means it will be removed from it’s former parent if it had one.
-
find
(cls, depth=-1)[source]¶ Yield all descendants if they are an instance of cls.
cls may also be a tuple of classes. This method uses iter_depth().
-
find_child
(cls, depth=-1)[source]¶ Return the first descendant that’s an instance of cls.
cls may also be a tuple of classes. This method uses iter_rings().
-
find_children
(cls, depth=-1)[source]¶ Yield all descendants if they are an instance of cls.
cls may also be a tuple of classes. This method uses iter_rings().
-
find_parent
(cls)[source]¶ Find an ancestor that’s an instance of the given class.
cls may also be a tuple of classes.
-
iter_depth
(depth=-1)[source]¶ Iterate over all the children, and their children, etc.
Set depth to restrict the search to a certain depth, -1 is unrestricted.
-
iter_rings
(depth=-1)[source]¶ Iterate over the children in rings, depth last.
This method returns the closest descendants first. Set depth to restrict the search to a certain depth, -1 is unrestricted.
-
next_sibling
()[source]¶ Return the sibling object just after us in our parents list.
Returns None if this is the last child, or if we have no parent.
-
previous_sibling
()[source]¶ Return the sibling object just before us in our parents list.
Returns None if this is the first child, or if we have no parent.
-
-
class
ly.node.
WeakNode
(parent=None)[source]¶ Bases:
ly.node.Node
A Node type using a weak reference to the parent.
ly.pkginfo module¶
Meta-information about the LY package.
This information is used by the install script, and also for the
command ly --version
.
-
ly.pkginfo.
name
= u'python-ly'¶ name of the package
-
ly.pkginfo.
version
= u'0.9.5'¶ the current version
-
ly.pkginfo.
description
= u'Tool and library for manipulating LilyPond files'¶ short description
-
ly.pkginfo.
long_description
= u'The python-ly package provides a Python library and a commandline tool that can be used to parse and manipulate LilyPond source files.'¶ long description
-
ly.pkginfo.
maintainer
= u'Wilbert Berendsen'¶ maintainer name
-
ly.pkginfo.
maintainer_email
= u'info@frescobaldi.org'¶ maintainer email
-
ly.pkginfo.
url
= u'https://github.com/wbsoft/python-ly'¶ homepage
-
ly.pkginfo.
license
= u'GPL'¶ license
ly.reformat module¶
Formatting tools to improve the readability of a ly.document.Document without changing the semantic meaning of the LilyPond source.
Basically the tools only change whitespace to make the source-code more readable.
See also ly.indent.
-
ly.reformat.
break_indenters
(cursor)[source]¶ Add newlines around indent and dedent tokens where needed.
If there is stuff after a { or << (that’s not closed on the same line) it is put on a new line, and if there if stuff before a } or >>, the } or >> is put on a new line.
It is necessary to run the indenter again over the same part of the document, as it will look garbled with the added newlines.
-
ly.reformat.
move_long_comments
(cursor)[source]¶ Move line comments with more than 2 comment characters to column 0.
ly.rhythm module¶
Implementation of the tools to edit durations of selected music.
Durations are represented simply by lists of ly.lex.lilypond.Duration tokens.
All functions expect a ly.document.Cursor with the selected range.
-
class
ly.rhythm.
music_item
(tokens, dur_tokens, may_remove, insert_pos, pos, end)¶ Bases:
tuple
-
dur_tokens
¶ Alias for field number 1
-
end
¶ Alias for field number 5
-
insert_pos
¶ Alias for field number 3
-
may_remove
¶ Alias for field number 2
-
pos
¶ Alias for field number 4
-
tokens
¶ Alias for field number 0
-
-
ly.rhythm.
music_items
(cursor, command=False, chord=False, partial=1)[source]¶ Yield music_item instances describing rests, skips or pitches.
cursor is a ly.document.Cursor instance.
The following keyword arguments can be used:
- command: whether to allow pitches in \relative, \transpose, etc.
- chord: whether to allow pitches inside chords.
- partial: ly.document.INSIDE (default), PARTIAL or OUTSIDE. See the documentation of ly.document.Source.__init__().
-
ly.rhythm.
music_tokens
(source, command=False, chord=False)[source]¶ DEPRECATED. Yield lists of tokens describing rests, skips or pitches.
source is a ly.document.Source instance following the state.
The following keyword arguments can be used:
- command: whether to allow pitches in \relative, \transpose, etc.
- chord: whether to allow pitches inside chords.
This function is deprecated and will be removed. You should use music_items() instead.
-
ly.rhythm.
preceding_duration
(cursor)[source]¶ Return a preceding duration before the cursor, or an empty list.
-
ly.rhythm.
rhythm_implicit_per_line
(cursor)[source]¶ Remove reoccurring durations, but always write one on a new line.
-
ly.rhythm.
rhythm_overwrite
(cursor, durations)[source]¶ Apply a list of durations to the cursor’s range.
The durations list looks like [“4”, “8”, “”, “16.”,] etc.
-
ly.rhythm.
rhythm_remove_fraction_scaling
(cursor)[source]¶ Remove the scaling containing fractions (like
*1/3
) from all durations.
ly.util module¶
Utility functions.
-
ly.util.
int2letter
(number, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ')[source]¶ Converts an integer to one or more letters.
E.g. 1 -> A, 2 -> B, … 26 -> Z, 27 -> AA, etc. Zero returns the empty string.
chars is the string to pick characters from, defaulting to string.ascii_uppercase.
-
ly.util.
int2roman
(n)[source]¶ Convert an integer value to a roman number string.
E.g. 1 -> “I”, 12 -> “XII”, 2015 -> “MMXV”
n has to be > 1.
-
ly.util.
int2text
(number)[source]¶ Converts an integer to the English language name of that integer.
E.g. converts 1 to “One”. Supports numbers 0 to 999999. This can be used in LilyPond identifiers (that do not support digits).
-
ly.util.
mkid
(*args)[source]¶ Makes a lower-camel-case identifier of the strings in args.
All strings are concatenated with the first character of every string uppercased, except for the first character, which is lowercased.
Examples:
mkid("Violin") ==> "violin" mkid("soprano", "verse") ==> "sopranoVerse" mkid("scoreOne", "choirII") ==> "scoreOneChoirII"
ly.words module¶
LilyPond reserved words for auto completion and highlighting.