File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -96,8 +96,8 @@ def iterate_partgroup(self, group):
9696
9797 def iterate_part (self , part ):
9898 """The part is iterated."""
99- if part .barlist :
100- last_bar = part . barlist [ - 1 ]
99+ last_bar = part .last_bar ()
100+ if last_bar :
101101 last_bar_objs = last_bar .obj_list
102102 part .set_first_bar (self .divisions )
103103 self .musxml .create_part (part .name , part .abbr , part .midi )
@@ -458,6 +458,12 @@ def extract_global_to_section(self, name):
458458 section .barlist .append (section_bar )
459459 return section
460460
461+ def last_bar (self ):
462+ """Returns the last Bar object in the score, or None if the score is empty."""
463+ for obj in reversed (self .barlist ):
464+ if isinstance (obj , Bar ):
465+ return obj
466+
461467
462468class Bar ():
463469 """ Representing the bar/measure.
You can’t perform that action at this time.
0 commit comments