Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import xml.etree.ElementTree as ET
  2. import zipfile
  3. import sys
  4.  
  5. # reads from a musescore save file and outputs the text in the order typically shown on the sheet.
  6. # not finished, i.e. arguments are not implemented, but functional. Dashses are not supported.
  7.  
  8. for a in sys.argv:
  9. if not a is None:
  10. print(a) # args ..
  11.  
  12.  
  13. zarchive = zipfile.ZipFile('1.mscz')
  14. tree = ET.parse(zarchive.open('1.mscx'))
  15. chords = tree.findall('.//Chord')
  16. text = []
  17. for chord in chords:
  18. count = 0;
  19. for lyrics in chord.iter('Lyrics'):
  20. for l in lyrics.iter('text'):
  21. for k in l.itertext():
  22. if count >= len(text):
  23. text.append('')
  24. text[count] += k
  25. text[count] += ' '
  26. count += 1
  27. # print text
  28. for t in text:
  29. print(t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement