
    rh                      S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSKJ	r	   " S S\R                  5      r " S	 S
\	R                  5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S \5      r " S! S"\5      r " S# S$\5      r " S% S&\5      r " S' S(\5      r " S) S*\5      r " S+ S,\5      r " S- S.\5      r " S/ S0\5      r  " S1 S2\5      r! " S3 S4\5      r" " S5 S6\5      r# " S7 S8\5      r$ " S9 S:\5      r% " S; S<\5      r& " S= S>\5      r' " S? S@\5      r( " SA SB\5      r) " SC SD\5      r* " SE SF\5      r+ " SG SH\5      r, " SI SJ\5      r- " SK SL\5      r. " SM SN\5      r/ " SO SP\5      r0 " SQ SR\5      r1 " SS ST\5      r2 " SU SV\5      r3 " SW SX\5      r4 " SY SZ\5      r5 " S[ S\\5      r6 " S] S^\5      r7 " S_ S`\5      r8 " Sa Sb\5      r9 " Sc Sd\5      r: " Se Sf\5      r; " Sg Sh\5      r< " Si Sj\5      r= " Sk Sl\5      r> " Sm Sn\5      r? " So Sp\5      r@ " Sq Sr\5      rA " Ss St\5      rB " Su Sv\5      rC " Sw Sx\5      rD " Sy Sz\5      rE " S{ S|\5      rF " S} S~\5      rG " S S\5      rH " S S\5      rI " S S\5      rJ " S S\5      rK " S S\5      rL " S S\5      rM " S S\5      rN " S S\5      rO " S S\5      rP " S S\5      rQ " S S\5      rR " S S\5      rS " S S\5      rT " S S\5      rU " S S\5      rV " S S\5      rW " S S\5      rX " S S\5      rY " S S\5      rZ " S S\5      r[ " S S\5      r\ " S S\5      r] " S S\5      r^ " S S\5      r_ " S S\R                  5      ra\bS:X  a  SSKr\R                  " \a5        gg)a   
music21 translates to Lilypond format and if Lilypond is installed on the
local computer, can automatically generate .pdf, .png, and .svg versions
of musical files using Lilypond.

The Grammar for Lilypond comes from
http://lilypond.org/doc/v2.14/Documentation/notation/lilypond-grammar
    )annotationsN)common)exceptions21)prebasec                      \ rS rSrSrg)LilyObjectsException    N)__name__
__module____qualname____firstlineno____static_attributes__r
       R/home/james-whalen/.local/lib/python3.13/site-packages/music21/lily/lilyObjects.pyr   r      s    r   r   c                      \ rS rSr% Sr/ rS\S'   0 rS\S'   0 rS\S'   S	r	S
 r
S rS rS rS rSS jr\S 5       rS rS rSS jrS rS rS rS rS rS rSS jrSrg) LyObject"   zx
LyObject is the base class of all other Lily Objects

>>> lyo = lily.lilyObjects.LyObject()
>>> lyo.stringOutput()
''

zlist[object]supportedClasseszdict[str, dict]m21toLyzdict[str, t.Any]defaultAttributes\c                f    0 U l         S U l        SU l        S U l        S U l        S U l        S U l        g Nr   )lilyAttributes_parent
thisIndent	markupToplyricMarkupOrIdentifiermarkupListOrIdentifiermarkupTopOrIdentifierselfs    r   __init__LyObject.__init__0   s7     '+$&*#%)"r   c                4   [        U[        5      (       a  UR                  U 5        O[[        R                  " U5      (       a@  U H:  n[        U[        5      (       d  M  UR
                  b  M)  UR                  U 5        M<     [        R                  XU5        g N)
isinstancer   	setParentr   
isIterabler   object__setattr__)r#   namevaluevs       r   r,   LyObject.__setattr__;   sk    eX&&OOD!u%%a**yy(D) 
 	4u-r   c                b    U R                   b"  [        R                  " U R                   5      nU$ g r'   )r   r   unwrapWeakref)r#   actualParents     r   	getParentLyObject.getParentF   s+    <<#!//=L $r   c                :    [         R                  " U5      U l        g r'   )r   wrapWeakrefr   )r#   parentObjects     r   r)   LyObject.setParentK   s    )),7r   c                |    / nU R                  5       nUb&  UR                  U5        UR                  5       nUb  M&  U$ )zG
returns a list of all unwrapped parent objects for the current object
)r4   append)r#   	ancestorscurrentParents      r   ancestorListLyObject.ancestorListN   sG     	(']+)335M ' r   c                v    SnU R                  5        H#  n[        XA5      (       d  M  X2:X  a  Us  $ US-  nM%     g )N   )r>   r(   )r#   classObjgetAncestorNumbercurrentIteras        r   getAncestorByClassLyObject.getAncestorByClassY   s?    ""$A!&&3H1$K % r   c                L    U R                  5       n[        U5      nSU-  nSU-   $ )N 
)r>   len)r#   r<   totalIndentsindentSpacess       r   newlineIndentLyObject.newlineIndentc   s2     %%'	 9~\)l""r   c                    SnSnU R                    H-  nXAR                  ;   d  US:X  d  M  U R                  XA5      nSn  O   USL a  [        SU SU R                    3-   5      eU$ )a  
Returns a dictionary and sets self.lilyAttributes to that dictionary, for a m21Object
of class classLookup using the mapping of self.m21toLy[classLookup]

>>> class Mock(base.Music21Object):
...     pass
>>> m = Mock()
>>> m.mockAttribute = 32
>>> m.mockAttribute2 = None

>>> lm = lily.lilyObjects.LyMock()

LyMock (our test class) defines mappings for two classes:
to LyMock.lilyAttributes:

>>> print(lm.supportedClasses)
[...'Mock', ...'Mocker']

Thus, we can get attributes from the Mock class (see `setAttributesFromClassObject`):

>>> lilyAttributes = lm.setAttributes(m)
>>> for x in sorted(lilyAttributes.keys()):
...    print(f'{x}: {lilyAttributes[x]}')
mock-attribute: 32
mock-attribute-2: None

>>> lilyAttributes is lm.lilyAttributes
True
NF*T*Could not support setting attributes from z: supported classes: )r   classessetAttributesFromClassObjectr   )r#   	m21Objectattrs
foundClasstryClasss        r   setAttributesLyObject.setAttributesm   s    < 
--H,,,C99(N!
	 . &<K4T5J5J4KLMN N r   c                0   XR                   ;  a  [        SU S3-   S-   5      eU R                   U   nU H!  n [        X$5      nX4   nXPR
                  U'   M#     U R
                  $ ! [         a%    X@R                  ;   a  U R                  U   n NLSn NPf = f)a  
Returns a dictionary and sets self.lilyAttributes to that dictionary, for a m21Object
of class classLookup using the mapping of self.m21toLy[classLookup]


>>> class Mock(base.Music21Object): pass
>>> m = Mock()
>>> lm = lily.lilyObjects.LyMock()

LyMock (our test class) defines certain mappings from the m21 Mock class
to LyMock.lilyAttributes:

>>> for x in sorted(lm.m21toLy['Mock'].keys()):
...    print(f"{x}: {lm.m21toLy['Mock'][x]}")
mockAttribute: mock-attribute
mockAttribute2: mock-attribute-2


Some of these attributes have defaults:

>>> for x in sorted(lm.defaultAttributes.keys()):
...    print(f'{x}: {lm.defaultAttributes[x]}')
mockAttribute2: 7


>>> m.mockAttribute = 'hello'
>>> lilyAttributes = lm.setAttributesFromClassObject('Mock', m)
>>> for x in sorted(lilyAttributes.keys()):
...    print(f'{x}: {lilyAttributes[x]}')
mock-attribute: hello
mock-attribute-2: 7

>>> lilyAttributes is lm.lilyAttributes
True
rR   z error in self.m21toLy,z% missing class definitions and no "*"N)r   r   getattrAttributeErrorr   r   )r#   classLookuprU   	classDictm21Attributer.   lyAttributes          r   rT   %LyObject.setAttributesFromClassObject   s    H ll*&<K6789:; ; LL-	%L!	8 $1K/4, & """ " !#9#99 22<@E E	!s   A&&(BBBc                n    [        U 5      nUR                  SS5        [        U5      S:  a  US S S-   nU$ )NrJ   z     
   z...)strreplacerK   )r#   msgs     r   _reprInternalLyObject._reprInternal   s9    $iD$s8r>cr(U"C
r   c                J    U R                  5       nUR                  SS5      nU$ )Nz

rJ   )stringOutputrg   )r#   sos     r   __str__LyObject.__str__   s%     ZZ%	r   c                    gN r
   r"   s    r   rl   LyObject.stringOutput   s    r   c                H    U H  n[        X5      c  M  [        X5      s  $    g r'   )r\   )r#   attributeListrE   s      r   getFirstNonNoneAttribute!LyObject.getFirstNonNoneAttribute   s'    At+t''  r   c                \    SnU H#  nUc  M  U[        U5      U R                  -   -  nM%     U$ rq   )rf   rN   )r#   contentscns       r   $newlineSeparateStringOutputIfNotNone-LyObject.newlineSeparateStringOutputIfNotNone   s9    AyQ$,,,,A 
 r   c                N   [        U[        5      (       aO  U R                  R                  U5      nSR                  SU R                  X R                  SU R                  /5      $ Ub>  SR                  SU R                  [	        U5      U R                  SU R                  /5      $ g)Nrr    {  } z { } )r(   listrN   joinrf   )r#   argstrArgs      r   encloseCurlyLyObject.encloseCurly   s    c4  '',,S1F77E4#5#5v?Q?Q!4#5#57 8 8_77E4#5#5s3xASAS!4#5#57 8 8 r   c                6    UR                  SS5      nSU-   S-   $ )z
returns a string that is quoted with
internal quotation marks backslash'd out
and an extra space at the end.

>>> m = lily.lilyObjects.LyObject()
>>> print(m.quoteString(r'Hello "there"!'))
"Hello \"there\"!"
"z\"z" )rg   )r#   stringIn	stringNews      r   quoteStringLyObject.quoteString   s%     $$S%0	Y%%r   c                .    SUR                  5       -   S-   $ )zp
returns a comment that is %{ stringIn.strip() %}

(Don't put %} etc. in comments -- it will break the system.)
z %{ z %} )strip)r#   r   s     r   commentLyObject.comment  s     ((611r   )r   r   r   r    r   r!   r   N)rA   )returnrf   )r   rf   r   rf   )r   r   r   r   __doc__r   __annotations__r   r   	backslashr$   r,   r4   r)   r>   rF   propertyrN   rY   rT   ri   rn   rl   rv   r|   r   r   r   r   r
   r   r   r   r   "   s     &(l'!G_!*,',I*	. 
8	 # #*X5#n
	&2r   r   c                  >    \ rS rSrSrSS/rSSS.SSS.S	.rS
S0rSrg)LyMocki  z?
A test object for trying various music21 to Lily conversions

MockMockerzmock-attributezmock-attribute-2)mockAttributemockAttribute2)mockerAttributegreg)r   r   r      r
   N)	r   r   r   r   r   r   r   r   r   r
   r   r   r   r     sB     ))9+= .>"48G *1 r   r   c                  >   ^  \ rS rSrSr/ SQrSU 4S jjrS rSrU =r	$ )LyLilypondTopi!  a  
corresponds to the highest level lilypond object in Appendix C:

::

  `lilypond: /* empty */
         | lilypond toplevel_expression
         | lilypond assignment
         | lilypond error
         | lilypond "\invalid"`


error and \invalid are not defined by music21
)NTopLevelExpression
Assignmentc                8   > Uc  / n[         TU ]  5         Xl        g r'   superr$   ry   r#   ry   	__class__s     r   r$   LyLilypondTop.__init__2  s    H r   c                8    U R                  U R                  5      $ r'   r|   ry   r"   s    r   rl   LyLilypondTop.stringOutput8      88GGr   ry   r'   )
r   r   r   r   r   
canContainr$   rl   r   __classcell__r   s   @r   r   r   !  s      <J!H Hr   r   c                  <   ^  \ rS rSrSr   SU 4S jjrS rSrU =r$ )LyTopLevelExpressioni<  a*  
can contain one of:

  lilypondHeader
  bookBlock
  bookPartBlock
  scoreBlock
  compositeMusic
  fullMarkup
  fullMarkupList
  outputDef

>>> bookBlock = lily.lilyObjects.LyBookBlock()
>>> lyTopLevel = lily.lilyObjects.LyTopLevelExpression(bookBlock=bookBlock)
>>> str(lyTopLevel)
'\\book  { } '
c	                   > [         T	U ]  5         Xl        X l        X0l        X@l        XPl        X`l        Xpl        Xl	        g r'   )
r   r$   lilypondHeader	bookBlockbookPartBlock
scoreBlockcompositeMusic
fullMarkupfullMarkupList	outputDef)
r#   r   r   r   r   r   r   r   r   r   s
            r   r$   LyTopLevelExpression.__init__O  s<     	,"*$,$,"r   c                d    U R                  / SQ5      nUc  [        S5      eUR                  5       $ )N)r   r   r   r   r   r   r   r   zNeed an outputObject to reportrv   r   rl   r#   outputObjects     r   rl   !LyTopLevelExpression.stringOutput]  s<    44 6K L &'GHH((**r   )r   r   r   r   r   r   r   r   )NNNNNNNN	r   r   r   r   r   r$   rl   r   r   r   s   @r   r   r   <  s"    $ 7;EIAE#+ +r   r   c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyLilypondHeaderif  zq
