Skip to content

Commit 3e9bfd0

Browse files
Proposed solution for PR cuthbertLab#1636. Note that I had to check md['software'] as it was being constructed, instead of afterward, because Metadata() actually adds a software item for the music21 version that read the file, and I don't want to be confused by that.
1 parent 41b6b6f commit 3e9bfd0

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

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__ = '9.6.0b4'
53+
__version__ = '9.6.0b19'
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-
'9.6.0b4'
30+
'9.6.0b19'
3131
3232
Alternatively, after doing a complete import, these classes are available
3333
under the module "base":

music21/musicxml/xmlToM21.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ def __init__(self):
769769
self.parts = []
770770

771771
self.musicXmlVersion = defaults.musicxmlVersion
772+
self.wasWrittenByFinale = False
772773

773774
def scoreFromFile(self, filename):
774775
'''
@@ -1326,9 +1327,17 @@ def processEncoding(self, encoding: ET.Element, md: metadata.Metadata) -> None:
13261327
# TODO: encoder (text + type = role) multiple
13271328
# TODO: encoding date multiple
13281329
# TODO: encoding-description (string) multiple
1330+
finaleFound: bool = False
1331+
nonFinaleFound: bool = False
13291332
for software in encoding.findall('software'):
13301333
if softwareText := strippedText(software):
1334+
if 'Finale' in softwareText:
1335+
finaleFound = True
1336+
else:
1337+
nonFinaleFound = True
13311338
md.add('software', softwareText)
1339+
if finaleFound and not nonFinaleFound:
1340+
self.wasWrittenByFinale = True
13321341

13331342
for supports in encoding.findall('supports'):
13341343
# todo: element: required
@@ -2630,18 +2639,19 @@ def xmlForward(self, mxObj: ET.Element):
26302639
if durationText := strippedText(mxDuration):
26312640
change = opFrac(float(durationText) / self.divisions)
26322641

2633-
# Create hidden rest (in other words, a spacer)
2634-
# old Finale documents close incomplete final measures with <forward>
2635-
# this will be removed afterward by removeEndForwardRest()
2636-
r = note.Rest(quarterLength=change)
2637-
r.style.hideObjectOnPrint = True
2638-
self.addToStaffReference(mxObj, r)
2639-
self.insertInMeasureOrVoice(mxObj, r)
2642+
if self.parent.parent.wasWrittenByFinale:
2643+
# Create hidden rest (in other words, a spacer)
2644+
# old Finale documents close incomplete final measures with <forward>
2645+
# this will be removed afterward by removeEndForwardRest()
2646+
r = note.Rest(quarterLength=change)
2647+
r.style.hideObjectOnPrint = True
2648+
self.addToStaffReference(mxObj, r)
2649+
self.insertInMeasureOrVoice(mxObj, r)
2650+
# xmlToNote() sets None
2651+
self.endedWithForwardTag = r
26402652

26412653
# Allow overfilled measures for now -- TODO(someday): warn?
26422654
self.offsetMeasureNote += change
2643-
# xmlToNote() sets None
2644-
self.endedWithForwardTag = r
26452655

26462656
def xmlPrint(self, mxPrint: ET.Element):
26472657
'''

0 commit comments

Comments
 (0)