
    rhH                      % S r SSKJr  / SQrSSKJr  SSKJr  SSKrSSK	J
r
  SSKrSSKrSSKrSSKrSSKJr  SSKrSS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSKJ!r!  SSK"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.  \R^                  " S5      r0\" S/ SQ5      r1 " S S\Rd                  5      r3 " S S\35      r4/ r5S\6S'   \7S:X  a  SSKr\Rp                  " 5         gg) a  
Classes and functions for creating and processing metadata associated with
scores, works, and fragments, such as titles, movements, authors, publishers,
and regions.

The :class:`~music21.metadata.Metadata` object is the main public interface to
metadata components. A Metadata object can be added to a Stream and used to set
common score attributes, such as title and composer. A Metadata object found at
offset zero can be accessed through a Stream's
:attr:`~music21.stream.Stream.metadata` property.

The following example creates a :class:`~music21.stream.Stream` object, adds a
:class:`~music21.note.Note` object, and configures and adds the
:attr:`~music21.metadata.Metadata.title` and
:attr:`~music21.metadata.Metadata.composer` properties of a Metadata object.

>>> s = stream.Score()
>>> p = stream.Part()
>>> m = stream.Measure()
>>> m.append(note.Note())
>>> p.append(m)
>>> s.append(p)
>>> s.insert(0, metadata.Metadata())
>>> s.metadata.title = 'title'
>>> s.metadata.composer = 'composer'
>>> #_DOCS_SHOW s.show()

.. image:: images/moduleMetadata-01.*
    :width: 600

A guide to the v8+ Dublin Core implementation:

The class Metadata has been completely rewritten in music21 v8 to support
significant new functionality.

The previous Metadata implementation had a list of supported workIds, and also
a list of standard contributor roles.  More than one of each contributor role
could exist, but only one of each workId.  And while there was some support for
custom contributor roles, there was no support for other custom metadata, only
the specified list of workIds.

In the v8 implementation, contributor roles are treated the same as other
non-contributor metadata.  Music21 includes a list of supported property terms,
which are pulled from Dublin Core (namespace = 'dcterms'), MARC Relator codes
(namespace = 'marcrel'), and Humdrum (namespace = 'humdrum').  Each property
term is assigned a unique name (e.g. 'composer', 'alternativeTitle', etc.).

Each metadata property can be specified by 'uniqueName' or by 'namespace:name'.
For example: `md['composer']` and `md['marcrel:CMP']` are equivalent, as are
`md['alternativeTitle']` and `md['dcterms:alternative']`. There can be more than
one of any such item (not just contributors).  And you can also have metadata
items with custom names.

For simple metadata items, like a single title, there is an easy way to get/set
them: use an attribute-style get operation (e.g. `t = md.title`).  This will always
return a single string.  If there is more than one item of that name, a summary
string will be returned.  To see the full list of metadata items in their native
value type, use a dictionary-style get operation (e.g. `titles = md['title']`).
If an item or list of items is set (whether attribute-style or dictionary-style),
any existing items of that name are deleted. To add an item or list of items
without deleting existing items, use the `md.add()` API.  See the examples below:

Set a title (overwrites any existing titles):

>>> md = metadata.Metadata()
>>> md.title = 'A Title'
>>> md.title
'A Title'
>>> md['title']
(<music21.metadata.primitives.Text A Title>,)

Set two titles (overwrites any existing titles):

>>> md['title'] = ['The Title', 'A Second Title']
>>> md['title']
(<music21.metadata.primitives.Text The Title>,
<music21.metadata.primitives.Text A Second Title>)
>>> md.title
'The Title, A Second Title'

Add a third title (leaves any existing titles in place):

>>> md.add('title', 'Third Title, A')
>>> md['title']
(<music21.metadata.primitives.Text The Title>,
<music21.metadata.primitives.Text A Second Title>,
<music21.metadata.primitives.Text Third Title, A>)
>>> md.title
'The Title, A Second Title, A Third Title'

You can also set/add/get free-form custom metadata items:

>>> md.setCustom('modification description', 'added missing sharp in measure 27')
>>> md.getCustom('modification description')
(<music21.metadata.primitives.Text added missing sharp in measure 27>,)

Adding another custom element for the same description creates a second
entry.

>>> md.addCustom('modification description', 'deleted redundant natural in measure 28')
>>> md.getCustom('modification description')
(<music21.metadata.primitives.Text added missing sharp in measure 27>,
 <music21.metadata.primitives.Text deleted redundant natural in measure 28>)

Metadata does not explicitly support client-specified namespaces, but by using
getCustom/addCustom/setCustom, clients can set anything they want. For instance, to
embed the old SoundTracker .MOD format's sample name, a .MOD file parser could use
`md.addCustom('soundtracker:SampleName', 'Bassoon')`, and a .MOD file writer that
understood 'soundtracker:' metadata could then write it back accurately to one of
those files. Custom metadata (whether namespaced this way, or free form) can also
be written to various other file formats without interpretation, as long as there
is a place for it (e.g. in the '<miscellaneous>' tag in MusicXML).

In music21 v8, primitives.Text has been updated to add `isTranslated` to keep track of
whether the text has been translated,
as well as an encoding scheme, that specifies which standard should be used to parse
the string.  See metadata/primitives.py for more information.
    )annotations)MetadataRichMetadataAmbitusShort)