A header object with a LyHeaderBody

>>> lyh = lily.lilyObjects.LyLilypondHeader()
>>> str(lyh)
'\\header { } '
c                .   > [         TU ]  5         Xl        g r'   )r   r$   lilypondHeaderBody)r#   r   r   s     r   r$   LyLilypondHeader.__init__o      "4r   c                X    U R                   S-   U R                  U R                  5      -   $ )Nheader)r   r   r   r"   s    r   rl   LyLilypondHeader.stringOutputs  s'    ~~(4+<+<T=T=T+UUUr   )r   r'   r   r   s   @r   r   r   f  s    5V Vr   r   c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyEmbeddedScmiw  a)  
represents Scheme embedded in Lilypond code.

Can be either an SCM_TOKEN (Scheme Token) or SCM_IDENTIFIER String stored in self.content

Note that if any LyEmbeddedScm is found in an output then the output SHOULD be marked as unsafe.
But a lot of standard lilypond functions are actually embedded scheme.
For instance, \clef, which
as http://lilypond.org/doc/v2.12/input/lsr/lilypond-snippets/Pitches#Tweaking-clef-properties
shows is a macro to run a lot of \set commands.

>>> lyScheme = lily.lilyObjects.LyEmbeddedScm('##t')
>>> str(lyScheme)
'##t'
c                .   > [         TU ]  5         Xl        g r'   r   r$   contentr#   r   r   s     r   r$   LyEmbeddedScm.__init__      r   c                    U R                   $ r'   r   r"   s    r   rl   LyEmbeddedScm.stringOutput      ||r   r   r'   r   r   s   @r   r   r   w  s      r   r   c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyLilypondHeaderBodyi  c                8   > Uc  / n[         TU ]  5         Xl        g r'   )r   r$   assignments)r#   r   r   s     r   r$   LyLilypondHeaderBody.__init__  s    K&r   c                8    U R                  U R                  5      $ r'   )r|   r   r"   s    r   rl   !LyLilypondHeaderBody.stringOutput  s    889I9IJJr   )r   r'   r   r   r   r   r$   rl   r   r   r   s   @r   r   r     s    'K Kr   r   c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyAssignmentIdi  zt
>>> lyAssignmentId = lily.lilyObjects.LyAssignmentId('title', isLyricString=False)
>>> str(lyAssignmentId)
'title'
c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   r   isLyricString)r#   r   r   r   s      r   r$   LyAssignmentId.__init__  s    *r   c                    U R                   $ r'   r   r"   s    r   rl   LyAssignmentId.stringOutput  r   r   )r   r   NFr   r   s   @r   r   r     s    +
 r   r   c                  :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )LyAssignmenti  a.  
one of three forms of assignment:

  assignment_id '=' identifier_init
  assignment_id property_path '=' identifier_init
  embedded_scm

if self.embeddedScm is not None, uses type 3
if self.propertyPath is not None, uses type 2
else uses type 1 or raises an exception.

>>> lyIdInit = lily.lilyObjects.LyIdentifierInit(string='hi')
>>> lya = lily.lilyObjects.LyAssignment(assignmentId='title', identifierInit=lyIdInit)
>>> print(lya)
title = "hi"

Note that you could also pass assignmentId a LyAssignmentId object,
but that's overkill for a lot of things.
c                R   > [         TU ]  5         Xl        X l        X0l        X@l        g r'   )r   r$   assignmentIdidentifierInitpropertyPathembeddedScm)r#   r   r   r   r   r   s        r   r$   LyAssignment.__init__  s&    (,(&r   c                2   U R                   b  U R                   R                  5       $ U R                  b  U R                  b  U R                  c  [        S5      eSR                  [        U R                  5      SU R                  R                  5       SU R                  R                  5       S/5      $ U R                  b  U R                  c  [        S5      eSR                  [        U R                  5      SU R                  R                  5       S/5      $ )Nz&need an assignmentId or identifierInitrr   rI    = =)r   rl   r   r   r   r   r   rf   r"   s    r   rl   LyAssignment.stringOutput  s   '##0022*  (D,?,?,G*+STT77C 1 12C --::<e //<<>E F F   (D,?,?,G*+STT88S!2!23S!00==?F G Gr   )r   r   r   r   NNNNr   r   s   @r   r   r     s!    ( :>04'G Gr   r   c                  F   ^  \ rS rSrSr        SU 4S jjrS rSrU =r$ )LyIdentifierIniti  z_

>>> lyIdInit = lily.lilyObjects.LyIdentifierInit(string='hello')
>>> print(lyIdInit)
"hello"
c                   > [         TU ]  5         Xl        X l        X0l        X@l        XPl        X`l        Xpl        Xl	        Xl
        Xl        Xl        Xl        Xl        Xl        g r'   )r   r$   r   r   r   r   contextDefSpecBlockmusic	postEventnumberExpressionstringr   r   r   digitcontextModification)r#   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s                  r   r$   LyIdentifierInit.__init__  s\     	$"*"#6 
" 0&$,
#6 r   c                    U R                  / SQ5      nUc  [        S5      eXR                  L a  [        U5      $ XR                  L a  U R                  U5      $ UR                  5       $ )N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   zneed an outputObject)rv   r   r   rf   r   r   rl   r   s     r   rl   LyIdentifierInit.stringOutput  sj    44 6, -
 &'=>>::%|$$[[(##L11,,..r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   )NNNNNNNNNNNNNNr   r   s   @r   r   r     s1     !#%)>BPT1572/ /r   r   c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyContextDefSpecBlocki  c                .   > [         TU ]  5         Xl        g r'   )r   r$   contextDefSpecBody)r#   r  r   s     r   r$   LyContextDefSpecBlock.__init__  r   r   c                X    U R                   S-   U R                  U R                  5      -   $ )Nzcontext )r   r   r  r"   s    r   rl   "LyContextDefSpecBlock.stringOutput  s'    ~~
*T->->t?V?V-WWWr   )r  r'   r   r   s   @r   r  r    s    5X Xr   r  c                  :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )LyContextDefSpecBodyi  a6  
None or one of four forms:

   CONTEXT_DEF_IDENTIFIER
   context_def_spec_body "\grobdescriptions" embedded_scm
   context_def_spec_body context_mod
   context_def_spec_body context_modification

>>> lyContextBody = lily.lilyObjects.LyContextDefSpecBody(contextDefIdentifier='cdi')
>>> lyContextBody.stringOutput()
'cdi'


>>> embedScm = lily.lilyObjects.LyEmbeddedScm('#t')
>>> lyContextBody = lily.lilyObjects.LyContextDefSpecBody(
...                 contextDefSpecBody='body', embeddedScm=embedScm)
>>> lyContextBody.stringOutput()
'body \\grobdescriptions #t'
c                ^   > [         TU ]  5         Xl        X l        X0l        X@l        XPl        g r'   )r   r$   contextDefIdentifierr  r   
contextModr   )r#   r  r  r   r  r   r   s         r   r$   LyContextDefSpecBody.__init__)  s+    $8!"4&$#6 r   c                   U R                   b  U R                   $ U R                  bW  SnU R                  b*  SR                  U R                  SU R                  SS/5      nXR                  R                  5       -  nU$ U R                  bQ  U R                  b*  U R                  S-   U R                  R                  5       -   $ U R                  R                  5       $ U R                  b\  U R                  b5  SR                  U R                  U R                  R                  5       /5      $ U R                  R                  5       $ g )Nrr   rI   grobdescriptions)r  r   r  r   r   rl   r  r   r#   outs     r   rl   !LyContextDefSpecBody.stringOutput2  s,   $$0,,,)C&&2ggt66T^^138 9##0022CJ__(&&2..4t7S7S7UUU3355%%1&&2xx!8!8!%!9!9!F!F!H!J K K //<<>>r   )r  r  r  r   r   )NNNNNr   r   s   @r   r
  r
    s!    ( FJQU7 r   r
  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyBookBlockiK  c                .   > [         TU ]  5         Xl        g r'   )r   r$   bookBody)r#   r  r   s     r   r$   LyBookBlock.__init__L       r   c                ^    U R                   S-   S-   U R                  U R                  5      -   $ )NbookrI   )r   r   r  r"   s    r   rl   LyBookBlock.stringOutputP  s*    ~~&,t/@/@/OOOr   )r  r'   r   r   s   @r   r  r  K  s    !P Pr   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )
LyBookBodyiT  a  
Contains None, bookIdentifier (string?) or one or more of the following:

   paperBlock
   bookPartBlock
   scoreBlock
   compositeMusic
   fullMarkup
   fullMarkupList
   lilypondHeader
   error

>>> lyBookBody = lily.lilyObjects.LyBookBody(bookIdentifier='bookId')
>>> lyBookBody.stringOutput()
'bookId'

>>> lyBookBody = lily.lilyObjects.LyBookBody()
>>> lyBookBody.stringOutput() is None
True

>>> lyBookBody = lily.lilyObjects.LyBookBody(contents=['a', 'b', 'c'])
>>> print(lyBookBody.stringOutput())
a
b
c
c                D   > Uc  / n[         TU ]  5         Xl        X l        g r'   r   r$   ry   bookIdentifierr#   ry   r!  r   s      r   r$   LyBookBody.__init__p  $    H ,r   c                    U R                   b  U R                   $ U R                  (       d  g U R                  U R                  5      $ r'   r!  ry   r|   r"   s    r   rl   LyBookBody.stringOutputw  9    *&&&<<T]]KKr   r!  ry   NNr   r   s   @r   r  r  T      6-L Lr   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyBookpartBlocki  z_
>>> lbb = lily.lilyObjects.LyBookpartBlock()
>>> lbb.stringOutput()
'\\bookpart  { \n\n } \n'
c                .   > [         TU ]  5         Xl        g r'   )r   r$   bookpartBody)r#   r/  r   s     r   r$   LyBookpartBlock.__init__  s    (r   c                    U R                   c!  U R                  S-   U R                  S5      -   $ U R                  S-   U R                  U R                   R                  5       5      -   $ )Nz	bookpart rr   )r/  r   r   rl   r"   s    r   rl   LyBookpartBlock.stringOutput  sb    $>>K/$2C2CB2GGG>>K/$2C2C!!..032 2 2r   )r/  r'   r   r   s   @r   r-  r-    s    )2 2r   r-  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyBookpartBodyi  a  
Contains None, bookIdentifier (string?) or one or more of the following:

   paperBlock
   scoreBlock
   compositeMusic
   fullMarkup
   fullMarkupList
   lilypondHeader
   error


>>> lyBookpartBody = lily.lilyObjects.LyBookpartBody(bookIdentifier='bookId')
>>> lyBookpartBody.stringOutput()
'bookId'

>>> lyBookpartBody = lily.lilyObjects.LyBookpartBody()
>>> lyBookpartBody.stringOutput() is None
True

>>> lyBookpartBody = lily.lilyObjects.LyBookpartBody(contents=['a', 'b', 'c'])
>>> print(lyBookpartBody.stringOutput())
a
b
c
c                D   > Uc  / n[         TU ]  5         Xl        X l        g r'   r   r"  s      r   r$   LyBookpartBody.__init__  r$  r   c                    U R                   b  U R                   $ U R                  (       d  g U R                  U R                  5      $ r'   r&  r"   s    r   rl   LyBookpartBody.stringOutput  r(  r   r)  r*  r   r   s   @r   r4  r4    r+  r   r4  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyScoreBlocki  z
represents the container for a score ( \score { ... } )

with all the real stuff being in self.scoreBody

>>> lyScoreBlock = lily.lilyObjects.LyScoreBlock(scoreBody='hello')
>>> print(lyScoreBlock)
\score { hello }
c                .   > [         TU ]  5         Xl        g r'   )r   r$   	scoreBody)r#   r<  r   s     r   r$   LyScoreBlock.__init__      "r   c                    U R                   c  [        S5      eU R                  S-   U R                  U R                   5      -   $ )Nz!scoreBody object cannot be empty!zscore )r<  r   r   r   r"   s    r   rl   LyScoreBlock.stringOutput  s;    >>!&'JKK~~(4+<+<T^^+LLLr   )r<  r'   r   r   s   @r   r:  r:    s    #M Mr   r:  c                  :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )LyScoreBodyi  z
represents the contents of a \score { contents }
block

can take one of the following attributes:
music, scoreIdentifier, scoreBody, lilypondHeader, outputDef, error

>>> lsb = lily.lilyObjects.LyScoreBody(scoreIdentifier='score')
>>> str(lsb)
'score'
c                j   > [         TU ]  5         Xl        X l        X0l        X@l        XPl        X`l        g r'   )r   r$   r   scoreIdentifierr<  r   r   error)r#   r   rD  r<  r   r   rE  r   s          r   r$   LyScoreBody.__init__  s.    
.","
r   c                f   U R                   b  U R                   R                  5       $ U R                  b  U R                  $ U R                  c  [	        S5      eU R
                  b8  U R                  R                  5       S-   U R
                  R                  5       -   $ U R                  b8  U R                  R                  5       S-   U R                  R                  5       -   $ U R                  b8  U R                  R                  5       S-   U R                  R                  5       -   $ [	        S5      e)Nz>scoreBody cannot be None if music and scoreIdentifier are NonerI   zSone of music, scoreIdentifier, lilypondHeader, outputDef, or error must not be None)r   rl   rD  r<  r   r   r   rE  r"   s    r   rl   LyScoreBody.stringOutput  s   ::!::**,,!!-'''^^#&PR R  ,>>..0369L9L9Y9Y9[[[^^'>>..0369T9T9VVVZZ#>>..0369P9P9RRR&%& &r   )rE  r   r   r   r<  rD  NNNNNNr   r   s   @r   rB  rB    s!    
 Y]'+& &r   rB  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyPaperBlocki   c                .   > [         TU ]  5         Xl        g r'   )r   r$   r   )r#   r   r   s     r   r$   LyPaperBlock.__init__  r>  r   c                R    U R                   c  g U R                   R                  5       $ r'   )r   rl   r"   s    r   rl   LyPaperBlock.stringOutput  s"    >>!>>..00r   )r   r'   r   r   s   @r   rK  rK     s    #1 1r   rK  c                      \ rS rSrS rSrg)LyLayouti  c                    U R                   S-   SU R                   -   S-   SU R                   -   S-   SU R                   -   S-   SS/nU R                  U5      $ )	Nzlayout {rI   z	context {z   RemoveEmptyStavesz-override VerticalAxisGroup.remove-first = ##tz }})r   r|   )r#   theseStringss     r   rl   LyLayout.stringOutput  sb    3dnn,{:.1DD.1``!3	( 88FFr   r
   N)r   r   r   r   rl   r   r
   r   r   rQ  rQ    s    Gr   rQ  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyOutputDefi  zE
This is an ugly grammar, since it does not close the curly bracket.
c                .   > [         TU ]  5         Xl        g r'   )r   r$   outputDefBody)r#   rZ  r   s     r   r$   LyOutputDef.__init__  s    *r   c                l    U R                   c  [        S5      eU R                   R                  5       S-   $ )NzNeed outputDefBody to be setrT  )rZ  r   rl   r"   s    r   rl   LyOutputDef.stringOutput   s4    %&'EFF!!..0366r   )rZ  r'   r   r   s   @r   rX  rX    s    +7 7r   rX  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyOutputDefHeadi&  z
defType can be paper, midi, or layout.

>>> lyODH = lily.lilyObjects.LyOutputDefHead()
>>> lyODH.defType = 'midi'
>>> print(lyODH.stringOutput())
\midi

According to Appendix C, is the same as LyOutputDefHeadWithModeSwitch
c                .   > [         TU ]  5         Xl        g r'   )r   r$   defType)r#   ra  r   s     r   r$   LyOutputDefHead.__init__2  r   r   c                j    U R                   S;  a  [        S5      eU R                  U R                   -   $ )N)papermidilayoutz8self.defType must be one of 'paper', 'midi', or 'layout')ra  r   r   r"   s    r   rl   LyOutputDefHead.stringOutput6  s.    <<::&'abb~~,,r   )ra  r'   r   r   s   @r   r_  r_  &  s    	- -r   r_  c                  :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )LyOutputDefBodyi=  a=  

