comparison 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
comparison
equal deleted inserted replaced
49:ac3bbc2195c1 50:e666306c5ab1
1 #!/usr/bin/env python
2 #
3 # Write out a modified version of a .abc file with just the data
4 # to print the first line of the music only.
5 #
6
7 import sys
8
9 def process(inf):
10 print "X:1"
11 for line in inf:
12 line = line.strip()
13 start = line[:2]
14 if start[0] != "|" and start[1] == ":":
15 if start[0] in ["M", "K", "L"]:
16 print line
17 elif start[0] != "%":
18 print line
19 if line[-1] != "\\":
20 break
21
22 if len(sys.argv) > 1:
23 for arg in sys.argv[1:]:
24 try:
25 inf = open(arg, "r")
26 process(inf)
27 finally:
28 inf.close()
29 else:
30 process(sys.stdin)