namedtuple)IterableN)	dataclass)overload)base)common)
deprecated)defaults)environment)exceptions21)interval)
properties)PropertyDescription)bundles)caching)
primitives)DateDatePrimitive
DateSingleDateRelativeDateBetweenDateSelectionTextContributorCreatorImprint	Copyright	ValueTypemetadatar   	semitonesdiatonicpitchLowestpitchHighestc                    ^  \ rS rSrSrSrSUU 4S jjr      SVS jrSWS jrSXS jr	SXS jr
\SYS	 j5       r\SZS
 j5       r\S[S j5       rS\S jr\S]S j5       r\S^S j5       r\S 5       r\R(                  S_S j5       rSSSSS.         S`S jjrS rSaU 4S jjr\    SbS j5       r\    ScS j5       r\SdS j5       rSeS jrSfS jrSgS jrShS jr  Si     SjS jjr\S 5       r\R(                  S_S  j5       r\S! 5       r\R(                  S_S" j5       r\S# 5       r \ R(                  SkS$ j5       r \S% 5       r!\!R(                  S_S& j5       r!\S' 5       r"\"R(                  S_S( j5       r"\SlS) j5       r#\#R(                  S_S* j5       r#\SlS+ j5       r$\$R(                  S_S, j5       r$\SlS- j5       r%\%R(                  S_S. j5       r%\SlS/ j5       r&\&R(                  S_S0 j5       r&\S1 5       r'\'R(                  S_S2 j5       r'\S3 5       r(\(R(                  S_S4 j5       r(\S5 5       r)\)R(                  SkS6 j5       r)\S7 5       r*\*R(                  S_S8 j5       r*\S9 5       r+\+R(                  SkS: j5       r+\S; 5       r,\,R(                  S_S< j5       r,\SlS= j5       r-\-R(                  S_S> j5       r-\SlS? j5       r.\.R(                  S_S@ j5       r.\SlSA j5       r/\/R(                  S_SB j5       r/\SC 5       r0\0R(                  S_SD j5       r0\SlSE j5       r1SZSF jr2SmSG jr3SnSH jr4SoSI jr5SpSJ jr6\SqSK j5       r7\SpSL j5       r8\SqSM j5       r9\SqSN j5       r:\SrSO j5       r;SsSP jr<StSQ jr=StSR jr>\SuSS j5       r?STr@U =rA$ )vr      a  
Metadata objects contain information about a work, including title, composer,
dates, and other relevant information. Metadata objects can also cover a fragment
of a Score such as individual parts or a range of measures.

Metadata is a :class:`~music21.base.Music21Object` subclass, meaning that it
can be positioned on a Stream by offset and have a
:class:`~music21.duration.Duration`.

In many cases, each Stream will have a single Metadata object at the zero-offset
position.

To get a simple string, use attribute-style access by unique name.
Some workIds from music21 v7 have been renamed (e.g. 'date' has been renamed
to 'dateCreated').  The old music21 v7 name in these cases is still supported
when you use attribute-style access.

>>> md = metadata.Metadata(title='Concerto in F')
>>> md.title
'Concerto in F'

Attribute access also works with three-letter workId abbreviations (these are
grandfathered in from music21 v7; abbreviations have not been added for
new-in-v8 metadata items):

>>> md = metadata.Metadata(otl='Concerto in F')
>>> md.otl
'Concerto in F'
>>> md.title
'Concerto in F'

It is also possible to set a list/tuple of values or get a tuple full of
(richer-typed) values using dictionary-style access.

>>> md = metadata.Metadata()
>>> md['composer'] = ['Billy Strayhorn', 'Duke Ellington']
>>> md['composer']
(<music21.metadata.primitives.Contributor composer:Billy Strayhorn>,
 <music21.metadata.primitives.Contributor composer:Duke Ellington>)
>>> md.composer
'Billy Strayhorn and Duke Ellington'
>>> md.contributors
(<music21.metadata.primitives.Contributor composer:Billy Strayhorn>,
 <music21.metadata.primitives.Contributor composer:Duke Ellington>)

Here is the list of grandfathered v7 synonyms, which may disappear in a
future version:

>>> sorted(metadata.properties.ALL_MUSIC21_WORK_IDS)
['commission', 'date', 'dedication', 'volume']

And here are their new v8 standard unique names:

>>> sorted(metadata.properties.MUSIC21_WORK_ID_TO_UNIQUE_NAME.values())
['commissionedBy', 'dateCreated', 'dedicatedTo', 'volumeNumber']
ic                  > 0 n0 nUR                  5        H#  u  pEU[        R                  ;   a  XSU'   M  XRU'   M%     [        TU ]  " S0 UD6  0 U l        UR                  5        H  u  pE[        XU5        M     [        R                  /U S'   g )Nsoftware )	itemsr   ALL_LEGAL_ATTRIBUTESsuper__init__	_contentssetattrr   r,   )selfkeywordsm21BaseKeywords
myKeywordsattrvalue	__class__s         S/home/james-whalen/.local/lib/python3.13/site-packages/music21/metadata/__init__.pyr1   Metadata.__init__   s    ,.')

 $>>+KDz666#(4 (-%	 , 	+?+57%++-KDD& . %--.Z    c                $    U R                  XSS9  g)u  
Adds a single item or multiple items with this name, leaving any existing
items with this name in place.

The name can be the item's uniqueName or 'namespace:name'.  If it is
not the uniqueName or namespaceName of one of the standard metadata
properties, KeyError will be raised.

>>> md = metadata.Metadata()
>>> md.add('average duration', '180 minutes')
Traceback (most recent call last):
KeyError: "Name='average duration' is not a standard metadata name...

Example of adding a composer and two titles:

>>> md.add('composer', 'Houcine Slaoui')
>>> md['composer']
(<music21.metadata.primitives.Contributor composer:Houcine Slaoui>,)

>>> md.add('title', metadata.Text('الماريكان', language='ar'))
>>> md.add('title', metadata.Text('The Americans',  language='en'))
>>> titles = md['title']
>>> titles
(<music21.metadata.primitives.Text الماريكان>,
 <music21.metadata.primitives.Text The Americans>)
>>> titles[0].language
'ar'
>>> titles[1].language
'en'

If you do in fact want to overwrite any existing items with this name,
you can use dictionary-style or attribute-style setting instead.
See :meth:`~music21.metadata.Metadata.__setitem__` and
:meth:`~music21.metadata.Metadata.__setattr__` for details.
FisCustomN_addr4   namer9   s      r;   addMetadata.add	  s    N 			$	.r=   c                "    U R                  USS9$ )a  
Gets any custom-named metadata items. The name can be free-form,
or it can be a custom 'namespace:name'.

getCustom always returns tuple[Text, ...], which may be empty.

>>> md = metadata.Metadata()
>>> md.setCustom('measure with 2nd ending', 'measure 128')
>>> md.getCustom('measure with 2nd ending')
(<music21.metadata.primitives.Text measure 128>,)

A second item can also be added.

>>> md.addCustom('measure with 2nd ending', 'measure 192')
>>> measures = md.getCustom('measure with 2nd ending')

>>> isinstance(measures, tuple)
True
>>> len(measures)
2
>>> measures
(<music21.metadata.primitives.Text measure 128>,
 <music21.metadata.primitives.Text measure 192>)
Tr?   )_getr4   rD   s     r;   	getCustomMetadata.getCustom2  s    2 yyy--r=   c                $    U R                  XSS9  g)a   
Adds any custom-named metadata items. The name can be free-form,
or it can be a custom 'namespace:name'.

addCustom takes a single object of any type, or a list/tuple of
objects of any type.  The object(s) will be converted to Text.

>>> md = metadata.Metadata()
>>> md.addCustom('measure with 2nd ending', 'measure 128')
>>> md.getCustom('measure with 2nd ending')
(<music21.metadata.primitives.Text measure 128>,)

An item list can also be added.

>>> md.addCustom('measure with 2nd ending', ['measure 192', 'measure 256'])
>>> measures = md.getCustom('measure with 2nd ending')

>>> isinstance(measures, tuple)
True
>>> len(measures)
3
>>> measures
(<music21.metadata.primitives.Text measure 128>,
 <music21.metadata.primitives.Text measure 192>,
 <music21.metadata.primitives.Text measure 256>)
Tr?   NrA   rC   s      r;   	addCustomMetadata.addCustomM  s    6 			$	-r=   c                $    U R                  XSS9  g)a  
Sets any custom-named metadata items (deleting any existing such items).
The name can be free-form, or it can be a custom 'namespace:name'.

setCustom takes a single object of any type, or a list/tuple of
objects of any type.  The object(s) will be converted to Text.

>>> md = metadata.Metadata()
>>> md.setCustom('measure with 2nd ending', 'measure 128')
>>> md.getCustom('measure with 2nd ending')
(<music21.metadata.primitives.Text measure 128>,)

An item list can also be set.

>>> md.setCustom('measure with 2nd ending', ['measure 192', 'measure 256'])
>>> measures = md.getCustom('measure with 2nd ending')

>>> isinstance(measures, tuple)
True
>>> len(measures)
2
>>> measures
(<music21.metadata.primitives.Text measure 192>,
 <music21.metadata.primitives.Text measure 256>)
Tr?   N)_setrC   s      r;   	setCustomMetadata.setCustomj  s    4 			$	-r=   c                B    [         R                  R                  U S5      $ )a  
Translates a unique name to the associated standard property's
namespace name (i.e. the property's name in the form 'namespace:name').

An example from the MARC Relators namespace: the namespace name of
'librettist' is 'marcrel:LBT'.

>>> metadata.Metadata.uniqueNameToNamespaceName('librettist')
'marcrel:LBT'

Returns None if no such associated standard property can be found.

>>> metadata.Metadata.uniqueNameToNamespaceName('average duration') is None
True

An example from the Dublin Core namespace: the namespace name of
'alternativeTitle' is 'dcterms:alternative'.

>>> metadata.Metadata.uniqueNameToNamespaceName('alternativeTitle')
'dcterms:alternative'
N)r   UNIQUE_NAME_TO_NAMESPACE_NAMEget)
uniqueNames    r;   uniqueNameToNamespaceName"Metadata.uniqueNameToNamespaceName  s    0 77;;JMMr=   c                B    [         R                  R                  U S5      $ )aj  
Translates a standard property namespace name ('namespace:name') to that
standard property's uniqueName.

An example from the MARC Relators namespace: the unique name of
'marcrel:LBT' is 'librettist'.

>>> metadata.Metadata.namespaceNameToUniqueName('marcrel:LBT')
'librettist'

Returns None if no such standard property exists.

>>> metadata.Metadata.namespaceNameToUniqueName('soundtracker:SampleName') is None
True

An example from the Dublin Core namespace: the unique name of
'dcterms:alternative' is 'alternativeTitle'.

>>> metadata.Metadata.namespaceNameToUniqueName('dcterms:alternative')
'alternativeTitle'
N)r   NAMESPACE_NAME_TO_UNIQUE_NAMErU   )namespaceNames    r;   namespaceNameToUniqueName"Metadata.namespaceNameToUniqueName  s    . 77;;M4PPr=   c                r    U (       d  g[         R                  R                  U S5      nUc  gUR                  $ )a  
Determines if a unique name is associated with a standard contributor
property.  Returns False if no such associated standard contributor
property can be found.

We allow uniqueName == None, since None is a valid custom contributor role.

Example: 'librettist' and 'otherContributor' are unique names of standard
contributors.

>>> metadata.Metadata.isContributorUniqueName('librettist')
True
>>> metadata.Metadata.isContributorUniqueName('otherContributor')
True

Example: 'alternativeTitle' is the unique name of a standard property,
but it is not a contributor.

>>> metadata.Metadata.isContributorUniqueName('alternativeTitle')
False

Example: 'average duration' is not the unique name of a standard property.

>>> metadata.Metadata.isContributorUniqueName('average duration')
False
FNr   #UNIQUE_NAME_TO_PROPERTY_DESCRIPTIONrU   isContributorrV   props     r;   isContributorUniqueName Metadata.isContributorUniqueName  s;    8 ::>>z4P 	 <!!!r=   c                `    U R                  U5      (       a  gU R                  U5      (       a  gg)a  
Determines if name is either a 'namespace:name' or a 'uniqueName'
associated with a standard property.

Returns False if no such associated standard property can be found.

>>> md = metadata.Metadata()
>>> md.isStandardName('librettist')
True

'marcrel:LBT' is the namespace name of 'librettist'

>>> md.isStandardName('marcrel:LBT')
True

Some examples of non-standard (custom) names.

>>> md.isStandardName('average duration')
False
>>> md.isStandardName('soundtracker:SampleName')
False
TF)_isStandardNamespaceName_isStandardUniqueNamerI   s     r;   isStandardNameMetadata.isStandardName  s/    . ((..%%d++r=   c                $    U R                  S5      $ )a  
Returns a tuple of software names/versions.

Returns an empty tuple if no software names/versions exist,
but this is rare, since music21 adds its own version when
initializing a Metadata object.

>>> md = metadata.Metadata()
>>> md.software
('music21 v...',)
>>> md.add('software', 'Finale for Macintosh')
>>> md.software
('music21 v...',
 'Finale for Macintosh')
>>> md['software']
(<music21.metadata.primitives.Text music21 v...>,
 <music21.metadata.primitives.Text Finale for Macintosh>)

Note that `.software` is an exception to the general rule that
singular looking properties return a string.  In fact, it is always
plural and returns a tuple of strings.  There is no singular version
r,   _getPluralAttributer4   s    r;   r,   Metadata.software  s    0 ''
33r=   c                r    / nU R                  SSSS9 H  u  p#UR                  U5        M     [        U5      $ )a  
Returns a tuple of all the Contributors found in the metadata.
Returns an empty tuple if no Contributors exist.

>>> md = metadata.Metadata()
>>> md.composer = 'Richard Strauss'
>>> md.librettist = 'Oscar Wilde'

When we add something that is not a person, such as a title
(whether through `.attribute` setting, `[item]` setting,
or the :meth:`~music21.metadata.Metadata.add` method), it will not show up
in the list of contributors.

>>> md.add('title', 'Salome')
>>> contribs = md.contributors
>>> contribs
(<music21.metadata.primitives.Contributor composer:Richard Strauss>,
 <music21.metadata.primitives.Contributor librettist:Oscar Wilde>)

Note that `.contributors` cannot be set.  Add them separately via
specific setters or the `.addContributor()` method.
TFskipNonContributorsreturnPrimitivesreturnSorted)allappendtuple)r4   output_contribs       r;   contributorsMetadata.contributors  sF    0 %'(($(!%" # $JA MM'"	$
 V}r=   c                $    U R                  S5      $ )uU  
Returns the copyright as a str.
Returns None if no copyright exists in the metadata.
Returns all the copyright values in one string (with ', ' between them)
if multiple copyrights exist in the metadata. Use md['copyright'] to
get all the copyrights as Copyright objects.

>>> md = metadata.Metadata()
>>> md.copyright is None
True
>>> md.copyright = 'Copyright © 1896, Éditions Durand (expired)'
>>> md.copyright
'Copyright © 1896, Éditions Durand (expired)'

Using dictionary-style access, you can use either the uniqueName ('copyright')
or the namespaceName ('dcterms:rights').  Here you can see how multiple
copyrights are handled.

>>> md.copyright = 'Copyright © 1984 All Rights Reserved'
>>> md.copyright
'Copyright © 1984 All Rights Reserved'

To add another copyright to the list, call md.add().

>>> md.add('copyright', 'Lyrics copyright © 1987 All Rights Reserved')

md.copyright will now return both copyrights in one string

>>> md.copyright
'Copyright © 1984 All Rights Reserved, Lyrics copyright © 1987 All Rights Reserved'

md['copyright'] will return a tuple containing both Copyright objects.