output_def_body: output_def_head_with_mode_switch '{'
                | output_def_head_with_mode_switch
                     '{'
                     OUTPUT_DEF_IDENTIFIER
                | output_def_body assignment
                | output_def_body context_def_spec_block
                | output_def_body error
c                j   > [         TU ]  5         Xl        X l        X0l        X@l        XPl        X`l        g r'   )r   r$   outputDefHeadoutputDefIdentifierrZ  
assignmentr   rE  )r#   rk  rl  rZ  rm  r   rE  r   s          r   r$   LyOutputDefBody.__init__I  s0    *#6 *$#6 
r   c                ~   U R                   b?  [        U R                   5      S-   nU R                  b  U[        U R                  5      -   $ U$ U R                  b  [	        S5      eU R
                  b8  U R                  R                  5       S-   U R
                  R                  5       -   $ U R                  b8  U R                  R                  5       S-   U R                  R                  5       -   $ U R                  b8  U R                  R                  5       S-   U R                  R                  5       -   $ [	        S5      e)Nr   zSNeed embedded outputDefBody if outputDefIdentifier or outputDefHead are not definedrI   zaNeed to define at least one of assignment, contextDefSpecBlock, or error if outputDefHead is None)	rk  rf   rl  rZ  r   rm  rl   r   rE  r  s     r   rl   LyOutputDefBody.stringOutputS  s&   )d(()E1C''3S!9!9:::
+& (L M M__(%%224s:T__=Y=Y=[[[%%1%%224s:T=U=U=b=b=dddZZ#%%224s:TZZ=T=T=VVV& (b c cr   )rm  r   rE  rZ  rk  rl  rI  r   r   s   @r   ri  ri  =  s#    	 TXBFc cr   ri  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyTempoEventih  a   
tempo_event: "\tempo" steno_duration '=' tempo_range
           | "\tempo" scalar steno_duration '=' tempo_range
           | "\tempo" scalar


>>> lte = lily.lilyObjects.LyTempoEvent(scalar='40')
>>> str(lte)
'\\tempo 40'

More complex:

>>> steno = lily.lilyObjects.LyStenoDuration('quarter')
>>> tempoRange = lily.lilyObjects.LyTempoRange(70, 100)
>>> lte = lily.lilyObjects.LyTempoEvent(tempoRange=tempoRange, stenoDuration=steno)
>>> str(lte)
'\\tempo quarter  = 70~100 '

>>> lte.scalar = 85
>>> str(lte)
'\\tempo 85 quarter  = 70~100 '
c                F   > [         TU ]  5         Xl        X l        X0l        g r'   )r   r$   
tempoRangestenoDurationscalar)r#   rt  ru  rv  r   s       r   r$   LyTempoEvent.__init__  s    $*r   c                $   U R                   S-   nU R                  b  U R                  c  [        S5      eU R                  bY  SR                  U[        U R                  5      U R                  R                  5       SU R                  R                  5       /5      $ SR                  XR                  R                  5       SU R                  R                  5       /5      $ U R                  c  [        S5      eUS-   [        U R                  5      -   $ )Ntempoz2If tempoRange is defined then need a stenoDurationrI   r   z-If tempoRange is not defined then need scalar)r   rt  ru  r   rv  r   rf   rl   )r#   bases     r   rl   LyTempoEvent.stringOutput  s    ~~'??&!!)*+_``{{&xx!$T[[!1!%!3!3!@!@!BC!%!=!=!?!A B B
 xx'9'9'F'F'H!$doo&B&B&D!F G G[[ &'VWWczC,,,r   )rv  ru  rt  NNNr   r   s   @r   rr  rr  h  s    .- -r   rr  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyMusicListi  zC
can take any number of LyMusic, LyEmbeddedScm, or LyError objects
c                8   > [         TU ]  5         Uc  / nXl        g r'   r   r   s     r   r$   LyMusicList.__init__  s    H r   c                8    U R                  U R                  5      $ r'   r   r"   s    r   rl   LyMusicList.stringOutput  r   r   r   r'   r   r   s   @r   r~  r~    s    !H Hr   r~  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyMusici  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   simpleMusicr   )r#   r  r   r   s      r   r$   LyMusic.__init__  s    &,r   c                    U R                   b  U R                   R                  5       $ U R                  b  U R                  R                  5       $ [        S5      e)Nz3Need to define one of simpleMusic or compositeMusic)r  rl   r   r   r"   s    r   rl   LyMusic.stringOutput  sP    '##0022  ,&&3355&'\]]r   )r   r  r*  r   r   s   @r   r  r    s    -
^ ^r   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyAlternativeMusici  c                .   > [         TU ]  5         Xl        g r'   )r   r$   	musicList)r#   r  r   s     r   r$   LyAlternativeMusic.__init__  r>  r   c                t    U R                   c  gU R                  S-   U R                  U R                   5      -   $ )Nrr   alternative)r  r   r   r"   s    r   rl   LyAlternativeMusic.stringOutput  s2    >>!>>M1D4E4Ednn4UUUr   )r  r'   r   r   s   @r   r  r    s    #V Vr   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyRepeatedMusici  c                R   > [         TU ]  5         Xl        X l        X0l        X@l        g r'   )r   r$   simpleStringunsignedNumberr   alternativeMusic)r#   r  r  r   r  r   s        r   r$   LyRepeatedMusic.__init__  s%    (,
 0r   c                    U R                   S-   U R                  R                  5       -   U R                  R                  5       -   U R                  R                  5       -   nU R
                  c  U$ US-   U R
                  R                  5       -   $ )Nzrepeat rI   )r   r  rl   r  r   r  r  s     r   rl   LyRepeatedMusic.stringOutput  s    ~~""//12 $$1134 ((*	+
   (J9t44AACCCr   )r  r   r  r  r   r   r   s   @r   r  r    s    1	D 	Dr   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LySequentialMusici  za
represents sequential music.

Can be explicitly tagged with "\sequential" if displayTag is True
c                F   > [         TU ]  5         Xl        X l        X0l        g r'   )r   r$   r  
displayTagbeforeMatter)r#   r  r  r  r   s       r   r$   LySequentialMusic.__init__  s    "$(r   c                   U R                   b  U R                   R                  5       nOSnSnU R                  SL a  U R                  S-   nU R                  S:X  a  U R                  S-   nOSnUS-   U-   U-   S-   U R
                  -   $ )Nrr   Tzsequential 
startStaffstartStaff z{ r   )r  rl   r  r   r  rN   )r#   musicListSOtagr  s       r   rl   LySequentialMusic.stringOutput  s    >>%..557KK??d"..=0C,>>M9LLTzL(;6>ASASSSr   )r  r  r  )NFNr   r   s   @r   r  r    s    )T Tr   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyOssiaMusici  z]
represents ossia music.

Can be tagged with \startStaff and \stopStaff if startstop is True
c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   r  	startstop)r#   r  r  r   s      r   r$   LyOssiaMusic.__init__      ""r   c                    U R                   SL a  U R                  S-   nU R                  S-   nOSu  pU R                  b  U R                  R                  5       nOSnSU-   U-   S-   U-   S-   U R                  -   $ )	NTr  	stopStaff)rr   rr   rr   {rI   rT  )r  r   r  rl   rN   )r#   startstopr  s       r   rl   LyOssiaMusic.stringOutput  s{    >>T!NN]2E>>K/D KE>>%..557KKU{[(3.5;d>P>PPPr   )r  r  )NTr   r   s   @r   r  r    s    #
Q Qr   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LySimultaneousMusici  z
represents simultaneous music.

Can be explicitly tagged with '\simultaneous' if displayTag is True
otherwise encloses in double angle brackets
c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   r  r  )r#   r  r  r   s      r   r$   LySimultaneousMusic.__init__  s    "$r   c                
   U R                   b  U R                   R                  5       nOSnU R                  SL a!  U R                  S-   U R	                  U5      -   $ SR                  U R                  SUSU R                  /5      $ )Nrr   Tzsimultaneous z<< z >>)r  rl   r  r   r   r   rN   )r#   r  s     r   rl    LySimultaneousMusic.stringOutput"  st    >>%..557KK??d">>O3d6G6G6TTT77D..{E4K]K]^__r   )r  r  r   r   r   s   @r   r  r    s    %
	` 	`r   r  c                  6   ^  \ rS rSr  SU 4S jjrS rSrU =r$ )LySimpleMusici.  c                R   > [         TU ]  5         Xl        X l        X0l        X@l        g r'   )r   r$   
eventChordmusicIdentifiermusicPropertyDefcontextChange)r#   r  r  r  r  r   s        r   r$   LySimpleMusic.__init__0  s%    $. 0*r   c                d    U R                  / SQ5      nUc  [        S5      eUR                  5       $ )N)r  r  r  r  zneed one attribute setr   r   s     r   rl   LySimpleMusic.stringOutput8  s:    44 6[ \&'?@@((**r   )r  r  r  r  r   r   r   s   @r   r  r  .  s    8<6:++ +r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyContextModificationi@  zY
represents both context_modification and optional_context_mod

but not context_mod!!!!!
c                F   > [         TU ]  5         Xl        X l        X0l        g r'   )r   r$   contextModListcontextModIdentifierdisplayWith)r#   r  r  r  r   s       r   r$   LyContextModification.__init__G  s     ,$8!&r   c                    U R                   b+  U R                  S-   U R                  U R                   5      -   $ U R                  b  U R                  S-   U R                  -   $ g)Nzwith rr   )r  r   r   r  r"   s    r   rl   "LyContextModification.stringOutputM  s\    *>>G+d.?.?@S@S.TTT&&2>>G+d.G.GGGr   )r  r  r  )NNTr   r   s   @r   r  r  @  s    ' r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyContextModListiV  zQ
contains zero or more LyContextMod objects and an optional contextModIdentifier
c                D   > Uc  / n[         TU ]  5         Xl        X l        g r'   )r   r$   ry   r  )r#   ry   r  r   s      r   r$   LyContextModList.__init__[  s$    H $8!r   c                z    U R                  U R                  5      nU R                  b  US-   U R                  -   $ U$ NrI   )r|   ry   r  )r#   outputs     r   rl   LyContextModList.stringOutputb  s<    ::4==I$$0C<$";";;;Mr   )ry   r  r*  r   r   s   @r   r  r  V  s    9 r   r  c                  F   ^  \ rS rSrSrSU 4S jjr\S 5       rS rSr	U =r
$ )LyCompositeMusicij  zM
one of LyPrefixCompositeMusic or LyGroupedMusicList stored in self.contents
c                F   > [         TU ]  5         Xl        X l        X0l        g r'   )r   r$   prefixCompositeMusicgroupedMusicList	newLyrics)r#   r  r  r  r   s       r   r$   LyCompositeMusic.__init__o  s    $8! 0"r   c                L    U R                   b  U R                   $ U R                  $ r'   )r  r  r"   s    r   ry   LyCompositeMusic.contentsu  s&    $$0,,,(((r   c                   U R                   b  U R                   nOSnU R                  b$  [        U R                  5      S-   [        U5      -   $ U R                  b$  [        U R                  5      S-   [        U5      -   $ [	        S5      e)Nrr   rJ   z>Need to define either prefixCompositeMusic or groupedMusicList)r  r  rf   r  r   )r#   r  s     r   rl   LyCompositeMusic.stringOutput|  s    >>%II$$0t001D83y>II"".t,,-4s9~EE&PR Rr   )r  r  r  r|  )r   r   r   r   r   r$   r   ry   rl   r   r   r   s   @r   r  r  j  s-    # ) )R Rr   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyGroupedMusicListi  z1
one of LySimultaneousMusic or LySequentialMusic
c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   simultaneousMusicsequentialMusic)r#   r  r  r   s      r   r$   LyGroupedMusicList.__init__  s    !2.r   c                    U R                   b  [        U R                   5      $ U R                  b  [        U R                  5      $ [        S5      e)Nz:Need to define either simultaneousMusic or sequentialMusic)r  rf   r  r   r"   s    r   rl   LyGroupedMusicList.stringOutput  sN    !!-t--..!!-t++,,&LN Nr   )r  r  r*  r   r   s   @r   r  r    s    /
N Nr   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LySchemeFunctioni  a3  
Unsupported for now, represents all of::

    function_scm_argument: embedded_scm
      116                      | simple_string

      117 function_arglist_music_last: EXPECT_MUSIC function_arglist music

      118 function_arglist_nonmusic_last: EXPECT_MARKUP
                                            function_arglist
                                            full_markup
      119                               | EXPECT_MARKUP
                                            function_arglist
                                            simple_string
      120                               | EXPECT_SCM
                                            function_arglist
                                            function_scm_argument

      121 function_arglist_nonmusic: EXPECT_NO_MORE_ARGS
      122                          | EXPECT_MARKUP
                                       function_arglist_nonmusic
                                       full_markup
      123                          | EXPECT_MARKUP
                                       function_arglist_nonmusic
                                       simple_string
      124                          | EXPECT_SCM
                                       function_arglist_nonmusic
                                       function_scm_argument

      125 function_arglist: EXPECT_NO_MORE_ARGS
      126                 | function_arglist_music_last
      127                 | function_arglist_nonmusic_last

      128 generic_prefix_music_scm: MUSIC_FUNCTION function_arglist

We have usually been using LyEmbeddedScm for this
c                .   > [         TU ]  5         Xl        g r'   r   r   s     r   r$   LySchemeFunction.__init__  r   r   c                H    U R                   c  g [        U R                   5      $ r'   )r   rf   r"   s    r   rl   LySchemeFunction.stringOutput  s    <<t||$$r   r   r'   r   r   s   @r   r  r    s    $L% %r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyOptionalIdi  z
an optional id setting
c                .   > [         TU ]  5         Xl        g r'   r   r   s     r   r$   LyOptionalId.__init__  r   r   c                <    U R                   c  g SU R                   -   $ )Nr   r   r"   s    r   rl   LyOptionalId.stringOutput  s    <<4<<''r   r   r'   r   r   s   @r   r  r    s    ( (r   r  c                  D   ^  \ rS rSrSr       SU 4S jjrS rSrU =r$ )LyPrefixCompositeMusici  a\  
type must be specified.  Should be one of:

scheme, context, new, times, repeated, transpose,
modeChanging, modeChangingWith, relative,
rhythmed

prefix_composite_music: generic_prefix_music_scm
                   | "\context"
                            simple_string
                            optional_id
                            optional_context_mod
                            music
                   | "\new"
                            simple_string
                            optional_id
                            optional_context_mod
                            music
                   | "\times" fraction music
                   | repeated_music
                   | "\transpose"
                            pitch_also_in_chords
                            pitch_also_in_chords
                            music
                   | mode_changing_head grouped_music_list
                   | mode_changing_head_with_context
                            optional_context_mod
                            grouped_music_list
                   | relative_music
                   | re_rhythmed_music
c                   > [         TU ]  5         Xl        X l        X0l        X@l        XPl        X`l        Xpl        Xl	        Xl
        Xl        Xl        Xl        Xl        Xl        Xl        g r'   )r   r$   typegenericPrefixMusicScmr  
