7 lilypond-book --filter="tr '[a-z]' '[A-Z]'" BOOK
10 lilypond-book --filter="convert-ly --no-version --from=1.6.11 -" BOOK
12 classic lilypond-book:
13 lilypond-book --process="lilypond" BOOK.tely
16 * ly-options: intertext ?
18 * eps in latex / eps by lilypond -fps ?
19 * check latex parameters, twocolumn, multicolumn?
21 * Converting from lilypond-book source, substitute:
22 @mbinclude foo.itely -> @include foo.itely
35 # * use --png --ps --pdf for making images?
38 ################################################################
39 # Users of python modules should include this snippet
40 # and customize variables below.
42 # We'll suffer this path init stuff as long as we don't install our
43 # python packages in <prefix>/lib/pythonx.y (and don't kludge around
44 # it as we do with teTeX on Red Hat Linux: set some environment var
45 # (PYTHONPATH) in profile)
47 # If set, LILYPONDPREFIX must take prevalence
48 # if datadir is not set, we're doing a build and LILYPONDPREFIX
49 import getopt, os, sys
50 datadir = '@local_lilypond_datadir@'
51 if not os.path.isdir (datadir):
52 datadir = '@lilypond_datadir@'
53 if os.environ.has_key ('LILYPONDPREFIX'):
54 datadir = os.environ['LILYPONDPREFIX']
55 while datadir[-1] == os.sep:
58 sys.path.insert (0, os.path.join (datadir, 'python'))
61 #if __name__ == '__main__':
69 program_version = '@TOPLEVEL_VERSION@'
70 program_name = sys.argv[0]
73 original_dir = os.getcwd ()
76 help_summary = _ ("""Process LilyPond snippets in hybrid HTML, LaTeX or texinfo document.
79 lilypond-book --filter="tr '[a-z]' '[A-Z]'" BOOK
80 lilypond-book --filter="convert-ly --no-version --from=2.0.0 -" BOOK
81 lilypond-book --process='lilypond -I include' BOOK
85 copyright = ('Jan Nieuwenhuizen <janneke@gnu.org>',
86 'Han-Wen Nienhuys <hanwen@cs.uu.nl>')
88 option_definitions = [
89 (_ ("EXT"), 'f', 'format', _ ("use output format EXT (texi [default], texi-html, latex, html)")),
90 (_ ("FILTER"), 'F', 'filter', _ ("pipe snippets through FILTER [convert-ly -n -]")),
91 ('', 'h', 'help', _ ("print this help")),
92 (_ ("DIR"), 'I', 'include', _ ("add DIR to include path")),
93 (_ ("COMMAND"), 'P', 'process', _ ("process ly_files using COMMAND FILE...")),
94 (_ ("DIR"), 'o', 'output', _ ("write output to DIR")),
95 ('', 'V', 'verbose', _ ("be verbose")),
96 ('', 'v', 'version', _ ("print version information")),
97 ('', 'w', 'warranty', _ ("show warranty and copyright")),
100 include_path = [ly.abspath (os.getcwd ())]
101 lilypond_binary = os.path.join ('@bindir@', 'lilypond')
103 # only use installed binary when we're installed too.
104 if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary):
105 lilypond_binary = 'lilypond'
111 latex_filter_cmd = 'latex "\\nonstopmode \input /dev/stdin"'
114 default_ly_options = {}
117 # is this pythonic? Personally, I find this rather #define-nesque. --hwn
121 EXAMPLEINDENT = 'exampleindent'
123 FRAGMENT = 'fragment'
128 LINEWIDTH = 'linewidth'
129 NOFRAGMENT = 'nofragment'
130 NOINDENT = 'noindent'
135 PREAMBLE = 'preamble'
136 PRINTFILENAME = 'printfilename'
138 RAGGEDRIGHT = 'raggedright'
139 RELATIVE = 'relative'
140 STAFFSIZE = 'staffsize'
143 VERBATIM = 'verbatim'
145 # Recognize special sequences in the input;
147 # (?P<name>regex) -- assign result of REGEX to NAME
148 # *? -- match non-greedily.
149 # (?m) -- multiline regex: make ^ and $ match at each line
150 # (?s) -- make the dot match all characters including newline
151 # (?x) -- ignore whitespace in patterns
161 ((?P<options>[^:]*):)
178 (?P<filename>[^<]+)\s*
184 (?P<code><!--\s.*?!-->)
186 'singleline_comment':
191 (?P<code><pre>.*?</pre>))''',
196 (?P<code><pre>\s.*?</pre>\s))''',
227 \\end\s*{lilypond})''',
240 'singleline_comment':
261 \\end\s*{verbatim}))''',
269 (?P<filename>\S+))''',
272 ^[^\n]*?(?!@c\s+)[^\n]*?
288 ^@end\s+lilypond)\s''',
304 @end\s+ignore))\s''',
305 'singleline_comment':
310 @c([ \t][^\n]*|)\n))''',
312 # don't do this: fucks up with @code{@{}
313 # 'verb': r'''(?P<code>@code{.*?})''',
320 @end\s+example\s))''',
327 'intertext': r',?\s*intertext=\".*?\"',
330 'intertext': r',?\s*intertext=\".*?\"',
331 'option-sep': ',\s*',
334 'intertext': r',?\s*intertext=\".*?\"',
335 'option-sep': ',\s*',
341 RELATIVE: r'''\relative c%(relative_quotes)s''',
345 indent = %(indent)s''',
347 linewidth = %(linewidth)s''',
351 linewidth = %(linewidth)s - 2.0 * %(exampleindent)s
355 raggedright = ##t''',
365 \remove Time_signature_engraver
372 #(set-global-staff-size %(staffsize)s)''',
378 FILTER: r'''<lilypond %(options)s>
387 <a href="%(base)s.ly">''',
389 <img align="center" valign="center"
390 border="0" src="%(image)s" alt="[image of music]">''',
391 PRINTFILENAME:'<p><tt><a href="%(base)s.ly">%(filename)s</a></tt></p>',
392 QUOTE: r'''<blockquote>
403 OUTPUT: r'''{\parindent 0pt
405 \ifx\preLilyPondExample\undefined\relax\else\preLilyPondExample\fi
406 \def\lilypondbook{}%%
408 \ifx\postLilyPondExample\undefined\relax\else\postLilyPondExample\fi
410 PRINTFILENAME: '''\\texttt{%(filename)s}
412 QUOTE: r'''\begin{quotation}
416 VERBATIM: r'''\noindent
418 %(verb)s\end{verbatim}
420 FILTER: r'''\begin{lilypond}[%(options)s]
426 FILTER: r'''@lilypond[%(options)s]
431 OUTPUT: r'''@noindent
432 @image{%(base)s,,,[image of music],%(ext)s}''',
433 PRINTFILENAME: '''@file{%(filename)s}
435 QUOTE: r'''@quotation
439 # FIXME: @exampleindent 5 is the default...
440 VERBATIM: r'''@exampleindent 0
448 PREAMBLE_LY = r"""%%%% Generated by %(program_name)s
449 %%%% Options: [%(option_string)s]
450 #(set! toplevel-score-handler ly:parser-print-score)
451 #(set! toplevel-music-handler (lambda (p m)
452 (ly:parser-print-score
453 p (ly:music-scorify m p))
457 #(define dump-extents #t)
460 \layout { %(layout_string)s
471 texinfo_linewidths = {
472 '@afourpaper': '160 \\mm',
473 '@afourwide': '6.5 \\in',
474 '@afourlatex': '150 \\mm',
475 '@smallbook': '5 \\in' ,
476 '@letterpaper': '6\\in',
479 def classic_lilypond_book_compatibility (o):
480 if o == 'singleline':
482 m = re.search ('relative\s*([-0-9])', o)
484 return 'relative=%s' % m.group (1)
485 m = re.match ('([0-9]+)pt', o)
487 return 'staffsize=%s' % m.group (1)
488 m = re.match ('indent=([-.0-9]+)(cm|in|mm|pt|staffspace)', o)
490 f = float (m.group (1))
491 return 'indent=%f\\%s' % (f, m.group (2))
492 m = re.match ('linewidth=([-.0-9]+)(cm|in|mm|pt|staffspace)', o)
494 f = float (m.group (1))
495 return 'linewidth=%f\\%s' % (f, m.group (2))
498 def compose_ly (code, options):
500 for i in default_ly_options.keys ():
505 if QUOTE in options and LINEWIDTH in options:
506 options.remove (LINEWIDTH)
508 if FRAGMENT in options:
509 if RAGGEDRIGHT not in options:
510 options.append (RAGGEDRIGHT)
519 #FIXME: where to get sane value for exampleindent?
520 override[EXAMPLEINDENT] = r'9.0 \mm'
521 override[LINEWIDTH] = None
522 override.update (default_ly_options)
524 option_string = string.join (options, ',')
527 option_types = [NOTES, PREAMBLE, LAYOUT, PAPER]
528 for a in option_types:
532 c = classic_lilypond_book_compatibility (i)
534 ly.warning (_ ("deprecated ly-option used: %s" % i))
535 ly.warning (_ ("compatibility mode translation: %s" \
539 if string.find (i, '=') > 0:
540 key, value = string.split (i, '=')
541 override[key] = value
544 if not override.has_key (i):
548 for type in option_types:
549 if ly_options[type].has_key (key):
551 options_dict[type].append (ly_options[type][key])
555 if not found and key not in (FRAGMENT, NOFRAGMENT, PRINTFILENAME,
556 RELATIVE, VERBATIM, TEXIDOC):
557 ly.warning (_("ignoring unknown ly option: %s") % i)
560 if RELATIVE in override.keys () and override[RELATIVE]:
561 relative = string.atoi (override[RELATIVE])
567 relative_quotes += ',' * (- relative)
569 relative_quotes += "'" * relative
571 program_name = __main__.program_name
573 paper_string = string.join (options_dict[PAPER], '\n ') % override
574 layout_string = string.join (options_dict[LAYOUT], '\n ') % override
575 notes_string = string.join (options_dict[NOTES], '\n ') % vars ()
576 preamble_string = string.join (options_dict[PREAMBLE], '\n ') % override
577 return (PREAMBLE_LY + body) % vars ()
581 # use lilypond for latex (.lytex) books,
582 # and lilypond --preview for html, texinfo books?
584 cmd = r'latex "\nonstopmode \input %s"' % file
585 # Ugh. (La)TeX writes progress and error messages on stdout
587 cmd = '(( %s >&2 ) >&- )' % cmd
589 ly.system ('dvips -Ppdf -u+ec-mftrace.map -u+lilypond.map -E -o %s.eps %s' \
593 # check if it really is EPS.
594 # Otherwise music glyphs disappear from 2nd and following pages.
596 # TODO: should run dvips -pp -E per page, then we get proper
599 f = open ('%s.eps' % file)
600 for x in range(0,10):
601 if re.search ("^%%Pages: ", f.readline ()):
604 ly.system ('dvips -Ppdf -u+ec-mftrace.map -u+lilypond.map -o %s.eps %s' \
609 def find_file (name):
610 for i in include_path:
611 full = os.path.join (i, name)
612 if os.path.exists (full):
614 ly.error (_ ('file not found: %s') % name + '\n')
618 def verbatim_html (s):
619 return re.sub ('>', '>',
621 re.sub ('&', '&', s)))
623 def verbatim_texinfo (s):
624 return re.sub ('{', '@{',
626 re.sub ('@', '@@', s)))
628 def split_options (option_string):
629 return re.split (format_res[format]['option-sep'], option_string)
633 def replacement_text (self):
636 def filter_text (self):
637 return self.replacement_text ()
640 def ly_is_outdated (self):
643 def png_is_outdated (self):
646 class Substring (Chunk):
647 def __init__ (self, source, start, end):
652 def replacement_text (self):
653 return self.source [self.start:self.end]
655 class Snippet (Chunk):
656 def __init__ (self, type, match, format):
663 def replacement_text (self):
664 return self.match.group ('match')
666 def substring (self, s):
667 return self.match.group (s)
670 return `self.__class__` + " type = " + self.type
672 class Include_snippet (Snippet):
673 def processed_filename (self):
674 f = self.substring ('filename')
675 return os.path.splitext (f)[0] + format2ext[format]
677 def replacement_text (self):
678 s = self.match.group ('match')
679 f = self.substring ('filename')
681 return re.sub (f, self.processed_filename (), s)
683 class Lilypond_snippet (Snippet):
684 def __init__ (self, type, match, format):
685 Snippet.__init__ (self, type, match, format)
686 os = match.group ('options')
688 self.options = split_options (os)
691 return self.substring ('code')
696 return compose_ly (s, self.options)
702 self.hash = abs (hash (self.full_ly ()))
707 return 'lily-%d' % self.get_hash ()
711 outf = open (self.basename () + '.ly', 'w')
712 outf.write (self.full_ly ())
714 open (self.basename() + '.txt', 'w').write("image of music")
717 def ly_is_outdated (self):
718 base = self.basename ()
720 tex_file = '%s.tex' % base
721 ly_file = '%s.ly' % base
722 ok = os.path.exists (ly_file) and os.path.exists (tex_file)\
723 and os.stat (tex_file)[stat.ST_SIZE] \
724 and open (tex_file).readlines ()[-1][1:-1] \
727 if ok and (use_hash_p or self.ly () == open (ly_file).read ()):
728 # TODO: something smart with target formats
729 # (ps, png) and m/ctimes
733 def png_is_outdated (self):
734 base = self.basename ()
735 ok = self.ly_is_outdated ()
736 if format == HTML or format == TEXINFO:
737 ok = ok and (os.path.exists (base + '.png')
738 or glob.glob (base + '-page*.png'))
741 def filter_text (self):
742 code = self.substring ('code')
743 s = run_filter (code)
746 'options': self.match.group ('options')
749 return output[self.format][FILTER] % d
751 def replacement_text (self):
752 func = Lilypond_snippet.__dict__ ['output_' + self.format]
755 def get_images (self):
756 base = self.basename ()
758 single = '%(base)s.png' % vars ()
759 multiple = '%(base)s-page1.png' % vars ()
761 if os.path.exists (multiple) \
762 and (not os.path.exists (single)\
763 or (os.stat (multiple)[stat.ST_MTIME] \
764 > os.stat (single)[stat.ST_MTIME])):
765 images = glob.glob ('%(base)s-page*.png' % vars ())
768 def output_html (self):
770 base = self.basename ()
772 str += self.output_print_filename (HTML)
773 if VERBATIM in self.options:
774 verb = verbatim_html (self.substring ('code'))
775 str += write (output[HTML][VERBATIM] % vars ())
776 if QUOTE in self.options:
777 str = output[HTML][QUOTE] % vars ()
779 str += output[HTML][BEFORE] % vars ()
780 for image in self.get_images ():
781 base, ext = os.path.splitext (image)
782 str += output[HTML][OUTPUT] % vars ()
783 str += output[HTML][AFTER] % vars ()
786 def output_info (self):
787 str = self.output_print_filename (HTML)
788 str = output[TEXINFO][BEFORE] % vars ()
789 for image in self.get_images ():
790 base, ext = os.path.splitext (image)
792 # URG, makeinfo implicitely prepends dot to ext
793 # specifying no extension is most robust
795 str += output[TEXINFO][OUTPUT] % vars ()
796 str += output[TEXINFO][AFTER] % vars ()
799 def output_latex (self):
801 base = self.basename ()
803 str += self.output_print_filename (LATEX)
804 if VERBATIM in self.options:
805 verb = self.substring ('code')
806 str += (output[LATEX][VERBATIM] % vars ())
807 if QUOTE in self.options:
808 str = output[LATEX][QUOTE] % vars ()
810 str += (output[LATEX][BEFORE]
811 + (output[LATEX][OUTPUT] % vars ())
812 + output[LATEX][AFTER])
815 def output_print_filename (self,format):
817 if PRINTFILENAME in self.options:
818 base = self.basename ()
819 filename = self.substring ('filename')
820 str = output[format][PRINTFILENAME] % vars ()
823 def output_texinfo (self):
825 # self.output_print_filename (TEXINFO)
826 if self.output_print_filename (0):
827 str += ('@html\n' + self.output_print_filename (HTML)
829 str += ('@tex\n' + self.output_print_filename (LATEX)
831 base = self.basename ()
832 if TEXIDOC in self.options:
833 texidoc = base + '.texidoc'
834 if os.path.exists (texidoc):
835 str += '@include %(texidoc)s\n\n' % vars ()
837 if VERBATIM in self.options:
838 verb = verbatim_texinfo (self.substring ('code'))
839 str += (output[TEXINFO][VERBATIM] % vars ())
841 str += ('@ifinfo\n' + self.output_info () + '\n@end ifinfo\n')
842 str += ('@tex\n' + self.output_latex () + '\n@end tex\n')
843 str += ('@html\n' + self.output_html () + '\n@end html\n')
845 if QUOTE in self.options:
846 str = output[TEXINFO][QUOTE] % vars ()
848 # need par after image
853 class Lilypond_file_snippet (Lilypond_snippet):
855 name = self.substring ('filename')
856 return '\\renameinput \"%s\"\n%s' % (name, open (find_file (name)).read ())
858 snippet_type_to_class = {
859 'lilypond_file': Lilypond_file_snippet,
860 'lilypond_block': Lilypond_snippet,
861 'lilypond': Lilypond_snippet,
862 'include': Include_snippet,
865 def find_toplevel_snippets (s, types):
868 res[i] = ly.re.compile (snippet_res[format][i])
872 ## found = dict (map (lambda x: (x, None), types))
875 map (lambda x, f=found: f.setdefault (x, None), types)
877 # We want to search for multiple regexes, without searching
878 # the string multiple times for one regex.
879 # Hence, we use earlier results to limit the string portion
881 # Since every part of the string is traversed at most once for
882 # every type of snippet, this is linear.
888 if not found[type] or found[type][0] < index:
890 m = res[type].search (s[index:endex])
895 if snippet_type_to_class.has_key (type):
896 cl = snippet_type_to_class[type]
897 snip = cl (type, m, format)
898 start = index + m.start ('match')
899 found[type] = (start, snip)
902 and (not first or found[type][0] < found[first][0]):
907 # Limiting the search space is a cute
908 # idea, but this *requires* to search
909 # for possible containing blocks
910 # first, at least as long as we do not
911 # search for the start of blocks, but
912 # always/directly for the entire
913 # @block ... @end block.
915 endex = found[first][0]
918 snippets.append (Substring (s, index, len (s)))
921 (start, snip) = found[first]
922 snippets.append (Substring (s, index, start))
923 snippets.append (snip)
925 index = start + len (snip.match.group ('match'))
929 def filter_pipe (input, cmd):
931 ly.progress (_ ("Opening filter `%s\'") % cmd)
933 stdin, stdout, stderr = os.popen3 (cmd)
935 status = stdin.close ()
939 output = stdout.read ()
940 status = stdout.close ()
941 error = stderr.read ()
945 signal = 0x0f & status
946 if status or (not output and error):
947 exit_status = status >> 8
948 ly.error (_ ("`%s\' failed (%d)") % (cmd, exit_status))
949 ly.error (_ ("The error log is as follows:"))
950 sys.stderr.write (error)
951 sys.stderr.write (stderr.read ())
960 return filter_pipe (s, filter_cmd)
962 def is_derived_class (cl, baseclass):
965 for b in cl.__bases__:
966 if is_derived_class (b, baseclass):
971 def process_snippets (cmd, ly_snippets, png_snippets):
972 ly_names = filter (lambda x: x, map (Lilypond_snippet.basename, ly_snippets))
973 png_names = filter (lambda x: x, map (Lilypond_snippet.basename, png_snippets))
978 status = ly.system (string.join ([cmd] + ly_names),
979 ignore_error = 1, progress_p = 1)
983 ly.error( 'Process %s exited unsuccessfully.' % cmd )
986 if format == HTML or format == TEXINFO:
988 if not os.path.exists (i + '.eps') and os.path.exists (i + '.tex'):
990 ly.make_ps_images (i + '.eps', resolution=110)
992 # elif os.path.exists (i + '.ps'):
993 # ly.make_ps_images (i + '.ps', resolution=110)
996 LATEX_DOCUMENT = r'''
999 \typeout{textwidth=\the\textwidth}
1000 \typeout{columnsep=\the\columnsep}
1001 \makeatletter\if@twocolumn\typeout{columns=2}\fi\makeatother
1004 #need anything else besides textwidth?
1005 def get_latex_textwidth (source):
1006 m = re.search (r'''(?P<preamble>\\begin\s*{document})''', source)
1007 preamble = source[:m.start (0)]
1008 latex_document = LATEX_DOCUMENT % vars ()
1009 parameter_string = filter_pipe (latex_document, latex_filter_cmd)
1012 m = re.search ('columns=([0-9.]*)', parameter_string)
1014 columns = string.atoi (m.group (1))
1017 m = re.search ('columnsep=([0-9.]*)pt', parameter_string)
1019 columnsep = string.atof (m.group (1))
1022 m = re.search('textwidth=([0-9.]*)pt', parameter_string)
1024 textwidth = string.atof (m.group (1))
1026 textwidth = (textwidth - columnsep) / columns
1038 '.texinfo': TEXINFO,
1044 #TEXINFO: '.texinfo',
1049 class Compile_error:
1052 def do_process_cmd (chunks):
1053 ly_outdated = filter (lambda x: is_derived_class (x.__class__, Lilypond_snippet) \
1054 and x.ly_is_outdated (), chunks)
1055 png_outdated = filter (lambda x: is_derived_class (x.__class__, Lilypond_snippet) \
1056 and x.png_is_outdated (), chunks)
1058 ly.progress (_ ("Writing snippets..."))
1059 map (Lilypond_snippet.write_ly, ly_outdated)
1063 ly.progress (_ ("Processing..."))
1064 process_snippets (process_cmd, ly_outdated, png_outdated)
1066 ly.progress (_ ("All snippets are up to date..."))
1070 def do_file (input_filename):
1074 e = os.path.splitext (input_filename)[1]
1075 if e in ext2format.keys ():
1077 format = ext2format[e]
1079 ly.error (_ ("cannot determine format for: %s" \
1083 if not input_filename or input_filename == '-':
1084 in_handle = sys.stdin
1085 input_fullname = '<stdin>'
1087 if os.path.exists (input_filename):
1088 input_fullname = input_filename
1089 elif format == LATEX:
1090 # urg python interface to libkpathsea?
1091 input_fullname = ly.read_pipe ('kpsewhich '
1092 + input_filename)[:-1]
1094 input_fullname = find_file (input_filename)
1095 in_handle = open (input_fullname)
1097 if input_filename == '-':
1098 input_base = 'stdin'
1100 input_base = os.path.basename \
1101 (os.path.splitext (input_filename)[0])
1103 # only default to stdout when filtering
1104 if output_name == '-' or (not output_name and filter_cmd):
1105 output_filename = '-'
1106 output_file = sys.stdout
1109 output_filename = input_base + format2ext[format]
1111 if not os.path.isdir (output_name):
1112 os.mkdir (output_name, 0777)
1113 output_filename = (output_name
1115 + format2ext[format])
1118 if (os.path.exists (input_filename) and
1119 os.path.exists (output_filename) and
1120 os.path.samefile (output_filename, input_fullname)):
1121 ly.error (_("Output would overwrite input file; use --output."))
1124 output_file = open (output_filename, 'w')
1126 os.chdir (output_name)
1128 ly.progress (_ ("Reading %s...") % input_fullname)
1129 source = in_handle.read ()
1132 # FIXME: containing blocks must be first, see find_toplevel_snippets
1134 'multiline_comment',
1138 'singleline_comment',
1142 ly.progress (_ ("Dissecting..."))
1143 chunks = find_toplevel_snippets (source, snippet_types)
1146 global default_ly_options
1148 if not default_ly_options.has_key (LINEWIDTH):
1150 textwidth = get_latex_textwidth (source)
1151 default_ly_options[LINEWIDTH] = '''%.0f\\pt''' \
1153 elif format == TEXINFO:
1154 for (k, v) in texinfo_linewidths.items ():
1155 # FIXME: @layout is usually not in chunk #0:
1156 # \input texinfo @c -*-texinfo-*-
1157 # bluntly search first K of source
1158 # s = chunks[0].replacement_text ()
1159 if re.search (k, source[:1024]):
1160 default_ly_options[LINEWIDTH] = v
1164 output_file.writelines ([c.filter_text () for c in chunks])
1168 do_process_cmd (chunks)
1169 ly.progress (_ ("Compiling %s...") % output_filename)
1170 output_file.writelines ([s.replacement_text () \
1174 def process_include (snippet):
1175 os.chdir (original_dir)
1176 name = snippet.substring ('filename')
1177 ly.progress (_ ('Processing include: %s') % name)
1181 map (process_include,
1182 filter (lambda x: is_derived_class (x.__class__, Include_snippet), chunks))
1183 except Compile_error:
1184 os.chdir (original_dir)
1185 ly.progress (_('Removing `%s\'') % output_filename)
1188 os.unlink (output_filename)
1193 global format, output_name
1194 global filter_cmd, process_cmd, verbose_p
1196 (sh, long) = ly.getopt_args (option_definitions)
1198 (options, files) = getopt.getopt (sys.argv[1:], sh, long)
1199 except getopt.error, s:
1200 sys.stderr.write ('\n')
1201 ly.error (_ ("getopt says: `%s\'" % s))
1202 sys.stderr.write ('\n')
1212 elif o == '--filter' or o == '-F':
1215 elif o == '--format' or o == '-f':
1217 if a == 'texi-html' or a == 'texi':
1219 elif o == '--help' or o == '-h':
1222 elif o == '--include' or o == '-I':
1223 include_path.append (os.path.join (original_dir,
1225 elif o == '--output' or o == '-o':
1227 elif o == '--outdir':
1229 elif o == '--process' or o == '-P':
1232 elif o == '--version' or o == '-v':
1233 ly.identify (sys.stdout)
1235 elif o == '--verbose' or o == '-V':
1237 elif o == '--warranty' or o == '-w':
1244 files = do_options ()
1246 if process_cmd == '':
1247 process_cmd = lilypond_binary + " -f tex "
1250 process_cmd += string.join ([(' -I %s' % p)
1251 for p in include_path])
1253 ly.identify (sys.stderr)
1254 ly.setup_environment ()
1258 except Compile_error:
1261 if __name__ == '__main__':