Mercurial > dottes
diff abcfirstline.py @ 50:e666306c5ab1
Add list of tune first lines.
Add a list of tune first lines to the Booke. First, a small Python script to
filter a .abc file and spit out just enough to give a graphic of the first line
without the title. Then generate these graphics and generate a new section in the Booke
with a longtable of tune name and the first line graphic.
author | Jim Hague <jim.hague@laicatc.com> |
---|---|
date | Sun, 04 Mar 2012 20:16:48 +0000 |
parents | |
children | 00a1bef43a34 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/abcfirstline.py Sun Mar 04 20:16:48 2012 +0000 @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# +# Write out a modified version of a .abc file with just the data +# to print the first line of the music only. +# + +import sys + +def process(inf): + print "X:1" + for line in inf: + line = line.strip() + start = line[:2] + if start[0] != "|" and start[1] == ":": + if start[0] in ["M", "K", "L"]: + print line + elif start[0] != "%": + print line + if line[-1] != "\\": + break + +if len(sys.argv) > 1: + for arg in sys.argv[1:]: + try: + inf = open(arg, "r") + process(inf) + finally: + inf.close() +else: + process(sys.stdin)