optionalIdoptionalContextModr   fractionrepeatedMusicpitchAlsoInChords1pitchAlsoInChords2modeChangingHeadr  modeChangingHeadWithContextrelativeMusicreRhythmedMusic)r#   r  r  r  r  r  r   r  r  r  r  r  r  r  r   r  r   s                   r   r$   LyPrefixCompositeMusic.__init__  sf     		%:"($"4
 *"4"4 0 0+F(*.r   c                   U R                   nUS:X  a  [        U R                  5      $ US;   a  U R                  U-   S-   [        U R                  5      -   S-   nU R
                  b  U[        U R
                  5      S-   -  nU R                  b  U[        U R                  5      S-   -  nU[        U R                  5      S-   -  nU$ US:X  aA  U R                  S-   [        U R                  5      -   S-   [        U R                  5      -   S-   $ US:X  a  [        U R                  5      $ US:X  a\  SR                  U R                  S	[        U R                  5      S[        U R                  5      S[        U R                  5      S/5      $ US
:X  a.  [        U R                  5      S-   [        U R                  5      -   $ US:X  a]  [        U R                  5      S-   nU R                  b  U[        U R                  5      S-   -  nU[        U R                  5      S-   -  nU$ US:X  a  [        U R                   5      $ US:X  a  [        U R"                  5      $ [%        SU R                    35      e)Nscheme)contextnewrI   timesztimes repeated	transposerr   z
transpose modeChangingmodeChangingWithrelativerhythmedzunknown self.type or None: )r  rf   r  r   r  r  r  r   r  r  r   r  r  r  r  r  r   r  r   )r#   myTyperz   s      r   rl   #LyPrefixCompositeMusic.stringOutput  s?   Xt1122))'#-D4E4E0FFLA*S)C//&&2S001C77TZZ3&&AHw>>H,s4==/AACG#djj/Y\___z!t))**{"77DNNL#d>U>U:VX[ 7 78#s4::PSU V V~%t,,-3c$:O:O6PPP))D445;A&&2S001C77T**+c11AHz!t))**z!t++,,&)DTYYK'PQQr   )r  r  r  r  r  r   r  r  r  r  r  r   r  r  r  )NNNNNNNNNNNNNNNr   r   s   @r   r  r    s1    @ 9=HL:>=A9=AE!%/2 R  Rr   r  c                  >   ^  \ rS rSrSr/ SQrSU 4S jjrS rSrU =r	$ )LyModeChangingHeadi>  av  
represents both mode_changing_head and mode_changing_head_with_context

.hasContext = False
.mode = ['note', 'drum', 'figure', 'chord', 'lyric']

>>> l = lily.lilyObjects.LyModeChangingHead(hasContext=True, mode='drum')
>>> print(l.stringOutput())
\drummode
>>> l2 = lily.lilyObjects.LyModeChangingHead(hasContext=False, mode='chord')
>>> print(l2.stringOutput())
\chords

)notedrumfigurechordlyricc                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   
hasContextmode)r#   r  r  r   s      r   r$   LyModeChangingHead.__init__O  s    $	r   c                (   U R                   c  [        S5      eU R                   U R                  ;  a  [        SU R                    35      eU R                  (       a  U R                  U R                   -   S-   $ U R                  U R                   -   S-   $ )NzMode must be setzNot an allowable mode r  s)r  r   allowableModesr  r   r"   s    r   rl   LyModeChangingHead.stringOutputT  sx    99&'9::99D///&)?		{'KLL??>>DII-66>>DII-33r   )r  r  FN)
r   r   r   r   r   r  r$   rl   r   r   r   s   @r   r  r  >  s     BN
	4 	4r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyRelativeMusici`  z
relative music
c                .   > [         TU ]  5         Xl        g r'   r   r   s     r   r$   LyRelativeMusic.__init__e  r   r   c                V    U R                   S-   U R                  R                  5       -   $ )Nz	relative )r   r   rl   r"   s    r   rl   LyRelativeMusic.stringOutputi  s#    ~~+dll.G.G.IIIr   r   r'   r   r   s   @r   r!  r!  `  s    J Jr   r!  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyNewLyricsim  z>
contains a list of LyGroupedMusicList objects or identifiers
c                8   > Uc  / n[         TU ]  5         Xl        g r'   )r   r$   groupedMusicLists)r#   r)  r   s     r   r$   LyNewLyrics.__init__r  s     $ "!2r   c                    SnU R                    H@  nXR                  S-   -  n[        US5      (       a  XR                  5       -  nM9  XS-   -  nMB     U$ )Nrr   z
addlyrics rl   rI   )r)  r   hasattrrl   )r#   outputStringrz   s      r   rl   LyNewLyrics.stringOutputx  sX    ''ANN\99Lq.)) 00C' ( r   )r)  r'   r   r   s   @r   r'  r'  m  s    3	 	r   r'  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyReRhythmedMusici  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   groupedMusicr  )r#   r2  r  r   s      r   r$   LyReRhythmedMusic.__init__  s    ("r   c                    U R                   n[        US5      (       a  UR                  5       nOUS-   nX R                  R                  5       -  nU$ )Nrl   rI   )r2  r,  rl   r  )r#   rz   r-  s      r   rl   LyReRhythmedMusic.stringOutput  sJ    1n%%>>+Ls7L3355r   )r2  r  r*  r   r   s   @r   r0  r0    s    #
 r   r0  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyContextChangei  zU
>>> lcc = lily.lilyObjects.LyContextChange('x', 'y')
>>> str(lcc)
'\\change x = y '
c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   beforeafter)r#   r9  r:  r   s      r   r$   LyContextChange.__init__  s    
r   c                `    U R                   S-   U R                  -   S-   U R                  -   S-   $ )Nzchange r   rI   )r   r9  r:  r"   s    r   rl   LyContextChange.stringOutput  s-    ~~	)DKK7%?$**LsRRr   )r:  r9  r*  r   r   s   @r   r7  r7    s    
S Sr   r7  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyPropertyPathi  zb
represents both property_path and property_path_revved

has one or more of LyEmbeddedScm objects
c                8   > Uc  / n[         TU ]  5         Xl        g r'   )r   r$   embeddedScheme)r#   rA  r   s     r   r$   LyPropertyPath.__init__  s    !N,r   c                ~    SR                  U R                   Vs/ s H  oR                  5       PM     sn5      $ s  snf r  )r   rA  rl   )r#   ess     r   rl   LyPropertyPath.stringOutput  s0    xxT5H5HI5Hr*5HIJJI   :)rA  r'   r   r   s   @r   r?  r?    s    -K Kr   r?  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyPropertyOperationi  a  
Represents:

   property_operation: STRING '=' scalar
                   | "\unset" simple_string
                   | "\override" simple_string property_path '=' scalar
                   | "\revert" simple_string embedded_scm

mandatory mode in ['set', 'unset', 'override', 'revert']


also represents simple_music_property_def which has the same forms


>>> lpo = lily.lilyObjects.LyPropertyOperation('unset', 'simple')
>>> str(lpo)
'\\unset simple '

>>> lpo = lily.lilyObjects.LyPropertyOperation('override', 'simple', 'x', 'y')
>>> str(lpo)
'\\override simple.x = y '

>>> lpo = lily.lilyObjects.LyPropertyOperation('revert', 'x', 'y')
>>> str(lpo)
'\\revert x.y '

TODO: should \set be given?
c                R   > [         TU ]  5         Xl        X l        X0l        X@l        g r'   )r   r$   r  value1value2value3)r#   r  rJ  rK  rL  r   s        r   r$   LyPropertyOperation.__init__  s"    	r   c           
     P   U R                   S;  a  [        SU R                    35      eU R                   S:X  a/  U R                  S-   U R                  -   S-   U R                  -   S-   $ U R                   S:X  a  U R                  S-   U R                  -   S-   $ U R                   S	:X  aA  S
R                  U R                  SU R                  SU R                  SU R                  S/5      $ U R                   S:X  a/  U R                  S-   U R                  -   S-   U R                  -   S-   $ g )N)setunsetoverriderevertzinvalid mode rO  zset r   rI   rP  zunset rQ  rr   z	override .rR  zrevert )r  r   r   rJ  rK  r   rL  r"   s    r   rl    LyPropertyOperation.stringOutput  s   99BB&tyyk'BCC99>>F*T[[85@4;;NQTTTYY'!>>H,t{{:S@@YY*$77DNNKc4;;!4;;5 6 6YY(">>I-;cADKKORUUU #r   )r  rJ  rK  rL  r   r   r   s   @r   rH  rH    s    :V Vr   rH  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyContextDefModi  zX
one of consists, remove, accepts, defaultchild, denies, alias, type, description, name
c                .   > [         TU ]  5         Xl        g r'   )r   r$   
contextDef)r#   rX  r   s     r   r$   LyContextDefMod.__init__  s    $r   c                :    U R                   U R                  -   S-   $ r  )r   rX  r"   s    r   rl   LyContextDefMod.stringOutput  s    ~~/#55r   )rX  r'   r   r   s   @r   rV  rV    s    %6 6r   rV  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyContextModi  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   contextDefOrPropertyrv  )r#   r_  rv  r   s      r   r$   LyContextMod.__init__  s    $8!r   c                    U R                   c  U R                  R                  5       $ U R                  R                  5       S-   U R                   -   S-   $ r  )rv  r_  rl   r"   s    r   rl   LyContextMod.stringOutput  sJ    ;;,,99;;,,99;cADKKORUUUr   )r_  rv  r*  r   r   s   @r   r]  r]    s    
V Vr   r]  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyMusicPropertyDefi  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   isOncepropertyDef)r#   rf  rg  r   s      r   r$   LyMusicPropertyDef.__init__	  s    &r   c                    SnU R                   (       a  XR                  S-   -  nXR                  R                  5       -   $ )Nrr   zonce )rf  r   rg  rl   )r#   r  s     r   rl   LyMusicPropertyDef.stringOutput  s7    ;;'))A##00222r   )rf  rg  r  r   r   s   @r   rd  rd    s    '
3 3r   rd  c                  :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )LyEventChordi  a  
takes all the parts as a list of up to three elements::

    event_chord: simple_chord_elements post_events
           | CHORD_REPETITION optional_notemode_duration post_events
           | MULTI_MEASURE_REST optional_notemode_duration post_events
           | command_element
           | note_chord_element

simple_chord_elements can be a LySimpleElement object.  Or it can be a
LyNewChord or LyFigureSpec + Duration
once that is done.  But there is no LySimpleChordElements object yet.
c                v   > [         TU ]  5         Xl        X l        X0l        X@l        XPl        X`l        Xpl        g r'   )	r   r$   simpleChordElements
postEventschordRepetitionmultiMeasureRestdurationcommandElementnoteChordElement)	r#   rn  ro  rp  rq  rr  rs  rt  r   s	           r   r$   LyEventChord.__init__&  s6    #6 $. 0 , 0r   c                   U R                   b  [        U R                   5      S-   $ U R                  b  [        U R                  5      S-   $ U R                  bi  [        U R                  5      nU R                  b  USU R                  -   -  nU R
                  b!  U R
                   H  nU[        U5      -  nM     US-  nU$ U R                  bl  [        U R                  5      nU R                  b  USU R                  -   -  nU R
                  b$  U R
                   H  nUS[        U5      -   -  nM     US-  nU$ [        U R                  5      nU R
                  b$  U R
                   H  nUS[        U5      -   -  nM     US-  nU$ r  )rt  rf   rs  rq  rr  ro  rp  rn  r#   rz   pes      r   rl   LyEventChord.stringOutput1  sk     ,t,,-33  ,t**+c11"".D))*A}}(S4==((*//BRLA *HAH!!-D(()A}}(S4==((*//Bs2w&A *HAHD,,-A*//Bs2w&A *HAHr   )rp  rs  rr  rq  rt  ro  rn  )NNNNNNNr   r   s   @r   rl  rl    s!     SW]a	1 r   rl  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyNoteChordElementiQ  c                P   > Uc  / n[         TU ]  5         Xl        X l        X0l        g r'   )r   r$   	chordBodyoptionalNoteModeDurationro  )r#   r}  r~  ro  r   s       r   r$   LyNoteChordElement.__init__R  s)    J"(@%$r   c                    [        U R                  5      nU R                  b  U[        U R                  5      S-   -  nU R                   H  nU[        U5      S-   -  nM     U$ r  )rf   r}  r~  ro  rw  s      r   rl   LyNoteChordElement.stringOutputZ  s[    ((4T223c99A//BR3A "r   )r}  r~  ro  r|  r   r   s   @r   r{  r{  Q  s    % r   r{  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyChordBodyic  c                8   > Uc  / n[         TU ]  5         Xl        g r'   )r   r$   chordBodyElements)r#   r  r   s     r   r$   LyChordBody.__init__e  s     $ "!2r   c                    SR                  U R                   Vs/ s H  n[        U5      PM     sn5      nSR                  SUS/5      $ s  snf )NrI   <z> )r   r  rf   )r#   cberz   s      r   rl   LyChordBody.stringOutputl  sF    HH$*@*@A*@3c#h*@ABxxa'' Bs   A
)r  r'   r   r   s   @r   r  r  c  s    3( (r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyChordBodyElementiq  a  
Contains a note or a drum pitch or a music function::

  chord_body_element: pitch
                        exclamations (a string of zero or more ! marks)
                        questions (a string of zero or more ? marks)
                        octave_check
                        post_events
                   | DRUM_PITCH post_events
                   | music_function_chord_body

TODO: only the first form is currently supported in creation
c                8   > Uc  / n[         TU ]  5         Xl        g r'   r   r$   partsr#   r  r   s     r   r$   LyChordBodyElement.__init__      =E
r   c                v    SR                  U R                   Vs/ s H  n[        U5      PM     sn5      $ s  snf r  r   r  rf   r#   ps     r   rl   LyChordBodyElement.stringOutput  s+    xx4AQ4554   6r  r'   r   r   s   @r   r  r  q  s    6 6r   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyCommandElementi  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   commandTypeargument)r#   r  r  r   s      r   r$   LyCommandElement.__init__  s    & r   c                
   U R                   nUS:X  a*  U R                  S-   U R                  R                  5       -   $ US:X  a  U R                  S-   $ US:X  a  U R                  S-   $ XR                  :X  a  US-   $ US:X  a*  U R                  S	-   U R                  R                  5       -   $ US
:X  a  U R                  S-   U R                  -   S-   $ US:X  a  U R                  S-   U R                  -   S-   $ UR                  5       $ )Nskipzskip [z[ ]z] rI   partialzpartial timeztime markmark )r  r   r  rl   r#   cts     r   rl   LyCommandElement.stringOutput  s    <>>G+dmm.H.H.JJJ3Y>>D((3Y>>D((>>!8O9_>>J.1K1K1MMM6\>>G+dmm;cAA6\>>G+dmm;cAA??$$r   )r  r  r*  r   r   s   @r   r  r    s    !
% %r   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyCommandEventi  c                F   > [         TU ]  5         Xl        X l        X0l        g r'   )r   r$   r  	argument1	argument2)r#   r  r  r  r   s       r   r$   LyCommandEvent.__init__  s    &""r   c                b   U R                   nUS:X  a  U R                  S-   $ US:X  a  U R                  S-   U R                  -   S-   $ US:X  a  U R                  S-   U R                  -   S-   $ US:X  a/  U R                  S-   U R                  -   S	-   U R                  -   S	-   $ UR	                  5       $ )
N~z~ zmark-defaultr  zdefault zkey-defaultzkey keyrI   )r  r   r  r  rl   r  s     r   rl   LyCommandEvent.stringOutput  s    9>>D((>!>>G+dnn<zII= >>F*T^^;jHH5[>>F*T^^;cADNNRUXXX??$$r   )r  r  r  r|  r   r   s   @r   r  r    s    #% %r   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyPostEventsi  c                8   > Uc  / n[         TU ]  5         Xl        g r'   )r   r$   	eventList)r#   r  r   s     r   r$   LyPostEvents.__init__  s    I"r   c                ~    SR                  U R                   Vs/ s H  oR                  5       PM     sn5      $ s  snf r  )r   r  rl   )r#   es     r   rl   LyPostEvents.stringOutput  s,    xx4>>B>a)>BCCBrF  )r  r'   r   r   s   @r   r  r    s    #D Dr   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyPostEventi  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   arg1arg2)r#   r  r  r   s      r   r$   LyPostEvent.__init__  s    		r   c                    [        U R                  5      nU R                  b  US[        U R                  5      -   -  nUS-   $ r  )rf   r  r  r#   rz   s     r   rl   LyPostEvent.stringOutput  s9    		N99 s499~%%A3wr   )r  r  r*  r   r   s   @r   r  r    s    
 r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyDirectionLessEventi  zm
represents ['[', ']', '~', '(', ')', '\!', '\(', '\)', '\>', '\<']
or an EVENT_IDENTIFIER or a tremolo_type
c                .   > [         TU ]  5         Xl        g r'   r   r$   eventr#   r  r   s     r   r$   LyDirectionLessEvent.__init__      
r   c                2    [        U R                  5      S-   $ r  rf   r  r"   s    r   rl   !LyDirectionLessEvent.stringOutput      4::$$r   r  r'   r   r   s   @r   r  r    s    
% %r   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyDirectionReqdEventi  c                .   > [         TU ]  5         Xl        g r'   r  r  s     r   r$   LyDirectionReqdEvent.__init__  r  r   c                2    [        U R                  5      S-   $ r  r  r"   s    r   rl   !LyDirectionReqdEvent.stringOutput  r  r   r  r'   r   r   s   @r   r  r    s    % %r   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyOctaveChecki  c                .   > [         TU ]  5         Xl        g r'   )r   r$   equalOrQuotesOrNone)r#   r  r   s     r   r$   LyOctaveCheck.__init__  s    #6 r   c                @    U R                   nUc  g US:X  a  gSU-   S-   $ )Nr   z= rI   r  )r#   eqns     r   rl   LyOctaveCheck.stringOutput  s.    &&;CZ#:##r   r  r'   r   r   s   @r   r  r    s    7$ $r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyPitchi  zl
represents a pitch name and zero or more sup or sub quotes
also used for steno_pitch and steno_tonic_pitch
c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   noteNamePitchquotes)r#   r  r  r   s      r   r$   LyPitch.__init__  s    *r   c                L    U R                   [        U R                  5      -   S-   $ r  )r  rf   r  r"   s    r   rl   LyPitch.stringOutput  s!    !!C$44s::r   )r  r  r*  r   r   s   @r   r  r    s    

; ;r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyGenTextDefi  z,
holds either full_markup, string, or DIGIT
c                .   > [         TU ]  5         Xl        g r'   r   r$   r.   r#   r.   r   s     r   r$   LyGenTextDef.__init__"  r  r   c                2    [        U R                  5      S-   $ r  rf   r.   r"   s    r   rl   LyGenTextDef.stringOutput&  r  r   r.   r'   r   r   s   @r   r  r    s    % %r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyScriptAbbreviationi*  zT
Holds a script abbreviation (for articulations etc.), one of::

    ^ + - | > . _

c                .   > [         TU ]  5         Xl        g r'   r  r  s     r   r$   LyScriptAbbreviation.__init__2  r  r   c                2    [        U R                  5      S-   $ r  r  r"   s    r   rl   !LyScriptAbbreviation.stringOutput6  r  r   r  r'   r   r   s   @r   r  r  *      % %r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyScriptDiri:  zO
Holds a script direction abbreviation (above below etc), one of::

    _ ^ -

c                .   > [         TU ]  5         Xl        g r'   r  r  s     r   r$   LyScriptDir.__init__B  r  r   c                2    [        U R                  5      S-   $ r  r  r"   s    r   rl   LyScriptDir.stringOutputF  r  r   r  r'   r   r   s   @r   r  r  :  r  r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyStenoDurationiM  z
the main thing that we think of as non-tuplet duration.

a duration number followed by one or more dots


>>> lsd = lily.lilyObjects.LyStenoDuration('2', 2)
>>> print(lsd)
2..

c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   durationNumbernumDots)r#   r  r  r   s      r   r$   LyStenoDuration.__init__Z  s    ,r   c                V    SU R                   -  n[        U R                  5      U-   S-   $ )NrS  rI   )r  rf   r  )r#   dotStrs     r   rl   LyStenoDuration.stringOutput_  s+    t||#4&&'&0366r   )r  r  r   r   r   s   @r   r  r  M  s    

7 7r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyMultipliedDurationid  z
represents either a simple LyStenoDuration or a list of things that
the steno duration should be multiplied by.

if stenoDur is None then output is None -- thus also represents
optional_notemode_duration
c                D   > Uc  / n[         TU ]  5         Xl        X l        g r'   )r   r$   stenoDurmultiply)r#   r  r  r   s      r   r$   LyMultipliedDuration.__init__m  s#    H  r   c                    U R                   c  g [        U R                   5      nU R                   H  nUS[        U5      -   -  nM     U$ )Nz * )r  rf   r  )r#   r  ms      r   rl   !LyMultipliedDuration.stringOutputt  sB    == DMM"A]]USV^# #Hr   )r  r  r*  r   r   s   @r   r  r  d  s    ! r   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyTremoloTypei~  c                .   > [         TU ]  5         Xl        g r'   )r   r$   tremTypeOrNone)r#   r  r   s     r   r$   LyTremoloType.__init__  s    ,r   c                T    U R                   b  S[        U R                   5      -   S-   $ g)N:rI   z: )r  rf   r"   s    r   rl   LyTremoloType.stringOutput  s,    *T0011C77r   )r  r'   r   r   s   @r   r  r  ~  s    - r   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyOptionalResti  c                .   > [         TU ]  5         Xl        g r'   )r   r$   rest)r#   r  r   s     r   r$   LyOptionalRest.__init__  s    	r   c                @    U R                   SL a  gU R                  S-   $ )NFrr   zrest )r  r   r"   s    r   rl   LyOptionalRest.stringOutput  s     99>>G++r   )r  )Fr   r   s   @r   r  r    s    , ,r   r  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LySimpleElementi  a  
A single note, lyric element, drum pitch or hidden rest::

    simple_element: pitch
                    exclamations (a string of zero or more ! marks)
                    questions (a string of zero or more ? marks)
                    octave_check
                    optional_notemode_duration
                    optional_rest
                | DRUM_PITCH optional_notemode_duration
                | RESTNAME optional_notemode_duration
                | lyric_element optional_notemode_duration
c                8   > Uc  / n[         TU ]  5         Xl        g r'   r  r  s     r   r$   LySimpleElement.__init__  r  r   c                v    SR                  U R                   Vs/ s H  n[        U5      PM     sn5      $ s  snf rq   r  r  s     r   rl   LySimpleElement.stringOutput  s+    ww

3
1A
3443r  r  r'   r   r   s   @r   r#  r#    s    5 5r   r#  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyLyricElementi  z
Object represents a single Lyric in lilypond.


>>> lle = lily.lilyObjects.LyLyricElement('hel_')
>>> lle
<music21.lily.lilyObjects.LyLyricElement hel_>
>>> print(lle)
hel_
c                .   > [         TU ]  5         Xl        g r'   )r   r$   lyMarkupOrString)r#   r+  r   s     r   r$   LyLyricElement.__init__  s     0r   c                2    [        U R                  5      S-   $ r  )rf   r+  r"   s    r   rl   LyLyricElement.stringOutput  s    4(()C//r   )r+  r'   r   r   s   @r   r)  r)    s    	10 0r   r)  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyTempoRangei  z*
defines either a single tempo or a range
c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   lowestOrOnlyTempohighestTempoOrNone)r#   r2  r3  r   s      r   r$   LyTempoRange.__init__  s    !2"4r   c                    U R                   c  [        U R                  5      S-   $ [        U R                  5      S-   [        U R                   5      -   S-   $ )NrI   r  )r3  rf   r2  r"   s    r   rl   LyTempoRange.stringOutput  sP    ""*t--.44t--.4s4;R;R7SSVYYYr   )r3  r2  r*  r   r   s   @r   r0  r0    s    5
Z Zr   r0  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyNumberExpressioni  zG
any list of numbers or LyNumberTerms separated by '+' or '-' objects.
c                8   > Uc  / n[         TU ]  5         Xl        g r'   r   r$   numberAndSepListr#   r;  r   s     r   r$   LyNumberExpression.__init__       #! 0r   c                    SR                  U R                   Vs/ s H  n[        U5      PM     sn5      nUS-   $ s  snf r  r   r;  rf   r#   r  rz   s      r   rl   LyNumberExpression.stringOutput  9    HHd&;&;<&;c!f&;<=3w =   ;r;  r'   r   r   s   @r   r8  r8        1 r   r8  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LyNumberTermi  z6
any list of numbers separated by '*' or '/' strings.
c                8   > Uc  / n[         TU ]  5         Xl        g r'   r:  r<  s     r   r$   LyNumberTerm.__init__  r>  r   c                    SR                  U R                   Vs/ s H  n[        U5      PM     sn5      nUS-   $ s  snf r  r@  rA  s      r   rl   LyNumberTerm.stringOutput  rC  rD  rE  r'   r   r   s   @r   rH  rH    rF  r   rH  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyLyricMarkupi  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   r   r   )r#   r   r   r   s      r   r$   LyLyricMarkup.__init__  s    '>$"r   c                    U R                   c  [        U R                  5      S-   $ [        U R                  5      S-   [        U R                   5      -   $ r  )r   rf   r   r"   s    r   rl   LyLyricMarkup.stringOutput  sF    >>!t334s::t334s:S=PPPr   )r   r   r*  r   r   s   @r   rN  rN    s    #
Q Qr   rN  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyFullMarkupListi  c                .   > [         TU ]  5         Xl        g r'   )r   r$   r    )r#   r    r   s     r   r$   LyFullMarkupList.__init__      &<#r   c                    [        U R                  [        5      (       a  U R                  S-   $ U R                  S-   U R                  R	                  5       -   $ )NrI   zmarkuplines )r(   r    rf   r   rl   r"   s    r   rl   LyFullMarkupList.stringOutput  sK    d11377..44 >>N2T5P5P5]5]5___r   )r    r'   r   r   s   @r   rT  rT    s    =` `r   rT  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyFullMarkupi  c                .   > [         TU ]  5         Xl        g r'   )r   r$   r!   )r#   r!   r   s     r   r$   LyFullMarkup.__init__  s    %:"r   c                    [        U R                  [        5      (       a  U R                  S-   $ U R                  S-   U R                  R	                  5       -   $ )NrI   zmarkup )r(   r!   rf   r   rl   r"   s    r   rl   LyFullMarkup.stringOutput  sI    d00#66--33>>I-0J0J0W0W0YYYr   )r!   r'   r   r   s   @r   r[  r[    s    ;Z Zr   r[  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyMarkupTopi  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   r  r  )r#   r  r  r   s      r   r$   LyMarkupTop.__init__   r  r   c                    U R                   c  [        U R                  5      $ SR                  U R                  U R                   /5      $ r  )r  rf   r  r   r"   s    r   rl   LyMarkupTop.stringOutput%  s7    >>!t~~&&88T^^T^^<==r   )r  r  r*  r   r   s   @r   ra  ra    s    #
> >r   ra  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyMarkupListi,  c                .   > [         TU ]  5         Xl        g r'   )r   r$   markupIdentifierOrList)r#   ri  r   s     r   r$   LyMarkupList.__init__-  rW  r   c                ,    [        U R                  5      $ r'   )rf   ri  r"   s    r   rl   LyMarkupList.stringOutput1  s    4..//r   )ri  r'   r   r   s   @r   rg  rg  ,  s    =0 0r   rg  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyMarkupComposedListi5  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   markupHeadListmarkupBracedList)r#   rp  rq  r   s      r   r$   LyMarkupComposedList.__init__6  s    , 0r   c                P    SR                  U R                  U R                  /5      $ r  )r   rp  rq  r"   s    r   rl   !LyMarkupComposedList.stringOutput;  s"    xx,,d.C.CDEEr   )rq  rp  r*  r   r   s   @r   rn  rn  5  s    1
F Fr   rn  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyMarkupBracedListi?  c                .   > [         TU ]  5         Xl        g r'   )r   r$   listBody)r#   rx  r   s     r   r$   LyMarkupBracedList.__init__@  r  r   c                >    SR                  SU R                  S/5      $ )NrI   r  rT  )r   rx  r"   s    r   rl   LyMarkupBracedList.stringOutputD  s    xxdmmS122r   )rx  r'   r   r   s   @r   rv  rv  ?  s    !3 3r   rv  c                  8   ^  \ rS rSrSU 4S jjrU 4S jrSrU =r$ )LyMarkupBracedListBodyiH  c                8   > Uc  / n[         TU ]  5         Xl        g r'   )r   r$   markupOrMarkupList)r#   r  r   s     r   r$   LyMarkupBracedListBody.__init__I  s     %!#"4r   c                p   > [         TU ]  5         SnU R                   H  nU[        U5      S-   -  nM     U$ )Nrr   rI   )r   r$   r  rf   )r#   rz   r  r   s      r   rl   #LyMarkupBracedListBody.stringOutputP  s:    ((AQ#A )r   )r  r'   r   r   s   @r   r}  r}  H  s    5 r   r}  c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )LySimpleMarkupi^  z
simpleType can be 'string' (or markup identifier or lyric markup identifier, etc.) or
'score-body' or 'markup-function'

takes 1 required arg, 2nd for markup_function
c                F   > [         TU ]  5         Xl        X l        X0l        g r'   )r   r$   
simpleTyper  r  )r#   r  r  r  r   s       r   r$   LySimpleMarkup.__init__f  s    $""r   c                   U R                   S:X  a  U R                  S-   $ U R                   S:X  a  U R                  S-   U R                  -   S-   $ U R                   S:X  a(  U R                  S-   [        U R                  5      -   S-   $ g )Nr   rI   z
score-bodyzscore { r   zmarkup-function)r  r  r   rf   r  r"   s    r   rl   LySimpleMarkup.stringOutputl  sz    ??h&>>C''__,>>J.?%GG__ 11>>C'#dnn*==CC 2r   )r  r  r  )r   NNr   r   s   @r   r  r  ^  s    #D Dr   r  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LyMarkupiu  c                :   > [         TU ]  5         Xl        X l        g r'   )r   r$   simpleMarkupoptionalMarkupHeadList)r#   r  r  r   s      r   r$   LyMarkup.__init__v  s    (&<#r   c                p    U R                   b  U R                   S-   nOSnU[        U R                  5      -   $ )NrI   rr   )r  rf   r  r  s     r   rl   LyMarkup.stringOutput{  s9    &&2++c1AA3t(()))r   )r  r  r*  r   r   s   @r   r  r  u  s    =
* *r   r  c                      \ rS rSrS rSrg)Testi  c                @   [        SS5      n[        SS5      n[        U5      n[        X/S9n[	        U5      n[        US9n[        US9n[        U/5      n[        U5      n	[        U	S9n
[        U
/5      nUR                  5       nU R                  UR                  5       S	5        / nUR                  5        H(  nUR                  UR                   R"                  5        M*     U R                  U/ S
Q5        UR%                  [        5      nU R'                  X5        g)z
make a dotted-half note c.
rz   z''2rA   r  )r  )r  )r  z{ c'' 2.  
    })r#  rl  r  r  r~  r  r  r   N)r  r  r  r#  rl  r  r  r~  r  r  r   rl   assertEqualr   r>   r;   r   r   rF   assertIs)r#   lyPitchru  multipliedDurationsimpleElementr  r  
musicInnerr  r  r   lilypondToplilypondOutputr<   r{   ancestorCompositeMusics                   r   testOneNoteTheHardWayTest.testOneNoteTheHardWay  s   
 #t$'Q/1-@'w.KL!-0
#z:5
-	+I6)?K#^$45$113--/1DE	%%'AQ[[112 ( 	 %6 	7 ")!;!;<L!M,=r   r
   N)r   r   r   r   r  r   r
   r   r   r  r    s    >r   r  __main__)dr   
__future__r   typingtunittestmusic21r   r   r   Music21Exceptionr   ProtoM21Objectr   r   r   r   r   r   r   r   r   r   r  r
  r  r  r-  r4  r:  rB  rK  rQ  rX  r_  ri  rr  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r!  r'  r0  r7  r?  rH  rV  r]  rd  rl  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r#  r)  r0  r8  rH  rN  rT  r[  ra  rg  rn  rv  r}  r  r  TestCaser  r   mainTestr
   r   r   <module>r     s   #      	<88 	j2w%% j2ZX $HH H6'+8 '+TVx V"H 2K8 KX  +G8 +G\//x //dXH X48 4nP( P)L )LX2h 2&)LX )LXM8 M,(&( (&V
18 
1Gx G7( 7-h -.(ch (cV/-8 /-dH( H^h ^ 
V 
VDh D*T T>Q8 Q6`( `2+H +$H ,x (Rx RBN N(/%x /%d(8 ( ZRX ZRz4 4D
Jh 
J( .  Sh S KX K$1V( 1Vh
6h 
6
V8 
V 3 3 78 7t $(( (6 6T%x %4%X %,D8 D( %8 %%8 %$H $ ;h ;"
%8 
%%8 % %( %&7h 7.8 4
H 
	,X 	,5h 560X 0(Z8 Z"  8  
QH 
Q
`x 
`	Z8 	Z
>( 
>08 0F8 F3 3X ,DX D.*x *z!>8 !>H zT r   