>>> md['copyright']
(<music21.metadata.primitives.Copyright Copyright © 1984 All Rights Reserved>,
 <music21.metadata.primitives.Copyright Lyrics copyright © 1987 All Rights Reserved>)

You can set str, Text, or Copyright values, and they will be converted to
Copyright automatically if necessary.  Note that 'dcterms:rights'
is Dublin Core terminology for 'copyright', and can be used interchangeably
with 'copyright' as a metadata dictionary-style key.

>>> md.copyright = metadata.Text('Copyright © 1984')
>>> md['copyright']
(<music21.metadata.primitives.Copyright Copyright © 1984>,)
>>> md.copyright = metadata.Copyright('Copyright © 1985', role='something')
>>> md['dcterms:rights']
(<music21.metadata.primitives.Copyright Copyright © 1985>,)
	copyright_getSingularAttributern   s    r;   r~   Metadata.copyright>  s    f ))+66r=   c                    [        U SU5        g)'
For type checking only. Does not run.
r~   Nr3   r4   r9   s     r;   r~   r   s      
 	k5)r=   FTskipContributorsrr   rs   rt   c               z   / nU R                   R                  5        Hv  u  pgU R                  U5      nU(       a	  U(       a  M&  U(       a	  U(       d  M6  U H:  n	U(       a  UR                  Xi45        M  UR                  U[	        U	5      45        M<     Mx     U(       a  [        [        U5      5      $ [        U5      $ )u  
Returns the values stored in this metadata as a Tuple of (uniqueName, value) pairs.
There are four bool options. The three that are new in v8 (skipNonContributors,
returnPrimitives, returnSorted) are defaulted to behave like v7.

If skipContributors is True, only non-contributor metadata will be returned.  If
skipNonContributors is True, only contributor metadata will be returned.  If both
of these are True, the returned Tuple will be empty. If returnPrimitives is False
(default), values are all converted to str.  If returnPrimitives is True, the values
will retain their original ValueType (e.g. Text, Contributor, Copyright, etc.).  If
returnSorted is False, the returned Tuple will not be sorted by uniqueName (the
default behavior is to sort).

Note that we cannot properly type-hint the return value, since derived classes (such
as RichMetadata) are allowed to return their own typed values that might not be str
or ValueType.

>>> c = corpus.parse('corelli/opus3no1/1grave')
>>> c.metadata.all()
(('arranger', 'Michael Scott Cuthbert'),
 ('composer', 'Arcangelo Corelli'),
 ('copyright', '© 2014, Creative Commons License (CC-BY)'),
 ('corpusFilePath', 'corelli/opus3no1/1grave.xml'),
 ('fileFormat', 'musicxml'),
 ('filePath', '...corpus/corelli/opus3no1/1grave.xml'),
 ('movementName', 'Sonata da Chiesa, No. I (opus 3, no. 1)'),
 ('software', 'Dolet...'),
 ('software', 'Finale...'),
 ('software', 'music21 v...'))

>>> c.metadata.date = metadata.DateRelative('1689', 'onOrBefore')
>>> c.metadata.localeOfComposition = 'Rome'
>>> c.metadata.all(skipContributors=True)
(('copyright', '© 2014, Creative Commons License (CC-BY)'),
 ('corpusFilePath', 'corelli/opus3no1/1grave.xml'),
 ('dateCreated', '1689/--/-- or earlier'),
 ('fileFormat', 'musicxml'),
 ('filePath', '...corpus/corelli/opus3no1/1grave.xml'),
 ('localeOfComposition', 'Rome'),
 ('movementName', 'Sonata da Chiesa, No. I (opus 3, no. 1)'),
 ('software', 'Dolet...'),
 ('software', 'Finale...'),
 ('software', 'music21 v...'))

>>> c.metadata.all(returnPrimitives=True, returnSorted=False)
(('software', <music21.metadata.primitives.Text music21 v...>),
 ('software', <music21.metadata.primitives.Text Finale ...>),
 ('software', <music21.metadata.primitives.Text Dolet Light...>),
 ('movementName', <...Text Sonata da Chiesa, No. I (opus 3, no. 1)>),
 ('composer', <music21.metadata.primitives.Contributor composer:Arcangelo Corelli>),
 ...
 ('dateCreated', <music21.metadata.primitives.DateRelative 1689/--/-- or earlier>),
 ('localeOfComposition', <music21.metadata.primitives.Text Rome>))

>>> c.metadata.all(skipNonContributors=True, returnPrimitives=True, returnSorted=True)
(('arranger', <music21.metadata.primitives.Contributor arranger:Michael Scott Cuthbert>),
 ('composer', <music21.metadata.primitives.Contributor composer:Arcangelo Corelli>))
)r2   r.   _isContributorUniqueNamerv   strrw   sorted)
r4   r   rr   rs   rt   allOutrV   	valueListra   r9   s
             r;   ru   Metadata.all{  s    F +- &*^^%9%9%;!J"&"?"?
"KMM"= ##MM:"56MM:s5z":;	 # &< ((V}r=   c                $    U R                  U5      $ )a[  
Utility attribute access for all uniqueNames, grandfathered workIds,
and grandfathered workId abbreviations.  Many grandfathered workIds
have explicit property definitions, so they won't end up here.

These always return str or None.  If there is more than one item
for a particular name, we will try to summarize or list them all
in one returned string.

If name is not a valid attribute (uniqueName, grandfathered workId,
or grandfathered workId abbreviation), then AttributeError is raised.

>>> md = metadata.Metadata()

An example of setting an attribute by uniqueName ('description').

>>> md.description = metadata.Text('A description set via uniqueName', language='en')

An example of setting an attribute by grandfathered workId ('dedication')

>>> md.dedication = 'A dedication set via grandfathered workId'

An example of setting an attribute by grandfathered workId abbreviation ('otl')

>>> md.otl = metadata.Text('A title set via grandfathered workId abbreviation')

See how we can get all three attributes by uniqueName, even though two of them
were set by other names.

An example of getting (by uniqueName) an attribute that was set by uniqueName.

>>> md.description
'A description set via uniqueName'

An example of getting (by uniqueName) an attribute that was set by workId.
The uniqueName for the grandfathered workId 'dedication' is 'dedicatedTo'.

>>> md.dedicatedTo
'A dedication set via grandfathered workId'

An example of getting (by uniqueName) an attribute that was set by abbreviation.
The uniqueName for the grandfathered workId abbreviation 'otl' is 'title'.

>>> md.title
'A title set via grandfathered workId abbreviation'

An example of getting an attribute for which there are multiple values.

>>> md.add('description', 'A description added via md.add()')
>>> md.description
'A description set via uniqueName, A description added via md.add()'
r   rI   s     r;   __getattr__Metadata.__getattr__  s    x ))$//r=   c                  > U[         R                  ;   a?  Ub<  [        U[        5      (       a'  [        U[        5      (       d  [        SU SU S35      eU[         R                  ;   a9  [        U[        5      (       a  [        U[        5      (       a  [        SU S35      eU[         R                  ;   a#  U R                  [         R                  U   USS9  gU[         R                  ;   a#  U R                  [         R                  U   USS9  gU[         R                  ;   a#  U R                  [         R                  U   USS9  gUS;   a  USS	 nU R                  X2SS9  g[        TU ]1  X5        g)
as  
Attribute setter for all uniqueNames, grandfathered workIds,
and grandfathered workId abbreviations, as well as the plural
properties ('composers', 'librettists', 'lyricists') and the
three new fileInfo properties.

These can take a single value of any type (or, if appropriate, an
iterable of any type of value), and will convert to the appropriate
internal valueType.
Nzmd.z+ can only be set to a single value; set md[z] to multiple values instead.z: can only be set to an iterable (e.g. a list, tuple, etc).Fr?   )	composerslibrettists	lyricists)r   ALL_SINGLE_ATTRIBUTE_NAMES
isinstancer   r   
ValueErrorALL_PLURAL_ATTRIBUTE_NAMESrT   rP   !MUSIC21_WORK_ID_TO_NAMESPACE_NAME&MUSIC21_ABBREVIATION_TO_NAMESPACE_NAMEr0   __setattr__)r4   rD   r9   rV   r:   s       r;   r   Metadata.__setattr__  s   0 :888!"5(33&uc22 3tf -++/&0M"O P P :888eX..*UC2H2H $YZ 
 :;;;II88>  
  :???II<<TB  
  :DDDIIAA$G  
  <<crJIIj%I8 	D(r=   c                    g Nr-   r4   keys     r;   __getitem__Metadata.__getitem__]  s     	r=   c                    g r   r-   r   s     r;   r   r   f  s    
 	r=   c                    g r   r-   r   s     r;   r   r   m  s    r=   c                b    [        U[        5      (       d  [        S5      eU R                  USS9$ )a  
"Dictionary key" access for all standard uniqueNames and
standard keys of the form 'namespace:name'.

These always return tuple[ValueType, ...], which may be empty.

If key is not a standard uniqueName or standard 'namespace:name',
then KeyError is raised.

>>> md = metadata.Metadata()
>>> md['average duration']
Traceback (most recent call last):
KeyError: "Name='average duration' is not a standard metadata name...

Example: setting, then getting (dictionary style) a single value. Note that
it must be set as a single element list/tuple, and is always returned as a
single element tuple.

>>> md['description'] = [
...     metadata.Text('For the coronation of Catherine the Great.', language='en')
... ]
>>> descs = md['description']
>>> descs
(<music21.metadata.primitives.Text For the coronation of Catherine the Great.>,)

A second description can also be added.

>>> md.add('description', 'In five sections, unique for its time.')
>>> descs = md['description']
>>> isinstance(descs, tuple)
True
>>> len(descs)
2
>>> descs
(<music21.metadata.primitives.Text For the coronation of Catherine the Great.>,
 <music21.metadata.primitives.Text In five sections, unique for its time.>)
>>> descs[0].language
'en'
>>> descs[1].language is None
True
metadata key must be strFr?   )r   r   KeyErrorrH   r   s     r;   r   r   q  s1    T #s##566yyuy--r=   c                d    [        U[        5      (       d  [        S5      eU R                  XSS9  g)a  
"Dictionary key" access for all standard uniqueNames and
standard keys of the form 'namespace:name'.

If key is not a standard uniqueName or standard 'namespace:name',
then KeyError is raised.

>>> md = metadata.Metadata()
>>> md['average duration'] = ['180 minutes']
Traceback (most recent call last):
KeyError: "Name='average duration' is not a standard metadata name...

KeyError is also raised for non-str keys.

>>> md[3] = ['180 minutes']
Traceback (most recent call last):
KeyError: 'metadata key must be str'

r   Fr?   N)r   r   r   rP   )r4   r   r9   s      r;   __setitem__Metadata.__setitem__  s-    ( #s##566		#u	-r=   c                    [        U[        5      (       d  [        R                  " SU 35      eU R	                  UR
                  5      nU R                  X!SS9  g)a  
Assign a :class:`~music21.metadata.Contributor` object to this
Metadata.

>>> md = metadata.Metadata(title='Gaelic Symphony')
>>> c = metadata.Contributor()
>>> c.name = 'Beach, Amy'
>>> c.role = 'composer'
>>> md.addContributor(c)
>>> md.composer
'Beach, Amy'

Add maiden name as an alternative composer name:

>>> c_alt = metadata.Contributor()
>>> c_alt.name = 'Cheney, Amy Marcy'
>>> c_alt.role = 'composer'
>>> md.addContributor(c_alt)
>>> md.composers
('Beach, Amy', 'Cheney, Amy Marcy')

>>> md.search('Beach')
(True, 'composer')
>>> md.search('Cheney')
(True, 'composer')

Note that in this case, a "composerAlias" would probably be a more
appropriate role than a second composer.

All contributor roles are searchable, even if they are not standard roles:

>>> dancer = metadata.Contributor()
>>> dancer.names = ['Merce Cunningham', 'Martha Graham']
>>> dancer.role = 'interpretive dancer'
>>> md.addContributor(dancer)
>>> md.search('Cunningham')
(True, 'interpretive dancer')
z&supplied object is not a Contributor: Fr?   N)r   r   r   MetadataException_contributorRoleToUniqueNamerolerB   )r4   crV   s      r;   addContributorMetadata.addContributor  sS    P ![))008<> >;;AFFC
		*%	0r=   c                    / nU R                  SSSS9 H(  u  p4UR                  U:X  d  M  UR                  U5        M*     [        U5      $ )a  
Return a :class:`~music21.metadata.Contributor` if defined for a
provided role.

We allow role == None, since None is a valid custom contributor role.

>>> md = metadata.Metadata(title='Violin Concerto')

>>> c = metadata.Contributor()
>>> c.name = 'Price, Florence'
>>> c.role = 'composer'
>>> md.addContributor(c)
>>> cTuple = md.getContributorsByRole('composer')
>>> cTuple
(<music21.metadata.primitives.Contributor composer:Price, Florence>,)

>>> cTuple[0].name
'Price, Florence'

Some musicxml files have contributors with no role defined.  To get
these contributors, search for getContributorsByRole(None).  N.B. upon
output to MusicXML, music21 gives these contributors the generic role
of "creator"

>>> c2 = metadata.Contributor()
>>> c2.name = 'Baron van Swieten'
>>> md.add('otherContributor', c2)
>>> noRoleTuple = md.getContributorsByRole(None)
>>> len(noRoleTuple)
1
>>> noRoleTuple[0].role is None
True
>>> noRoleTuple[0].name
'Baron van Swieten'
TFrq   )ru   r   rv   rw   )r4   r   resultry   rz   s        r;   getContributorsByRoleMetadata.getContributorsByRole  sS    H %'(($(!%" # $JA ||t#g&$ V}r=   c                  ^ Sn/ nTc  Uc  U(       d  gTc  Uc  U(       a  UR                  5       u  nmUb  UR                  5       nSn U R                  U5      nU(       a  U H  nUR                  X45        M     SnU(       d  U R                  SS9 H  u  pU R                  U	5      (       d  M  X)R                  5       ;   a  UR                  X45        Sn  O[        R                  R                  U	S5      n
U
c  Mk  X*R                  5       ;   d  M  UR                  X45        Sn  OE   OBU R                  SS9 H/  u  pU R                  U	5      (       d  M  UR                  X45        M1     U R                  SSSS9 H  u  pUb^  UR                  c  UR                  5       S:w  a  M+  UR                  b.  UR                  5       UR                  R                  5       ;  a  Mf  UR                   H)  nUR                  [        U5      UR                  45        M+     M     Sn[        T[        R                  5      (       a  SnTnOT[        T[        5      (       a?  [!        U4S jS	 5       5      (       a%  Sn["        R$                  " T["        R&                  S
9nU(       a@  Ub=  U H6  u  p[        U[        5      (       d  M  UR)                  U5      nUc  M2  SU4s  $    g[+        T5      (       a  U H  u  pT" U5      (       d  M  SU4s  $    gU H  u  p[        U[        5      (       a3  [        T5      mTR                  5       UR                  5       ;   a  SU4s  $ [        U[,        5      (       a'  [/        TS5      (       a  TR0                  U:X  a  SU4s  $ TU:X  d  M  SU4s  $    g! [         a     GN>f = f)a/  
Search one or all fields with a query, given either as a string or a
regular expression match.

>>> md = metadata.Metadata()
>>> md.composer = 'Joplin, Scott'
>>> md.title = 'Maple Leaf Rag'

>>> md.search(
...     'joplin',
...     field='composer',
...     )
(True, 'composer')

Note how the incomplete field name in the following example is still
matched:

>>> md.search(
...     'joplin',
...     field='compos',
...     )
(True, 'composer')

These don't work (Richard didn't have the sense of rhythm to write this!)

>>> md.search(
...     'Wagner',
...     field='composer',
...     )
(False, None)

>>> md.search('Wagner')
(False, None)

>>> md.search('leaf')
(True, 'title')

>>> md.search(
...     'leaf',
...     field='composer',
...     )
(False, None)

>>> md.search(
...     'leaf',
...     field='title',
...     )
(True, 'title')

>>> md.search('leaf|entertainer')
(True, 'title')

>>> md.search('opl(.*)cott')
(True, 'composer')


* New in v4: use a keyword argument to search
  that field directly:

>>> md.search(composer='Joplin')
(True, 'composer')
N)FNFT)r   rq   contributorc              3  ,   >#    U  H	  oT;   v   M     g 7fr   r-   ).0	characterquerys     r;   	<genexpr>"Metadata.search.<locals>.<genexpr>  s     D)Y5()s   z*.|+?{})flagssharps)popitemlowerrm   rv   AttributeErrorru   rh   r   UNIQUE_NAME_TO_MUSIC21_WORK_IDrU   r   namesr   r   tPatternanyrecompile
IGNORECASEsearchcallableinthasattrr   )r4   r   fieldr5   reQueryvalueFieldPairsmatchvaluesr9   rV   workIdry   rz   rD   useRegex
innerFieldmatchReSearchs    `               r;   r   Metadata.search  sw   N #'=U]8 ]u}#++-LE5KKMEE11%8!''..~> "( E )-4)H%J55jAA   0 0 22'../BC $ (2'P'P'T'T"D(F ~  .'..? $5 *I8 &*XXtX%D!
--j99#**E+>? &E (($(!%" # $JA  <<'EKKM],J<<+W\\EWEWEY0Y&&D	7<<'@A &$  eQYY''HG$$D)DDDHjjbmm<G+%4!eS))$+NN5$9M$0#Z// &5. # e__%4!<<++ &5   &5!eS))JE{{}5#Z//uc**#E844!LLE1++e^++ &5 q " s   
5N0 0
N>=N>c                $    U R                  S5      $ )z
Get or set the alternative title.

>>> md = metadata.Metadata(popularTitle='Eroica')
>>> md.alternativeTitle = 'Heroic Symphony'
>>> md.alternativeTitle
'Heroic Symphony'
alternativeTitler   rn   s    r;   r   Metadata.alternativeTitle  s     ))*<==r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r     s    
 	(%0r=   c                $    U R                  S5      $ )av  
Get or set the composer of this work. Only the first composer can be
got or set via properties.

The composer attribute does not live in Metadata, but creates a
:class:`~music21.metadata.Contributor` object in the .contributors
object.

>>> md = metadata.Metadata(
...     title='...(Iphigenia)',
...     )
>>> md.composer = 'Shorter, Wayne'

You can set multiple composers by setting them dictionary-style
or by using `md.add`.
>>> md.add('composer', 'Spalding, Esperanza')

The `Metadata.composer` attribute returns a summary string if there is
more than one composer.

>>> md.composer
'Shorter, Wayne and Spalding, Esperanza'
composerr   rn   s    r;   r   Metadata.composer  s    2 ))*55r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r         
 	j%(r=   c                $    U R                  S5      $ )a  
Get a tuple or set an iterable of strings of all composer roles.

>>> md = metadata.Metadata(title='Yellow River Concerto')
>>> md.composers = ['Xian Xinghai', 'Yin Chengzong']

(Yin Chengzong might be better called "Arranger" but this is for
illustrative purposes)

>>> md.composers
('Xian Xinghai', 'Yin Chengzong')

Might as well add a third composer to the concerto committee?

>>> contrib3 = metadata.Contributor(role='composer', name='Chu Wanghua')
>>> md.add('composer', contrib3)
>>> md.composers
('Xian Xinghai', 'Yin Chengzong', 'Chu Wanghua')

If there are no composers, returns an empty list:

>>> md = metadata.Metadata(title='Sentient Algorithmic Composition')
>>> md.composers
()
r   rl   rn   s    r;   r   Metadata.composers  s    6 ''
33r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r   0  r   r=   c                    U R                   $ )za
The `.date` property is deprecated in v8 and will be removed in v10.
Use `dateCreated` instead.
)dateCreatedrn   s    r;   dateMetadata.date7  s     r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r   ?  s    
 	fe$r=   c                $    U R                  S5      $ )a7  
Get or set the creation date of this work as one of the following date
objects:

:class:`~music21.metadata.DateSingle`,
:class:`~music21.metadata.DateRelative`,
:class:`~music21.metadata.DateBetween`,
:class:`~music21.metadata.DateSelection`,

>>> md = metadata.Metadata(
...     title='Third Symphony',
...     popularTitle='Eroica',
...     composer='Beethoven, Ludwig van',
...     )
>>> md.dateCreated = '1805'
>>> md.dateCreated
'1805/--/--'

>>> md.dateCreated = metadata.DateBetween(['1803/01/01', '1805/04/07'])
>>> md.dateCreated
'1803/01/01 to 1805/04/07'
r   r   rn   s    r;   r   Metadata.dateCreatedF  s    0 ))-88r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r   `      
 	mU+r=   c                $    U R                  S5      $ )z-
Get or set the file format that was parsed.

fileFormatr   rn   s    r;   r   Metadata.fileFormatg      
 )),77r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r   n      
 	lE*r=   c                $    U R                  S5      $ )zu
Get or set the file path that was parsed.  This returns a string, not a Path object
that is deliberate for caching.
filePathr   rn   s    r;   r   Metadata.filePathu  s     ))*55r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r   }  r   r=   c                $    U R                  S5      $ )z8
Get or set the path within the corpus that was parsed.
corpusFilePathr   rn   s    r;   r   Metadata.corpusFilePath  s    
 ))*:;;r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r         
 	&.r=   c                $    U R                  S5      $ )z-
Get or set the file number that was parsed.

fileNumberr   rn   s    r;   r  Metadata.fileNumber  r   r=   c                    [        U SU5        g)r   r  Nr   r   s     r;   r  r    r   r=   c                $    U R                  S5      $ )z
Get or set the locale of composition, or origin, of the work.

>>> md = metadata.Metadata(popularTitle='Eroica')
>>> md.localeOfComposition = 'Paris, France'
>>> md.localeOfComposition
'Paris, France'
localeOfCompositionr   rn   s    r;   r  Metadata.localeOfComposition  s     ))*?@@r=   c                    [        U SU5        g)r   r  Nr   r   s     r;   r  r    s    
 	+U3r=   c                $    U R                  S5      $ )a[  
Gets or sets a single librettist for this work:

>>> md = metadata.Metadata(title='Death of Klinghoffer, The')
>>> md.librettist = 'Goodman, Alice'
>>> md.librettist
'Goodman, Alice'

To preserve continuity with Humdrum, library catalogues, etc.,
librettists should be distinguished from lyricists etc., but sometimes
the line is not 100% clear.

librettistr   rn   s    r;   r	  Metadata.librettist  s     )),77r=   c                    [        U SU5        g)r   r	  Nr   r   s     r;   r	  r
    r   r=   c                $    U R                  S5      $ )a  
Gets a tuple or sets an iterable of librettists for this work:

>>> md = metadata.Metadata(title='Madama Butterfly')
>>> md.librettists = ['Illica, Luigi', 'Giacosa, Giuseppe']
>>> md.librettists
('Illica, Luigi', 'Giacosa, Giuseppe')

