8 program_name
= 'lys-to-tely'
11 sys
.stdout
.write (r
"""Usage: lys-to-tely [OPTION]... LY-FILE...
12 Construct tely doc from LY-FILEs.
15 -h, --help print this help
16 -o,output=NAME write tely doc to NAME
17 -t,title=TITLE set tely tely doc title TITLE
21 (options
, files
) = getopt
.getopt(sys
.argv
[1:], 'hn:t:', [
22 'help', 'name=', 'title='])
29 if o
== '-h' or o
== '--help':
31 elif o
== '-n' or o
== '--name':
33 elif o
== '-t' or o
== '--title':
36 raise 'unknown opt ', o
38 def strip_extension (f
, ext
):
39 (p
, e
) = os
.path
.splitext (f
)
45 dir = os
.path
.dirname (name
)
48 name
= strip_extension (os
.path
.basename (name
), ".tely")
56 @author Han-Wen Nienhuys and Jan Nieuwenhuizen
61 ''' % (name
, title
, title
)
65 if string
.find (n
, '+') >= 0:
66 s
= "@lilypondfile{%s}" % n
68 s
= "@lilypondfile[printfilename]{%s}" % n
71 s
= s
+ string
.join (map (lambda x
: name2line (x
), files
), "\n")
73 f
= "%s/%s.tely" % (dir, name
)
74 sys
.stderr
.write ("%s: writing %s..." % (program_name
, f
))
78 sys
.stderr
.write ('\n')