* stepmake/stepmake/omf-targets.make (local-install): add
[lilypond.git] / buildscripts / lys-to-tely.py
blobc07524cfb65712977a7c24c489ca22783390ca22
1 #!@PYTHON@
4 '''
5 TODO:
7 * Add @nodes, plit at sections?
8 * Less kludged first introduction file
9 * include *.texi files for text at start of section?
11 '''
14 import sys
15 import os
16 import string
17 import getopt
19 program_name = 'lys-to-tely'
21 def help ():
22 sys.stdout.write (r"""Usage: lys-to-tely [OPTION]... LY-FILE...
23 Construct tely doc from LY-FILEs.
25 Options:
26 -h, --help print this help
27 -o,output=NAME write tely doc to NAME
28 -t,title=TITLE set tely tely doc title TITLE
29 """)
30 sys.exit (0)
32 (options, files) = getopt.getopt(sys.argv[1:], 'hn:t:', [
33 'help', 'name=', 'title='])
35 name="ly-doc"
36 title="Ly Doc"
37 for opt in options:
38 o = opt[0]
39 a = opt[1]
40 if o == '-h' or o == '--help':
41 help ()
42 elif o == '-n' or o == '--name':
43 name = a
44 elif o == '-t' or o == '--title':
45 title = a
46 else:
47 raise 'unknown opt ', o
49 def strip_extension (f, ext):
50 (p, e) = os.path.splitext (f)
51 if e == ext:
52 e = ''
53 return p + e
55 if files:
56 dir = os.path.dirname (name)
57 if not dir:
58 dir = "."
59 name = strip_extension (os.path.basename (name), ".tely")
61 s = '''\input texinfo
62 @setfilename %s.info
63 @settitle %s
65 @c fool ls-latex
66 @ignore
67 @author Han-Wen Nienhuys and Jan Nieuwenhuizen
68 @title %s
69 @end ignore
71 @node Top, , , (dir)
72 ''' % (name, title, title)
74 def name2line (n):
75 # UGR
76 s = "@lilypondfile[printfilename]{%s}" % n
77 return s
79 s = s + string.join (map (lambda x: name2line (x), files), "\n")
80 s = s + '\n@bye\n'
81 f = "%s/%s.tely" % (dir, name)
82 sys.stderr.write ("%s: writing %s..." % (program_name, f))
83 h = open (f, "w")
84 h.write (s)
85 h.close ()
86 sys.stderr.write ('\n')
87 else:
88 # not Unix philosophy, but hey, at least we notice when
89 # we don't distribute any .ly files.
90 sys.stderr.write ("No files specified. Doing nothing")