Should be distinguished from lyricists etc.
r	  rl   rn   s    r;   r   Metadata.librettists  s     ''55r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r    r   r=   c                $    U R                  S5      $ )a  
Gets or sets a single lyricist for this work:

>>> md = metadata.Metadata(title='Girlfriend')
>>> md.lyricist = 'Keys, Alicia'

To preserve continuity with Humdrum, library catalogues, etc.,
lyricists should be distinguished from librettists etc., but sometimes
the line is not 100% clear:

>>> md = metadata.Metadata(title='West Side Story')
>>> md.lyricist = 'Sondheim, Stephen'
>>> md.lyricist
'Sondheim, Stephen'
lyricistr   rn   s    r;   r  Metadata.lyricist  s    " ))*55r=   c                    [        U SU5        g)r   r  Nr   r   s     r;   r  r    r   r=   c                $    U R                  S5      $ )a7  
Gets a tuple or sets an iterable of lyricists for this work:

>>> md = metadata.Metadata(title='Rumors')
>>> md.lyricists = ['Buckingham, Lindsey', 'McVie, Christine', 'Nicks, Stevie']
>>> md.lyricists
('Buckingham, Lindsey', 'McVie, Christine', 'Nicks, Stevie')

Should be distinguished from librettists etc.
r  rl   rn   s    r;   r   Metadata.lyricists  s     ''
33r=   c                    [        U SU5        g)r   r   Nr   r   s     r;   r   r    r   r=   c                $    U R                  S5      $ )a=  
Get or set the movement title.

>>> md = metadata.Metadata()
>>> md.movementName = 'Vivace'
>>> md.movementName
'Vivace'

Note that a number of pieces from various MusicXML datasets have
the piece title as the movement title. For instance, the Bach
Chorales, since they are technically movements of larger cantatas.
movementNamer   rn   s    r;   r  Metadata.movementName  s     )).99r=   c                    [        U SU5        g)r   r  Nr   r   s     r;   r  r    s    
 	ne,r=   c                $    U R                  S5      $ )z
Get or set the movement number as a string (or None)

>>> md = metadata.Metadata(title='Ode to Joy')
>>> md.movementNumber = 4

Note that movement numbers are always returned as strings!  This may
change in the future.

>>> md.movementNumber
'4'
movementNumberr   rn   s    r;   r  Metadata.movementNumber%  s     ))*:;;r=   c                    [        U SU5        g)r   r  Nr   r   s     r;   r  r  5  r   r=   c                $    U R                  S5      $ )ax  
Get or set the number of the work within a collection of pieces,
as a string. (for instance, the number within a collection of ABC files)

>>> md = metadata.Metadata()
>>> md.number = '4'

Note that numbers are always returned as strings!  This may
change in the future.

>>> md.number
'4'

However, it is acceptable to set it as an int:

>>> md.number = 2
>>> md.number
'2'
numberr   rn   s    r;   r  Metadata.number<  s    * ))(33r=   c                    [        U SU5        g)r   r  Nr   r   s     r;   r  r   S  s    
 	h&r=   c                $    U R                  S5      $ )a  
Get or set the opus number.

>>> md = metadata.Metadata()
>>> md.opusNumber = 56

Note that opusNumbers are always returned as strings!  This may
change in the future, however, it is less likely to change
than `.number` or `.movementNumber` since Opus numbers such as
`18a` are common.

>>> md.opusNumber
'56'

There is no enforcement that only numbers actually called "opus"
are used, and it could be used for other catalogue numbers.

>>> md.opusNumber = 'K.622'

opusNumberr   rn   s    r;   r#  Metadata.opusNumberZ  s    * )),77r=   c                    [        U SU5        g)r   r#  Nr   r   s     r;   r#  r$  q  r   r=   c                $    U R                  S5      $ )z
Get the title of the work.

>>> md = metadata.Metadata(title='Third Symphony')
>>> md.title
'Third Symphony'

