File: gen_rhythms_table.py

package info (click to toggle)
solfege 3.16.4-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 34,472 kB
  • ctags: 5,287
  • sloc: python: 22,642; xml: 14,196; ansic: 4,682; makefile: 621; sh: 287
file content (26 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python

import os
import sys
# We need to do this on the build server. For some reason, it is not
# necessary on my workstation.
sys.path.insert(0, os.getcwdu())

import solfege.const

img_str = """%i:<inlinemediaobject>
      <imageobject>
        <imagedata fileref="../../graphics/rhythm-%s.png" format="PNG"/>
      </imageobject>
      <textobject>
       <phrase>%s</phrase>
      </textobject>
    </inlinemediaobject>"""
f = open("help/C/rhythmtable.xml", "w")
print >> f, "<para>"
for i, r in enumerate(solfege.const.RHYTHMS):
    print >> f, img_str % (i, r.replace(" ", ""), r),
    if i != len(solfege.const.RHYTHMS) - 1:
        print >> f, ", "
print >> f, "</para>"
f.close()