Skip to content

Commit 62516b2

Browse files
authored
Merge pull request #1839 from cuthbertLab/addIdentificationToMetadata
2 parents 8074f3c + 95c8dd2 commit 62516b2

File tree

3 files changed

+39
-16
lines changed

3 files changed

+39
-16
lines changed

music21/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
'''
5151
from __future__ import annotations
5252

53-
__version__ = '10.0.1b2'
53+
__version__ = '10.0.1b3'
5454

5555
def get_version_tuple(vv):
5656
v = vv.split('.')

music21/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<class 'music21.base.Music21Object'>
2828
2929
>>> music21.VERSION_STR
30-
'10.0.1b2'
30+
'10.0.1b3'
3131
3232
Alternatively, after doing a complete import, these classes are available
3333
under the module "base":

music21/musicxml/xmlToM21.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,11 @@ def partGroups(self):
11911191
self.spannerBundle.append(staffGroup)
11921192
# self.stream.coreInsert(0, staffGroup)
11931193

1194-
def xmlMetadata(self, el=None, inputM21=None):
1194+
def xmlMetadata(
1195+
self,
1196+
el: ET.Element|None = None,
1197+
inputM21: metadata.Metadata|None = None
1198+
) -> metadata.Metadata|None:
11951199
'''
11961200
Converts part of the root element into a metadata object
11971201
@@ -1234,17 +1238,24 @@ def xmlMetadata(self, el=None, inputM21=None):
12341238

12351239
identification = el.find('identification')
12361240
if identification is not None:
1237-
self.identificationToMetadata(identification, md)
1241+
self.addIdentificationToMetadata(identification, md)
12381242

12391243
if inputM21 is None:
12401244
return md
1245+
return None
1246+
12411247

1242-
def identificationToMetadata(self,
1243-
identification: ET.Element,
1244-
inputM21: metadata.Metadata|None = None):
1248+
def addIdentificationToMetadata(
1249+
self,
1250+
identification: ET.Element,
1251+
md: metadata.Metadata,
1252+
) -> None:
12451253
'''
1246-
Convert an <identification> tag, containing <creator> tags, <rights> tags, and
1247-
<miscellaneous> tag.
1254+
Given an <identification> tag, , containing <creator> tags, <rights> tags, and
1255+
<miscellaneous> tags etc., add this information to the
1256+
:class:`~music21.metadata.Metadata` object passed in.
1257+
1258+
(Replaces identificationToMetadata which is now deprecated.)
12481259
12491260
Not supported: source, relation
12501261
@@ -1254,11 +1265,6 @@ def identificationToMetadata(self,
12541265
new-system (definesExplicitSystemBreaks) and
12551266
new-page (definesExplicitPageBreaks)
12561267
'''
1257-
if inputM21 is not None:
1258-
md = inputM21
1259-
else:
1260-
md = metadata.Metadata()
1261-
12621268
for creator in identification.findall('creator'):
12631269
c = self.creatorToContributor(creator)
12641270
if md.isContributorUniqueName(c.role):
@@ -1295,8 +1301,25 @@ def identificationToMetadata(self,
12951301
# so nothing is lost.
12961302
md.addCustom(miscFieldName, miscFieldValue)
12971303

1298-
if inputM21 is None:
1304+
@common.deprecated('use addIdentificationToMetadata', 'v10', 'v11')
1305+
def identificationToMetadata(
1306+
self,
1307+
identification: ET.Element,
1308+
inputM21: metadata.Metadata|None = None
1309+
) -> metadata.Metadata|None:
1310+
'''
1311+
Deprecated -- use addIdentificationToMetadata instead and always
1312+
pass in a metadata object.
1313+
'''
1314+
if inputM21 is not None:
1315+
md = inputM21
1316+
else:
1317+
md = metadata.Metadata()
1318+
self.addIdentificationToMetadata(identification, md)
1319+
if inputM21 is not None:
12991320
return md
1321+
return None
1322+
13001323

13011324
@staticmethod
13021325
def isRecognizableMetadataKey(miscFieldName: str) -> bool:
@@ -5046,7 +5069,7 @@ def findM21VoiceFromXmlVoice(
50465069

50475070
return thisVoice
50485071

5049-
def xmlBarline(self, mxBarline):
5072+
def xmlBarline(self, mxBarline: ET.Element) -> None:
50505073
'''
50515074
Handles everything for putting a barline into a Stream
50525075
and updating repeat characteristics.

0 commit comments

Comments
 (0)