>>> md = metadata.Metadata(popularTitle='Eroica')
>>> md.title is None
True
titler   rn   s    r;   r'  Metadata.titlex  s     ))'22r=   c                    [        U SU5        g)r   r'  Nr   r   s     r;   r'  r(    s    
 	gu%r=   c                t    SnU H0  nU R                  [        R                  U   5      nU(       d  M.  Us  $    g)aE  
Get the title of the work, or the next-matched title string
available from a related parameter fields.

>>> md = metadata.Metadata(title='Third Symphony')
>>> md.bestTitle
'Third Symphony'

>>> md = metadata.Metadata(popularTitle='Eroica')
>>> md.bestTitle
'Eroica'

>>> md = metadata.Metadata(
...     title='Third Symphony',
...     popularTitle='Eroica',
...     )
>>> md.bestTitle
'Third Symphony'

>>> md.popularTitle
'Eroica'

>>> md.otp
'Eroica'

bestTitle cannot be set:

>>> md.bestTitle = 'Bonaparte'
Traceback (most recent call last):
AttributeError: ...'bestTitle'...
)r'  popularTitler   r  N)_getStringValueByNamespaceNamer   rT   )r4   searchIdrV   titleSummarys       r;   	bestTitleMetadata.bestTitle  sF    H
 #J%)%H%H88D&L |## # r=   c                V   U[         R                  ;  a  gU R                  USS9nU(       d  gU R                  U5      (       am  [	        U5      S:X  a  [        US   5      $ [	        U5      S:X  a   [        US   5      S-   [        US   5      -   $ [        US   5      S[	        U5      S-
   S3-   $ U R                  U5      (       aL  S	n[        U5       H9  u  pE[        U[        5      (       d   eUS:  a  US
-  nX5R                  5       -  nM;     U$ S
R                  S U 5       5      $ )a  
Gets a single str value (a summary if necessary) for a supported
'namespace:name'.

>>> md = metadata.Metadata()
>>> md['title'] = ['The Title', 'A Second Title']
>>> md._getStringValueByNamespaceName('dcterms:title')
'The Title, A Second Title'

Returns None  (rather than raising KeyError) if namespaceName
is not a supported 'namespace:name'.

>>> md.setCustom('average duration', '180 minutes')
>>> md._getStringValueByNamespaceName('average duration') is None
True

Returns None if the namespaceName is supported, but no such
metadata item exists.

>>> md._getStringValueByNamespaceName('dcterms:alternative') is None
True

Performs article normalization on metadata properties that are declared
as needing it (generally, title-like properties).

>>> md['alternativeTitle'] = ['Alternative Title, The', 'Second Alternative Title, A']
>>> md._getStringValueByNamespaceName('dcterms:alternative')
'The Alternative Title, A Second Alternative Title'
NFr?      r      z and z others z, c              3  8   #    U  H  n[        U5      v   M     g 7fr   r   r   r9   s     r;   r   :Metadata._getStringValueByNamespaceName.<locals>.<genexpr>  s     8U   )r   ALL_NAMESPACE_NAMESrH   _isContributorNamespaceNamelenr   '_namespaceNameNeedsArticleNormalization	enumerater   r   getNormalizedArticlejoin)r4   r[   r   rx   ir9   s         r;   r,  'Metadata._getStringValueByNamespaceName  s    < 
 > >>(,		-%	(P++M::6{a6!9~%6{a6!9~/#fQi.@@vay>eCK!O+<G$DDD77FFF%f-!%....q5dNF4466	 .
 Myy8888r=   c                h   U[         R                  ;  a
  [        5       $ U R                  USS9nU(       d
  [        5       $ U R	                  U5      (       aL  / nU H9  n[        U[        5      (       d   eUR                  UR                  5       5        M;     [        U5      $ [        S U 5       5      $ )a  
Gets a tuple of str values for a supported 'namespace:name'.

>>> md = metadata.Metadata()
>>> md['title'] = ['The Title', 'A Second Title']
>>> md._getStringValuesByNamespaceName('dcterms:title')
('The Title', 'A Second Title')

Returns an empty tuple (rather than raising KeyError) if namespaceName
is not a supported 'namespace:name'.

>>> md.setCustom('average duration', '180 minutes')
>>> md._getStringValuesByNamespaceName('average duration')
()

Returns an empty tuple if the namespaceName is supported, but no such
metadata item exists.

>>> md._getStringValuesByNamespaceName('dcterms:alternative')
()

Performs article normalization on metadata properties that are declared
as needing it (generally, title-like properties).

>>> md['alternativeTitle'] = ['Alternative Title, The', 'Second Alternative Title, A']
>>> md._getStringValuesByNamespaceName('dcterms:alternative')
('The Alternative Title', 'A Second Alternative Title')
Fr?   c              3  8   #    U  H  n[        U5      v   M     g 7fr   r6  r7  s     r;   r   ;Metadata._getStringValuesByNamespaceName.<locals>.<genexpr>&  s     4VESZZVr9  )	r   r:  rw   rH   r=  r   r   rv   r?  )r4   r[   r   rx   r9   s        r;   _getStringValuesByNamespaceName(Metadata._getStringValuesByNamespaceName  s    : 
 > >>7N(,		-%	(P7N77FF "F!%....e88:;   = 4V444r=   c                b   U[         R                  ;   a"  U R                  [         R                  U   5      $ U[         R                  ;   a"  U R                  [         R                  U   5      $ U[         R                  ;   a"  U R                  [         R                  U   5      $ [        SU 35      e)a  
This does what __getattr__ would do if we supported plural attributeNames
(but it takes singular attributeNames, of course).  It returns a tuple
of strings (perhaps empty) for supported uniqueNames, grandfathered
workIds, and grandfathered workId abbrevations.  It is used in search,
as well as in the various plural properties, such as md.composers, etc.

>>> md = metadata.Metadata()
>>> md['dedicatedTo'] = ('The First Dedicatee', 'A Second Dedicatee')

Example: _getPluralAttribute by uniqueName

>>> md._getPluralAttribute('dedicatedTo')
('The First Dedicatee', 'A Second Dedicatee')

Example: _getPluralAttribute by grandfathered workId

>>> md._getPluralAttribute('dedication')
('The First Dedicatee', 'A Second Dedicatee')

Example: _getPluralAttribute by grandfathered workId abbreviation

>>> md._getPluralAttribute('ode')
('The First Dedicatee', 'A Second Dedicatee')

It raises AttributeError if attributeName is not a valid uniqueName,
workId, or workId abbreviation.

Example: _getPluralAttribute by 'namespace:name'

>>> md._getPluralAttribute('humdrum:ODE')
Traceback (most recent call last):
AttributeError: invalid attributeName: humdrum:ODE
zinvalid attributeName: )r   rT   rF  r   r   r   r4   attributeNames     r;   rm   Metadata._getPluralAttribute(  s    F JDDD7788G 
 JHHH77<<]K 
 JMMM77AA-P  6}oFGGr=   c                   U[         R                  ;   a"  U R                  [         R                  U   5      $ U[         R                  ;   a"  U R                  [         R                  U   5      $ U[         R                  ;   a"  U R                  [         R                  U   5      $ [        U R                  R                  < SU< 35      e)a  
This returns a single string (perhaps a summary) for supported uniqueNames,
grandfathered workIds, and grandfathered workId abbrevations.

>>> md = metadata.Metadata()
>>> md['dedicatedTo'] = ('The First Dedicatee', 'A Second Dedicatee')

Example: _getSingularAttribute by uniqueName

>>> md._getSingularAttribute('dedicatedTo')
'The First Dedicatee, A Second Dedicatee'

Example: _getSingularAttribute by grandfathered workId

>>> md._getSingularAttribute('dedication')
'The First Dedicatee, A Second Dedicatee'

Example: _getSingularAttribute by grandfathered workId abbreviation

>>> md._getSingularAttribute('ode')
'The First Dedicatee, A Second Dedicatee'

It raises AttributeError if attributeName is not a valid uniqueName,
workId, or workId abbreviation.

Example: _getSingularAttribute by 'namespace:name'

>>> md._getSingularAttribute('humdrum:ODE')
Traceback (most recent call last):
AttributeError: 'Metadata' object has no attribute: 'humdrum:ODE'
z object has no attribute: )r   rT   r,  r   r   r   r:   __name__rI  s     r;   r   Metadata._getSingularAttribute^  s    @ JDDD6688G 
 JHHH66<<]K 
 JMMM66AA-P  ~~&&))CMCTU
 	
r=   c                (    U[         R                  ;   $ )a1  
Determines if a unique name is associated with a standard property.
Returns False if no such associated standard property can be found.

Example: a standard contributor uniqueName returns True

>>> md = metadata.Metadata()
>>> md._isStandardUniqueName('librettist')
True

Example: a standard 'namespace:name' returns False (it is a standard
namespaceName, but not a standard uniqueName)

>>> md._isStandardUniqueName('marcrel:LBT')
False

Example: a standard non-contributor uniqueName returns True

>>> md._isStandardUniqueName('alternativeTitle')
True

Example: a custom (non-standard) name returns False (it is not
a standard name of any sort)

>>> md._isStandardUniqueName('average duration')
False

Example: a RichMetadata additional attribute name returns False

>>> md._isStandardUniqueName('ambitus')
False

)r   r`   )r4   rV   s     r;   rh   Metadata._isStandardUniqueName  s    D ZKKKKr=   c                L    [         R                  R                  U S5      nUc  gg)a  
Determines if a 'namespace:name' is associated with a standard property.
Returns False if no such associated standard property can be found.

Example: a standard 'namespace:name' returns True

>>> metadata.Metadata._isStandardNamespaceName('marcrel:LBT')
True

Example: a standard contributor uniqueName returns False (it is a
standard uniqueName, but not a standard namespaceName)

>>> metadata.Metadata._isStandardNamespaceName('librettist')
False

Example: a namespaceName with a non-standard namespace returns False

>>> metadata.Metadata._isStandardNamespaceName('nonstandardnamespace:LBT')
False

Example: a namespaceName with a standard namespace, but a non-standard name
returns False

>>> metadata.Metadata._isStandardNamespaceName('marcrel:nonstandardname')
False

Example: a custom (non-standard) name returns False (it is not
a standard name of any sort)

>>> metadata.Metadata._isStandardNamespaceName('average duration')
False
NFT)r   &NAMESPACE_NAME_TO_PROPERTY_DESCRIPTIONrU   r[   rc   s     r;   rg   !Metadata._isStandardNamespaceName  s.    F ==AA-QUV 	 <r=   c                `    [         R                  R                  U 5      nUc  gUR                  $ )a  
Determines if a uniqueName is associated with a standard contributor
property. Returns False if no such associated standard property can be found,
or if the associated standard property is not a contributor property.

Example: 'librettist' returns True ('librettist' is a standard contributor
property).

>>> metadata.Metadata._isContributorUniqueName('librettist')
True

Example: 'alternativeTitle' returns False (it is a standard namespaceName,
but it is not a contributor).

>>> metadata.Metadata._isContributorUniqueName('alternativeTitle')
False

Example: 'marcrel:LBT' returns False (it is a standard contributor
namespaceName, but not a standard contributor uniqueName)

>>> metadata.Metadata._isContributorUniqueName('marcrel:LBT')
False

Example: a custom (non-standard) name returns False (it is not
a standard name of any sort)

>>> metadata.Metadata._isContributorUniqueName('average duration')
False
Fr_   rb   s     r;   r   !Metadata._isContributorUniqueName  s4    @ ::>>zJ 	 <!!!r=   c                `    [         R                  R                  U 5      nUc  gUR                  $ )a  
Determines if a 'namespace:name' is associated with a standard contributor
property. Returns False if no such associated standard property can be found,
or if the associated standard property is not a contributor property.

Example: 'marcrel:LBT' returns True ('marcrel:LBT' is a standard contributor
property: the librettist).

>>> metadata.Metadata._isContributorNamespaceName('marcrel:LBT')
True

Example: 'dcterms:alternative' returns False (it is a standard namespaceName,
but it is not a contributor).

>>> metadata.Metadata._isContributorNamespaceName('dcterms:alternative')
False

Example: 'librettist' returns False (it is a standard contributor
uniqueName, but not a standard contributor namespaceName)

>>> metadata.Metadata._isContributorNamespaceName('librettist')
False

Example: a namespaceName with a non-standard namespace returns False

>>> metadata.Metadata._isContributorNamespaceName('nonstandardnamespace:LBT')
False

Example: a namespaceName with a standard namespace, but a non-standard name
returns False

>>> metadata.Metadata._isContributorNamespaceName('marcrel:nonstandardname')
False

Example: a custom (non-standard) name returns False (it is not
a standard name of any sort)

>>> metadata.Metadata._isContributorNamespaceName('average duration')
False
F)r   rR  rU   ra   rS  s     r;   r;  $Metadata._isContributorNamespaceName  s4    V ==AA-P 	 <!!!r=   c                `    [         R                  R                  U 5      nUc  gUR                  $ )a  
Determines if a 'namespace:name' is associated with a standard property that
needs article normalization (generally title-like properties). Returns False
if no such associated standard property can be found, or if the associated
standard property is not a contributor property.

Example: 'dcterms:title' returns True

>>> metadata.Metadata._namespaceNameNeedsArticleNormalization('dcterms:title')
True

Example: 'title' returns False ('title' is the uniqueName of a standard property
that needs article normalization, but it is not a namespaceName).

>>> metadata.Metadata._namespaceNameNeedsArticleNormalization('title')
False

Example: 'marcrel:LBT' (the librettist) returns False (it doesn't need article
normalization)

>>> metadata.Metadata._namespaceNameNeedsArticleNormalization('marcrel:LBT')
False

Example: 'average duration' returns False (it is not a standard name)

>>> metadata.Metadata._namespaceNameNeedsArticleNormalization('average duration')
False
F)r   rR  rU   needsArticleNormalizationrS  s     r;   r=  0Metadata._namespaceNameNeedsArticleNormalization:  s3    > ==AA-P 	 <---r=   c                x    U c  g[         R                  R                  U 5      nUc  gUR                  (       d  gU $ )a  
Translates a contributor role to a standard uniqueName that
should be used to store that contributor.  For standard contributor
roles, this simply returns role, because standard roles are their
own standard uniqueNames. But for non-standard roles, 'otherContributor'
is returned. This is the standard uniqueName that should be used for
contributors with custom roles.

Example: 'composer' and 'lyricist' are standard contributor roles whose
uniqueNames are 'composer' and 'lyricist', respectively.

>>> metadata.Metadata._contributorRoleToUniqueName('composer')
'composer'
>>> metadata.Metadata._contributorRoleToUniqueName('lyricist')
'lyricist'

Example: 'interpretive dancer' is a non-standard contributor role, so
'otherContributor' is returned.

>>> metadata.Metadata._contributorRoleToUniqueName('interpretive dancer')
'otherContributor'

Example: None is a non-standard contributor role, so 'otherContributor' is returned.

>>> metadata.Metadata._contributorRoleToUniqueName(None)
'otherContributor'
otherContributorr_   )r   rc   s     r;   r   %Metadata._contributorRoleToUniqueName`  sB    : <% ::>>tD 	 <%!!%r=   c                >   U(       d`  UnU R                  U5      (       a   [        R                  R                  US5      nU R	                  U5      (       d  [        SU< S35      eUnU R                  R                  U5      nU(       d
  [        5       $ [        U5      $ )a`  
Returns all the items stored in metadata with this name.
The returned value is always a Tuple. If there are no items, an empty
Tuple is returned.

If isCustom is True, then the name will be used unconditionally as a custom name.

If isCustom is False, and the name is not a standard uniqueName or a standard
'namespace:name', KeyError will be raised.
r4  Name=V is not a standard metadata name. Call addCustom/setCustom/getCustom for custom names.)rg   r   rZ   rU   rh   r   r2   rw   )r4   rD   r@   rV   r   s        r;   rH   Metadata._get  s     "J,,T22'EEII$PRS
--j99D8 $L LM M D*...*<*<T*B	7N Yr=   c                   U(       d`  UnU R                  U5      (       a   [        R                  R                  US5      nU R	                  U5      (       d  [        SU< S35      eUn[        U[        5      (       d  U/n[        U[        5      (       a  U/n/ nU H#  nUR                  U R                  X5      5        M%     U R                  R                  US5      nU(       d  XPR                  U'   gXu-   U R                  U'   g)a7  
Adds a single item or multiple items with this name, leaving any existing
items with this name in place.

If isCustom is True, then the name will be used unconditionally as a custom name.

If isCustom is False, and the name is not a standard uniqueName or a standard
'namespace:name', KeyError will be raised.
r4  r`  ra  N)rg   r   rZ   rU   rh   r   r   r   r   rv   _convertValuer2   )r4   rD   r9   r@   rV   convertedValuesv
prevValuess           r;   rB   Metadata._add  s     "J,,T22'EEII$PRS
--j99D8 $L LM M D%**GEeS!!GE+-A""4#5#5d#>?  ,0>>+=+=dD+I
 $3NN4  $.#?DNN4 r=   c                6   U(       d`  UnU R                  U5      (       a   [        R                  R                  US5      nU R	                  U5      (       d  [        SU< S35      eUnU R                  R                  US5        Ub  U R                  XU5        gg)u/  
Sets a single item or multiple items with this name, replacing any
existing items with this name.  If isCustom is False, the name must
be a standard uniqueName or a standard 'namespace:name'.  If isCustom
is True, the name can be any custom name.

>>> md = metadata.Metadata()

Example: set the librettist

>>> md._set('librettist', metadata.Text('Marie Červinková-Riegrová'), isCustom=False)
>>> md['librettist']
(<music21.metadata.primitives.Contributor librettist:Marie Červinková-Riegrová>,)

Example: replace that librettist with two other librettists

>>> md._set('librettist', ['Melissa Li', 'Kit Yan Win'], isCustom=False)
>>> md['marcrel:LBT']
(<music21.metadata.primitives.Contributor librettist:Melissa Li>,
 <music21.metadata.primitives.Contributor librettist:Kit Yan Win>)

If isCustom is True, then the name will be used unconditionally as a custom name.

>>> md._set('average duration', '180 minutes', isCustom=True)
>>> md._get('average duration', isCustom=True)
(<music21.metadata.primitives.Text 180 minutes>,)

If isCustom is False, and the name is not a standard uniqueName or a standard
'namespace:name', KeyError will be raised.

>>> md._set('average duration', '180 minutes', isCustom=False)
Traceback (most recent call last):
KeyError: "Name='average duration' is not a standard metadata name...
r4  r`  ra  N)	rg   r   rZ   rU   rh   r   r2   poprB   )r4   rD   r9   r@   rV   s        r;   rP   Metadata._set  s    F "J,,T22'EEII$PRS
--j99D8 $L LM M D4&IId8, r=   c                   [         R                  R                  U S5      nUnUc  [        n[	        X5      (       a  U$ U[        L a4  [	        U[
        5      (       a  [        U5      $ [        [        U5      5      $ U[        L al  [	        U[
        5      (       a  [        U5      $ [	        U[        5      (       a  [        U5      $ [        R                  " S[        U5      R                   35      eU[        L a  [	        U[        5      (       a  [        U5      n[	        U[        5      (       a  U$ [	        U[
        [        R                  [        45      (       a   [        U5      $ [        R                  " S[        U5      R                   35      eU[        L aj  [	        U[
        5      (       a  [        U5      n[	        U[        5      (       a	  [        XS9$ [        R                  " S[        U5      R                   35      eU[         L a   [!        U5      $ [        R                  " S5      e!   [        [        U5      5      s $ = f!   [        R                  " S[        U5      R                   35      e= f)a  
Converts a value to the appropriate valueType (looked up in STDPROPERTIES by
uniqueName).

Converts certain named values to Text

>>> metadata.Metadata._convertValue('title', 3.4)
<music21.metadata.primitives.Text 3.4>
>>> metadata.Metadata._convertValue('title', '3.4')
<music21.metadata.primitives.Text 3.4>
>>> metadata.Metadata._convertValue('title', metadata.Text('3.4'))
<music21.metadata.primitives.Text 3.4>

Converts certain named values to Copyright

>>> metadata.Metadata._convertValue('copyright', 'copyright str')
<music21.metadata.primitives.Copyright copyright str>
>>> metadata.Metadata._convertValue('copyright', metadata.Text('copyright text'))
<music21.metadata.primitives.Copyright copyright text>
>>> metadata.Metadata._convertValue('copyright', metadata.Copyright('copyright'))
<music21.metadata.primitives.Copyright copyright>

Converts certain named values to Contributor

>>> metadata.Metadata._convertValue('composer', 'composer str')
<music21.metadata.primitives.Contributor composer:composer str>
>>> metadata.Metadata._convertValue('composer', metadata.Text('composer text'))
<music21.metadata.primitives.Contributor composer:composer text>
>>> metadata.Metadata._convertValue('composer',
...     metadata.Contributor(role='random', name='Joe'))
<music21.metadata.primitives.Contributor random:Joe>

Converts certain named values to DateSingle

>>> metadata.Metadata._convertValue('dateCreated', '1938')
<music21.metadata.primitives.DateSingle 1938/--/-->
>>> metadata.Metadata._convertValue('dateCreated', metadata.Text('1938'))
<music21.metadata.primitives.DateSingle 1938/--/-->
>>> metadata.Metadata._convertValue('dateCreated',
...     metadata.DateBetween(['1938', '1939']))
<music21.metadata.primitives.DateBetween 1938/--/-- to 1939/--/-->
Nzinvalid type for Copyright: zinvalid type for DateSingle: )r   rD   zinvalid type for Contributor: zinvalid type for int: z!internal error: invalid valueType)r   UNIQUE_NAME_TO_VALUE_TYPErU   r   r   r   r!   r   r   typerM  r   datetimer   r   r   r   )rV   r9   	valueTypeoriginalValues       r;   rd  Metadata._convertValue	  s8   X +5*N*N*R*R+
	  %Ie''L %%%E{"E
##	!%%% ''%&& ''00.tE{/C/C.DEG G % %&&E
%// %#x'8'8$!?@@4%e,, 00/U0D0D/EFH H #%%%U%&&"
??000e1E1E0FGI I E5z! ,,-PQQ74M 233(E"44,T%[-A-A,BCE Es   
H0 
I 0I.I9)r2   )returnNone)rD   r   r9   t.Any | Iterable[t.Any]rs  rt  )rD   r   rs  tuple[ValueType, ...])rD   r   r9   ru  )rV   r   rs  
str | None)r[   r   rs  rw  )rV   rw  rs  bool)rD   r   rs  rx  rs  tuple[str, ...])rs  tuple[Contributor, ...])r9   r   rs  rt  
r   rx  rr   rx  rs   rx  rt   rx  rs  ztuple[tuple[str, t.Any], ...])rD   r   r9   t.Any)r   z4t.Literal['movementName', 'movementNumber', 'title']rs  tuple[Text, ...])r   zt.Literal['copyright',]rs  ztuple[Copyright, ...])r   r   rs  r~  )r   r   rs  z(tuple[ValueType, ...] | tuple[Text, ...])r   r   r9   ru  )r   r   )r   rw  rs  r{  )NN)r   z0str | t.Pattern | t.Callable[[str], bool] | Noner   rw  rs  ztuple[bool, str | None])r9   zIterable[str]rs  rt  )rs  rw  )r[   r   rs  rz  )rJ  r   rs  rz  )rJ  r   rs  rw  rV   r   rs  rx  )r[   r   rs  rx  )r   rw  rs  r   )rD   r   r@   rx  rs  rv  )rD   r   r9   ru  r@   rx  )rV   r   r9   r}  rs  r"   )BrM  
__module____qualname____firstlineno____doc__classSortOrderr1   rE   rJ   rM   rQ   staticmethodrW   r\   rd   ri   propertyr,   r{   r~   setterru   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r	  r   r  r   r  r  r  r#  r'  r/  r,  rF  rm   r   rh   rg   r   r;  r=  r   rH   rB   rP   rd  __static_attributes____classcell__r:   s   @r;   r   r      s   7v N/2'/'/('/ '/R.6.:.> N N2 Q Q0 #" #"JD 4 42  > 27 27h * * &+(-%*!%V #V "&	V
 #V V 
'Vp<0|I)X 
 +   0   -.^.2,1\+^ =Ao9o o
 
oT 	> 	> 1 1 6 64 __) ) 4 48 * *     
[[% % 9 92 , , 8 8 + + 6 6 __) ) < < / / 8 8 + + 	A 	A 4  4 8 8 + + 6 6 , , 6 6$ __) ) 4 4 * * : : - - < < / / 4 4, ]]' ' 8 8, + + 3 3 \\& & 0 0j59n+5Z4Hl3
j"LH ' 'R $" $"L /" /"b #. #.J + +Z <&@R/-b sR sRr=   r   c                     ^  \ rS rSrSrSrU 4S jrSU 4S jjrSS jrSS jr	S	 r
SSSS
S.         SU 4S jjjrSU 4S jjrSrU =r$ )r   i~	  a  
RichMetadata adds to Metadata information about the contents of the Score
it is attached to. TimeSignature, KeySignature and related analytical is
stored.  RichMetadata are generally only created in the process of creating
stored JSON metadata.

>>> richMetadata = metadata.RichMetadata(title='Concerto in F')
>>> richMetadata.title
'Concerto in F'

>>> richMetadata.keySignatureFirst = key.KeySignature(-1)
>>> 'keySignatureFirst' in richMetadata.additionalRichMetadataAttributes
True

RichMetadata objects contain all the usual Metadata items, plus some observed
musical information analyzed from the score.  Here is a list of what information
is added:

>>> richMetadata.additionalRichMetadataAttributes
('ambitus', 'keySignatureFirst', 'keySignatures', 'noteCount', 'numberOfParts',
 'pitchHighest', 'pitchLowest', 'quarterLength', 'sourcePath', 'tempoFirst',
 'tempos', 'timeSignatureFirst', 'timeSignatures')
)ambituskeySignatureFirstkeySignatures	noteCountnumberOfPartsr(   r'   quarterLength
sourcePath
tempoFirsttempostimeSignatureFirsttimeSignaturesc                   > [         TU ]  " S0 UD6  S U l        S U l        / U l        S U l        S U l        S U l        S U l        S U l	        SU l
        S U l        / U l        S U l        / U l        g )Nr4  r-   )r0   r1   r  r  r  r  r  r(   r'   r  r  r  r  r  r  )r4   r5   r:   s     r;   r1   RichMetadata.__init__	  sv    $8$!%! !"& r=   c                v   > XR                   ;   a  [        X5      nUc
  [        5       $ U4$ [        TU ]  U5      $ r   ) additionalRichMetadataAttributesgetattrrw   r0   rm   )r4   rJ  r9   r:   s      r;   rm    RichMetadata._getPluralAttribute	  s@     AAA D0E}w8Ow*=99r=   Fc                    S/n[         R                  S/5        U H<  n[        X5      nUb	  U(       a  M   Ub  [        X5      nUb  [        XU5        M:  M<  M>     g! [         a     MN  f = f)a  
Given another Metadata or RichMetadata object, combine
all attributes and return a new object.

>>> md = metadata.Metadata(title='Concerto in F')
>>> md.title
'Concerto in F'

>>> richMetadata = metadata.RichMetadata()
>>> richMetadata.merge(md)
>>> richMetadata.title
'Concerto in F'

r2   zRichMetadata: calling merge()N)environLocal
printDebugr  r3   r   )r4   other	favorSelf
localNamesrD   
localValue
otherValues          r;   mergeRichMetadata.merge	  s    $ 

 	!@ ABD ,J %)(%,U%9
%1#D
; 2 )  & s   A
A+*A+c                   UR                   (       d  gUR                   nUR                  (       a  UR                  $ UR                  nU(       d  g[        U[        R
                  5      (       d  [        R
                  " U5      n UR                  [        R                  " 5       5      nUR                  5       $ ! [         a    UR                  5       s $ f = f)z
Get a string of the path after the corpus for the piece.  Useful for
searching on corpus items without proper composer data.

>>> rmd = metadata.RichMetadata()
>>> b = corpus.parse('bwv66.6')
>>> rmd.getSourcePath(b)
'bach/bwv66.6.mxl'
r4  )r#   r   r   r   pathlibPathrelative_tor   getCorpusFilePathas_posixr   )r4   	streamObjmdstreamFprelativePaths        r;   getSourcePathRichMetadata.getSourcePath	  s     !!$$$;;(GLL11||H-H	'#//0H0H0JKL((** 	'$$&&	's   3B: :CCc                h   SSK Jn  SSK Jn  SSK Jn  [        R                  S/5        UR                  5       R                  5       n[        UR                  5      U l
        SU l        / U l        SU l        / U l        SU l        / U l        U R#                  U5      U l        U GH  n['        XcR(                  5      (       a:  UR*                  nXpR                   ;  a  U R                   R-                  U5        MV  MX  ['        XbR.                  5      (       aC  UR0                  U R                  ;  a'  U R                  R-                  UR0                  5        M  M  ['        XdR2                  5      (       d  M  [5        U5      nXR                  ;  d  M  U R                  R-                  U5        GM     U R                   (       a  U R                   S   U l        U R                  (       a  U R                  S   U l        U R                  (       a  U R                  S   U l        [        UR6                  5      U l        UR:                  U l        SSKJ n	  SU l!        SU l"        SU l#        U	RI                  U5      n
U
RJ                  bC  U
RL                  b6  U
RJ                  RN                  U l#        U
RL                  RN                  U l"        U
RQ                  U5      nUc  [R        RT                  " S5      n[W        URX                  URZ                  R\                  U RF                  U RD                  S	9U l!        g)
a,  
Given a Stream object, update attributes with stored objects.

>>> rmd = metadata.RichMetadata()
>>> rmd.keySignatureFirst is None
True
>>> rmd.sourcePath
''

>>> b = corpus.parse('bwv66.6')
>>> rmd.update(b)
>>> rmd.keySignatureFirst
3
>>> rmd.sourcePath
'bach/bwv66.6.mxl'
>>> rmd.numberOfParts
4
r   )r   )meter)tempozRichMetadata: update(): startN)discreteP1r$   )/music21r   r  r  r  r  flattenr   r<  partsr  r  r  r  r  r  r  r  r  r   TimeSignatureratioStringrv   KeySignaturer   TempoIndicationr   notesAndRestsr  highestTimer  music21.analysisr  r  r(   r'   AmbitusminPitchObjmaxPitchObjnameWithOctavegetSolutionr   Intervalr   r%   r&   
simpleName)r4   r  r   r  r  flatelementr  tempoIndicationStringr  analysisObjectambitusIntervals               r;   updateRichMetadata.update
  s   & 	 !!!@ AB  "))+ 1!%"& ,,Y7 G'#6#677%11&9&99''..{; :G%5%566>>););;&&--gnn= <G%:%:;;(+G%(;KK&&'<=  &*&9&9!&<D#%)%7%7%:D";;"kk!nDO( T//0!-- 	. !)))4%%1n6P6P6\  .99HHD . : : I ID(44Y?"&//5O#o.G.G-<-E-E-P-P040@0@151B1B&r=   Tr   c          	       > [        [        TU ]	  UUUUS95      nU(       a  [        U5      $ U R                   H  nUR                  U[        X5      45        M!     U(       a  [        [        U5      5      $ [        U5      $ )u  
Returns all values stored in this RichMetadata as a Tuple of Tuples.
Each individual Metadata Tuple is (uniqueName, value) and each additional
RichMetadata tuple is (name, richAttributeValue).

>>> rmd = metadata.RichMetadata()
>>> c = corpus.parse('corelli/opus3no1/1grave')
>>> rmd.merge(c.metadata)
>>> rmd.update(c)
>>> rmd.all()
(('ambitus',
    AmbitusShort(semitones=48, diatonic='P1', pitchLowest='C2', pitchHighest='C6')),
 ('arranger', 'Michael Scott Cuthbert'),
 ('composer', 'Arcangelo Corelli'),
 ...
 ('sourcePath', 'corelli/opus3no1/1grave.xml'),
 ('tempoFirst', '<music21.tempo.MetronomeMark Quarter=60 (playback only)>'),
 ('tempos', ['<music21.tempo.MetronomeMark Quarter=60 (playback only)>']),
 ('timeSignatureFirst', '4/4'),
 ('timeSignatures', ['4/4']))

>>> rmd.dateCreated = metadata.DateRelative('1689', 'onOrBefore')
>>> rmd.localeOfComposition = 'Rome'
>>> rmd.all(skipContributors=True)
(('ambitus',
    AmbitusShort(semitones=48, diatonic='P1', pitchLowest='C2', pitchHighest='C6')),
 ('copyright', '© 2014, Creative Commons License (CC-BY)'),
 ('corpusFilePath', 'corelli/opus3no1/1grave.xml'),
 ('dateCreated', '1689/--/-- or earlier'),
 ('fileFormat', 'musicxml'),
 ...
 ('keySignatures', [-1]),
 ('localeOfComposition', 'Rome'),
 ('movementName', 'Sonata da Chiesa, No. I (opus 3, no. 1)'),
 ...
 ('timeSignatures', ['4/4']))

>>> rmd.all(returnPrimitives=True, returnSorted=False)
(('software', <music21.metadata.primitives.Text music21 ...>),
 ('software', <music21.metadata.primitives.Text Finale 2014 for Mac>),
 ('software', <music21.metadata.primitives.Text Dolet Light for Finale 2014>),
 ('movementName', <...Text Sonata da Chiesa, No. I (opus 3, no. 1)>),
 ('composer', <music21.metadata.primitives.Contributor composer:Arcangelo Corelli>),
 ...
 ('timeSignatures', ['4/4']))

>>> rmd.all(skipNonContributors=True, returnPrimitives=True, returnSorted=True)
(('arranger', <music21.metadata.primitives.Contributor arranger:Michael Scott Cuthbert>),
 ('composer', <music21.metadata.primitives.Contributor composer:Arcangelo Corelli>))
r   )listr0   ru   rw   r  rv   r  r   )r4   r   rr   rs   rt   r   rD   r:   s          r;   ru   RichMetadata.ally
  s    t +/uw{- 3-%	 0; 0' +( =  99DMM4!456 : ((V}r=   c                P   > [         TU ]  U5      (       a  gXR                  ;   a  gg)a8  
Determines if a unique name is associated with a standard property.
Returns False if no such associated standard property can be found.

Example: a RichMetadata additional attribute name returns True

>>> rmd = metadata.RichMetadata()
>>> rmd._isStandardUniqueName('ambitus')
True

Example: a standard contributor uniqueName returns True

>>> rmd._isStandardUniqueName('librettist')
True

Example: a standard 'namespace:name' returns False (it is a standard
namespaceName, but not a standard uniqueName)

>>> rmd._isStandardUniqueName('marcrel:LBT')
False

Example: a standard non-contributor uniqueName returns True

>>> rmd._isStandardUniqueName('alternativeTitle')
True

Example: a custom (non-standard) name returns False (it is not
a standard name of any sort)

>>> rmd._isStandardUniqueName('average duration')
False
TF)r0   rh   r  )r4   rV   r:   s     r;   rh   "RichMetadata._isStandardUniqueName
  s+    B 7(44>>>r=   ry  )F)rs  r   r|  r  )rM  r  r  r  r  r  r1   rm   r  r  r  ru   rh   r  r  r  s   @r;   r   r   ~	  s    6($$! :"H'>i&\ &+(-%*!%K #K "&	K
 #K K 
'K KZ% %r=   r   z
list[type]
_DOC_ORDER__main__)9r  
__future__r   __all__collectionsr   collections.abcr   copydataclassesr	   ro  r  r   typingr   r
   unittestr  r   r   music21.commonr   r   r   r   r   music21.metadatar   music21.metadata.propertiesr   r   r   r   music21.metadata.primitivesr   r   r   r   r   r   r   r   r   r    r!   r"   Environmentr  r   Music21Objectr   r   r  __annotations__rM  mainTestr-   r=   r;   <module>r     s   ul # # $  !   	      %      ' ; $ $ 'H H H H
 &&z2.RTJ#Rt!! J#R\Fm8 md 
J  z r=   