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__':
68 program_version = '@TOPLEVEL_VERSION@'
69 program_name = sys.argv[0]
72 original_dir = os.getcwd ()
74 help_summary = _ ('''Process LilyPond snippets in hybrid HTML, LaTeX or texinfo document.
77 lilypond-book --filter="tr '[a-z]' '[A-Z]'" BOOK
78 lilypond-book --filter="convert-ly --no-version --from=2.0.0 -" BOOK
79 lilypond-book --process='lilypond -I include' BOOK
83 copyright = ('Jan Nieuwenhuizen <janneke@gnu.org>',
84 'Han-Wen Nienhuys <hanwen@cs.uu.nl>')
86 option_definitions = [
87 (_ ("EXT"), 'f', 'format', _ ("use output format EXT (texi [default], texi-html, latex, html)")),
88 (_ ("FILTER"), 'F', 'filter', _ ("pipe snippets through FILTER [convert-ly -n -]")),
89 ('', 'h', 'help', _ ("print this help")),
90 (_ ("DIR"), 'I', 'include', _ ("add DIR to include path")),
91 (_ ("COMMAND"), 'P', 'process', _ ("process ly_files using COMMAND FILE...")),
92 (_ ("DIR"), 'o', 'output', _ ("write output to DIR")),
93 ('', 'V', 'verbose', _ ("be verbose")),
94 ('', 'v', 'version', _ ("print version information")),
95 ('', 'w', 'warranty', _ ("show warranty and copyright")),
98 include_path = [ly.abspath (os.getcwd ())]
99 lilypond_binary = os.path.join ('@bindir@', 'lilypond')
101 # only use installed binary when we're installed too.
102 if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary):
103 lilypond_binary = 'lilypond'
108 latex_filter_cmd = 'latex "\\nonstopmode \input /dev/stdin"'
111 default_ly_options = {}
114 # is this pythonic? Personally, I find this rather #define-nesque. --hwn
118 EXAMPLEINDENT = 'exampleindent'
120 FRAGMENT = 'fragment'
125 LINEWIDTH = 'linewidth'
126 NOFRAGMENT = 'nofragment'
127 NOINDENT = 'noindent'
132 PREAMBLE = 'preamble'
133 PRINTFILENAME = 'printfilename'
135 RAGGEDRIGHT = 'raggedright'
136 RELATIVE = 'relative'
137 STAFFSIZE = 'staffsize'
140 VERBATIM = 'verbatim'
142 # Recognize special sequences in the input;
144 # (?P<name>regex) -- assign result of REGEX to NAME
145 # *? -- match non-greedily.
146 # (?m) -- multiline regex: make ^ and $ match at each line
147 # (?s) -- make the dot match all characters including newline
148 # (?x) -- ignore whitespace in patterns
160 (\s*(?P<options>.*?)\s*:)?\s*
168 \s*(?P<options>.*?)\s*
177 \s*(?P<options>.*?)\s*
179 \s*(?P<filename>.*?)\s*
186 (?P<code><!--\s.*?!-->)
189 'singleline_comment':
195 (?P<code><pre>.*?</pre>))''',
201 (?P<code><pre>\s.*?</pre>\s))''',
220 \s*(?P<options>.*?)\s*
231 \s*(?P<options>.*?)\s*
235 \\end\s*{lilypond})''',
243 \s*(?P<options>.*?)\s*
251 'singleline_comment':
274 \\end\s*{verbatim}))''',
283 (?P<filename>\S+))''',
287 ^[^\n]*?(?!@c\s+)[^\n]*?
291 \s*(?P<options>.*?)\s*
301 \s*(?P<options>.*?)\s*
304 ^@end\s+lilypond)\s''',
311 \s*(?P<options>.*?)\s*
322 @end\s+ignore))\s''',
324 'singleline_comment':
329 @c([ \t][^\n]*|)\n))''',
331 # don't do this: fucks up with @code{@{}
332 # 'verb': r'''(?P<code>@code{.*?})''',
340 @end\s+example\s))''',
346 'intertext': r',?\s*intertext=\".*?\"',
351 'intertext': r',?\s*intertext=\".*?\"',
352 'option_sep': '\s*,\s*',
356 'intertext': r',?\s*intertext=\".*?\"',
357 'option_sep': '\s*,\s*',
364 RELATIVE: r'''\relative c%(relative_quotes)s''',
370 indent = %(indent)s''',
372 linewidth = %(linewidth)s''',
378 linewidth = %(linewidth)s - 2.0 * %(exampleindent)s
383 raggedright = ##t''',
393 \remove Time_signature_engraver
400 #(set-global-staff-size %(staffsize)s)''',
407 FILTER: r'''<lilypond %(options)s>
417 <a href="%(base)s.ly">''',
420 <img align="center" valign="center"
421 border="0" src="%(image)s" alt="[image of music]">''',
423 PRINTFILENAME: '<p><tt><a href="%(base)s.ly">%(filename)s</a></tt></p>',
425 QUOTE: r'''<blockquote>
439 OUTPUT: r'''{\parindent 0pt
441 \ifx\preLilyPondExample\undefined\relax\else\preLilyPondExample\fi
442 \def\lilypondbook{}%%
444 \ifx\postLilyPondExample\undefined\relax\else\postLilyPondExample\fi
447 PRINTFILENAME: '''\\texttt{%(filename)s}
450 QUOTE: r'''\begin{quotation}
455 VERBATIM: r'''\noindent
457 %(verb)s\end{verbatim}
460 FILTER: r'''\begin{lilypond}[%(options)s]
467 FILTER: r'''@lilypond[%(options)s]
475 OUTPUT: r'''@noindent
476 @image{%(base)s,,,[image of music],%(ext)s}''',
478 PRINTFILENAME: '''@file{%(filename)s}
481 QUOTE: r'''@quotation
486 # FIXME: @exampleindent 5 is the default...
487 VERBATIM: r'''@exampleindent 0
495 PREAMBLE_LY = r'''%%%% Generated by %(program_name)s
496 %%%% Options: [%(option_string)s]
497 #(set! toplevel-score-handler ly:parser-print-score)
498 #(set! toplevel-music-handler (lambda (p m)
499 (ly:parser-print-score
500 p (ly:music-scorify m p))
504 #(define dump-extents #t)
507 \layout { %(layout_string)s
514 %% ly snippet contents follows:
526 texinfo_linewidths = {
527 '@afourpaper': '160\\mm',
528 '@afourwide': '6.5\\in',
529 '@afourlatex': '150\\mm',
530 '@smallbook': '5\\in',
531 '@letterpaper': '6\\in',
534 def classic_lilypond_book_compatibility (o):
535 if o == 'singleline':
537 m = re.search ('relative\s*([-0-9])', o)
539 return 'relative=%s' % m.group (1)
540 m = re.match ('([0-9]+)pt', o)
542 return 'staffsize=%s' % m.group (1)
543 m = re.match ('indent=([-.0-9]+)(cm|in|mm|pt|staffspace)', o)
545 f = float (m.group (1))
546 return 'indent=%f\\%s' % (f, m.group (2))
547 m = re.match ('linewidth=([-.0-9]+)(cm|in|mm|pt|staffspace)', o)
549 f = float (m.group (1))
550 return 'linewidth=%f\\%s' % (f, m.group (2))
553 def compose_ly (code, options):
555 for i in default_ly_options.keys ():
560 if QUOTE in options and LINEWIDTH in options:
561 options.remove (LINEWIDTH)
563 if FRAGMENT in options:
564 if RAGGEDRIGHT not in options:
565 options.append (RAGGEDRIGHT)
574 #FIXME: where to get sane value for exampleindent?
575 override[EXAMPLEINDENT] = r'9.0 \mm'
576 override[LINEWIDTH] = None
577 override.update (default_ly_options)
579 option_string = string.join (options, ',')
582 option_types = [NOTES, PREAMBLE, LAYOUT, PAPER]
583 for a in option_types:
587 c = classic_lilypond_book_compatibility (i)
589 ly.warning (_ ("deprecated ly-option used: %s" % i))
590 ly.warning (_ ("compatibility mode translation: %s" \
594 if string.find (i, '=') > 0:
595 key, value = re.split ('\s*=\s*', i)
596 override[key] = value
599 if not override.has_key (i):
603 for type in option_types:
604 if ly_options[type].has_key (key):
606 options_dict[type].append (ly_options[type][key])
610 if not found and key not in (FRAGMENT, NOFRAGMENT, PRINTFILENAME,
611 RELATIVE, VERBATIM, TEXIDOC):
612 ly.warning (_ ("ignoring unknown ly option: %s") % i)
615 if RELATIVE in override.keys () and override[RELATIVE]:
616 relative = string.atoi (override[RELATIVE])
622 relative_quotes += ',' * (- relative)
624 relative_quotes += "'" * relative
626 program_name = __main__.program_name
628 paper_string = string.join (options_dict[PAPER], '\n ') % override
629 layout_string = string.join (options_dict[LAYOUT], '\n ') % override
630 notes_string = string.join (options_dict[NOTES], '\n ') % vars ()
631 preamble_string = string.join (options_dict[PREAMBLE], '\n ') % override
632 return (PREAMBLE_LY + body) % vars ()
635 # use lilypond for latex (.lytex) books,
636 # and lilypond --preview for html, texinfo books?
638 cmd = r'latex "\nonstopmode \input %s"' % file
639 # Ugh. (La)TeX writes progress and error messages on stdout
641 cmd = '(( %s >&2 ) >&- )' % cmd
643 ly.system ('dvips -Ppdf -u+ec-mftrace.map -u+lilypond.map -E -o %s.eps %s' \
646 # check if it really is EPS.
647 # Otherwise music glyphs disappear from 2nd and following pages.
649 # TODO: should run dvips -pp -E per page, then we get proper
652 f = open ('%s.eps' % file)
653 for x in range (0, 10):
654 if re.search ("^%%Pages: ", f.readline ()):
656 ly.system ('dvips -Ppdf -u+ec-mftrace.map -u+lilypond.map -o %s.eps %s' \
660 def find_file (name):
661 for i in include_path:
662 full = os.path.join (i, name)
663 if os.path.exists (full):
665 ly.error (_ ('file not found: %s') % name + '\n')
669 def verbatim_html (s):
670 return re.sub ('>', '>',
672 re.sub ('&', '&', s)))
674 def verbatim_texinfo (s):
675 return re.sub ('{', '@{',
677 re.sub ('@', '@@', s)))
679 def split_options (option_string):
680 return re.split (format_res[format]['option_sep'], option_string)
683 def replacement_text (self):
686 def filter_text (self):
687 return self.replacement_text ()
689 def ly_is_outdated (self):
692 def png_is_outdated (self):
695 class Substring (Chunk):
696 def __init__ (self, source, start, end):
701 def replacement_text (self):
702 return self.source [self.start:self.end]
704 class Snippet (Chunk):
705 def __init__ (self, type, match, format):
712 def replacement_text (self):
713 return self.match.group ('match')
715 def substring (self, s):
716 return self.match.group (s)
719 return `self.__class__` + " type = " + self.type
721 class Include_snippet (Snippet):
722 def processed_filename (self):
723 f = self.substring ('filename')
724 return os.path.splitext (f)[0] + format2ext[format]
726 def replacement_text (self):
727 s = self.match.group ('match')
728 f = self.substring ('filename')
730 return re.sub (f, self.processed_filename (), s)
732 class Lilypond_snippet (Snippet):
733 def __init__ (self, type, match, format):
734 Snippet.__init__ (self, type, match, format)
735 os = match.group ('options')
737 self.options = split_options (os)
740 return self.substring ('code')
745 return compose_ly (s, self.options)
751 self.hash = abs (hash (self.full_ly ()))
756 return 'lily-%d' % self.get_hash ()
760 outf = open (self.basename () + '.ly', 'w')
761 outf.write (self.full_ly ())
763 open (self.basename () + '.txt', 'w').write ("image of music")
765 def ly_is_outdated (self):
766 base = self.basename ()
768 tex_file = '%s.tex' % base
769 ly_file = '%s.ly' % base
770 ok = os.path.exists (ly_file) and os.path.exists (tex_file)\
771 and os.stat (tex_file)[stat.ST_SIZE] \
772 and open (tex_file).readlines ()[-1][1:-1] \
775 if ok and (use_hash_p or self.ly () == open (ly_file).read ()):
776 # TODO: something smart with target formats
777 # (ps, png) and m/ctimes
781 def png_is_outdated (self):
782 base = self.basename ()
783 ok = self.ly_is_outdated ()
784 if format == HTML or format == TEXINFO:
785 ok = ok and (os.path.exists (base + '.png')
786 or glob.glob (base + '-page*.png'))
789 def filter_text (self):
790 code = self.substring ('code')
791 s = run_filter (code)
794 'options': self.match.group ('options')
797 return output[self.format][FILTER] % d
799 def replacement_text (self):
800 func = Lilypond_snippet.__dict__ ['output_' + self.format]
803 def get_images (self):
804 base = self.basename ()
806 single = '%(base)s.png' % vars ()
807 multiple = '%(base)s-page1.png' % vars ()
809 if os.path.exists (multiple) \
810 and (not os.path.exists (single)\
811 or (os.stat (multiple)[stat.ST_MTIME] \
812 > os.stat (single)[stat.ST_MTIME])):
813 images = glob.glob ('%(base)s-page*.png' % vars ())
816 def output_html (self):
818 base = self.basename ()
820 str += self.output_print_filename (HTML)
821 if VERBATIM in self.options:
822 verb = verbatim_html (self.substring ('code'))
823 str += write (output[HTML][VERBATIM] % vars ())
824 if QUOTE in self.options:
825 str = output[HTML][QUOTE] % vars ()
827 str += output[HTML][BEFORE] % vars ()
828 for image in self.get_images ():
829 base, ext = os.path.splitext (image)
830 str += output[HTML][OUTPUT] % vars ()
831 str += output[HTML][AFTER] % vars ()
834 def output_info (self):
835 str = self.output_print_filename (HTML)
836 str = output[TEXINFO][BEFORE] % vars ()
837 for image in self.get_images ():
838 base, ext = os.path.splitext (image)
840 # URG, makeinfo implicitely prepends dot to ext
841 # specifying no extension is most robust
843 str += output[TEXINFO][OUTPUT] % vars ()
844 str += output[TEXINFO][AFTER] % vars ()
847 def output_latex (self):
849 base = self.basename ()
851 str += self.output_print_filename (LATEX)
852 if VERBATIM in self.options:
853 verb = self.substring ('code')
854 str += (output[LATEX][VERBATIM] % vars ())
855 if QUOTE in self.options:
856 str = output[LATEX][QUOTE] % vars ()
858 str += (output[LATEX][BEFORE]
859 + (output[LATEX][OUTPUT] % vars ())
860 + output[LATEX][AFTER])
863 def output_print_filename (self,format):
865 if PRINTFILENAME in self.options:
866 base = self.basename ()
867 filename = self.substring ('filename')
868 str = output[format][PRINTFILENAME] % vars ()
871 def output_texinfo (self):
873 if self.output_print_filename (TEXINFO):
874 str += ('@html\n' + self.output_print_filename (HTML)
876 str += ('@tex\n' + self.output_print_filename (LATEX)
878 base = self.basename ()
879 if TEXIDOC in self.options:
880 texidoc = base + '.texidoc'
881 if os.path.exists (texidoc):
882 str += '@include %(texidoc)s\n\n' % vars ()
884 if VERBATIM in self.options:
885 verb = verbatim_texinfo (self.substring ('code'))
886 str += (output[TEXINFO][VERBATIM] % vars ())
888 str += ('@ifinfo\n' + self.output_info () + '\n@end ifinfo\n')
889 str += ('@tex\n' + self.output_latex () + '\n@end tex\n')
890 str += ('@html\n' + self.output_html () + '\n@end html\n')
892 if QUOTE in self.options:
893 str = output[TEXINFO][QUOTE] % vars ()
895 # need par after image
900 class Lilypond_file_snippet (Lilypond_snippet):
902 name = self.substring ('filename')
903 return '\\renameinput \"%s\"\n%s' % (name, open (find_file (name)).read ())
905 snippet_type_to_class = {
906 'lilypond_file': Lilypond_file_snippet,
907 'lilypond_block': Lilypond_snippet,
908 'lilypond': Lilypond_snippet,
909 'include': Include_snippet,
912 def find_toplevel_snippets (s, types):
915 res[i] = ly.re.compile (snippet_res[format][i])
919 ## found = dict (map (lambda x: (x, None), types))
922 map (lambda x, f=found: f.setdefault (x, None), types)
924 # We want to search for multiple regexes, without searching
925 # the string multiple times for one regex.
926 # Hence, we use earlier results to limit the string portion
928 # Since every part of the string is traversed at most once for
929 # every type of snippet, this is linear.
935 if not found[type] or found[type][0] < index:
937 m = res[type].search (s[index:endex])
942 if snippet_type_to_class.has_key (type):
943 cl = snippet_type_to_class[type]
944 snip = cl (type, m, format)
945 start = index + m.start ('match')
946 found[type] = (start, snip)
949 and (not first or found[type][0] < found[first][0]):
954 # Limiting the search space is a cute
955 # idea, but this *requires* to search
956 # for possible containing blocks
957 # first, at least as long as we do not
958 # search for the start of blocks, but
959 # always/directly for the entire
960 # @block ... @end block.
962 endex = found[first][0]
965 snippets.append (Substring (s, index, len (s)))
968 (start, snip) = found[first]
969 snippets.append (Substring (s, index, start))
970 snippets.append (snip)
972 index = start + len (snip.match.group ('match'))
976 def filter_pipe (input, cmd):
978 ly.progress (_ ("Opening filter `%s\'") % cmd)
980 stdin, stdout, stderr = os.popen3 (cmd)
982 status = stdin.close ()
986 output = stdout.read ()
987 status = stdout.close ()
988 error = stderr.read ()
992 signal = 0x0f & status
993 if status or (not output and error):
994 exit_status = status >> 8
995 ly.error (_ ("`%s\' failed (%d)") % (cmd, exit_status))
996 ly.error (_ ("The error log is as follows:"))
997 sys.stderr.write (error)
998 sys.stderr.write (stderr.read ())
1007 return filter_pipe (s, filter_cmd)
1009 def is_derived_class (cl, baseclass):
1012 for b in cl.__bases__:
1013 if is_derived_class (b, baseclass):
1017 def process_snippets (cmd, ly_snippets, png_snippets):
1018 ly_names = filter (lambda x: x, map (Lilypond_snippet.basename, ly_snippets))
1019 png_names = filter (lambda x: x, map (Lilypond_snippet.basename, png_snippets))
1023 status = ly.system (string.join ([cmd] + ly_names),
1024 ignore_error = 1, progress_p = 1)
1027 ly.error ('Process %s exited unsuccessfully.' % cmd)
1030 if format == HTML or format == TEXINFO:
1032 if not os.path.exists (i + '.eps') and os.path.exists (i + '.tex'):
1034 ly.make_ps_images (i + '.eps', resolution=110)
1036 # elif os.path.exists (i + '.ps'):
1037 # ly.make_ps_images (i + '.ps', resolution=110)
1039 LATEX_DOCUMENT = r'''
1042 \typeout{textwidth=\the\textwidth}
1043 \typeout{columnsep=\the\columnsep}
1044 \makeatletter\if@twocolumn\typeout{columns=2}\fi\makeatother
1047 #need anything else besides textwidth?
1048 def get_latex_textwidth (source):
1049 m = re.search (r'''(?P<preamble>\\begin\s*{document})''', source)
1050 preamble = source[:m.start (0)]
1051 latex_document = LATEX_DOCUMENT % vars ()
1052 parameter_string = filter_pipe (latex_document, latex_filter_cmd)
1055 m = re.search ('columns=([0-9.]*)', parameter_string)
1057 columns = string.atoi (m.group (1))
1060 m = re.search ('columnsep=([0-9.]*)pt', parameter_string)
1062 columnsep = string.atof (m.group (1))
1065 m = re.search ('textwidth=([0-9.]*)pt', parameter_string)
1067 textwidth = string.atof (m.group (1))
1069 textwidth = (textwidth - columnsep) / columns
1081 '.texinfo': TEXINFO,
1087 #TEXINFO: '.texinfo',
1092 class Compile_error:
1095 def do_process_cmd (chunks):
1096 ly_outdated = filter (lambda x: is_derived_class (x.__class__, Lilypond_snippet) \
1097 and x.ly_is_outdated (), chunks)
1098 png_outdated = filter (lambda x: is_derived_class (x.__class__, Lilypond_snippet) \
1099 and x.png_is_outdated (), chunks)
1101 ly.progress (_ ("Writing snippets..."))
1102 map (Lilypond_snippet.write_ly, ly_outdated)
1106 ly.progress (_ ("Processing..."))
1107 process_snippets (process_cmd, ly_outdated, png_outdated)
1109 ly.progress (_ ("All snippets are up to date..."))
1112 def do_file (input_filename):
1116 e = os.path.splitext (input_filename)[1]
1117 if e in ext2format.keys ():
1119 format = ext2format[e]
1121 ly.error (_ ("cannot determine format for: %s" \
1125 if not input_filename or input_filename == '-':
1126 in_handle = sys.stdin
1127 input_fullname = '<stdin>'
1129 if os.path.exists (input_filename):
1130 input_fullname = input_filename
1131 elif format == LATEX:
1132 # urg python interface to libkpathsea?
1133 input_fullname = ly.read_pipe ('kpsewhich '
1134 + input_filename)[:-1]
1136 input_fullname = find_file (input_filename)
1137 in_handle = open (input_fullname)
1139 if input_filename == '-':
1140 input_base = 'stdin'
1142 input_base = os.path.basename \
1143 (os.path.splitext (input_filename)[0])
1145 # only default to stdout when filtering
1146 if output_name == '-' or (not output_name and filter_cmd):
1147 output_filename = '-'
1148 output_file = sys.stdout
1151 output_filename = input_base + format2ext[format]
1153 if not os.path.isdir (output_name):
1154 os.mkdir (output_name, 0777)
1155 output_filename = (output_name
1157 + format2ext[format])
1159 if (os.path.exists (input_filename) and
1160 os.path.exists (output_filename) and
1161 os.path.samefile (output_filename, input_fullname)):
1162 ly.error (_ ("Output would overwrite input file; use --output."))
1165 output_file = open (output_filename, 'w')
1167 os.chdir (output_name)
1169 ly.progress (_ ("Reading %s...") % input_fullname)
1170 source = in_handle.read ()
1173 # FIXME: containing blocks must be first, see find_toplevel_snippets
1175 'multiline_comment',
1179 'singleline_comment',
1183 ly.progress (_ ("Dissecting..."))
1184 chunks = find_toplevel_snippets (source, snippet_types)
1187 global default_ly_options
1189 if not default_ly_options.has_key (LINEWIDTH):
1191 textwidth = get_latex_textwidth (source)
1192 default_ly_options[LINEWIDTH] = '''%.0f\\pt''' \
1194 elif format == TEXINFO:
1195 for (k, v) in texinfo_linewidths.items ():
1196 # FIXME: @layout is usually not in chunk #0:
1197 # \input texinfo @c -*-texinfo-*-
1198 # bluntly search first K of source
1199 # s = chunks[0].replacement_text ()
1200 if re.search (k, source[:1024]):
1201 default_ly_options[LINEWIDTH] = v
1205 output_file.writelines ([c.filter_text () for c in chunks])
1208 do_process_cmd (chunks)
1209 ly.progress (_ ("Compiling %s...") % output_filename)
1210 output_file.writelines ([s.replacement_text () \
1214 def process_include (snippet):
1215 os.chdir (original_dir)
1216 name = snippet.substring ('filename')
1217 ly.progress (_ ('Processing include: %s') % name)
1221 map (process_include,
1222 filter (lambda x: is_derived_class (x.__class__, Include_snippet), chunks))
1223 except Compile_error:
1224 os.chdir (original_dir)
1225 ly.progress (_ ('Removing `%s\'') % output_filename)
1228 os.unlink (output_filename)
1232 global format, output_name
1233 global filter_cmd, process_cmd, verbose_p
1235 (sh, long) = ly.getopt_args (option_definitions)
1237 (options, files) = getopt.getopt (sys.argv[1:], sh, long)
1238 except getopt.error, s:
1239 sys.stderr.write ('\n')
1240 ly.error (_ ("getopt says: `%s\'" % s))
1241 sys.stderr.write ('\n')
1251 elif o == '--filter' or o == '-F':
1254 elif o == '--format' or o == '-f':
1256 if a == 'texi-html' or a == 'texi':
1258 elif o == '--help' or o == '-h':
1261 elif o == '--include' or o == '-I':
1262 include_path.append (os.path.join (original_dir,
1264 elif o == '--output' or o == '-o':
1266 elif o == '--outdir':
1268 elif o == '--process' or o == '-P':
1271 elif o == '--version' or o == '-v':
1272 ly.identify (sys.stdout)
1274 elif o == '--verbose' or o == '-V':
1276 elif o == '--warranty' or o == '-w':
1283 files = do_options ()
1285 if process_cmd == '':
1286 process_cmd = lilypond_binary + " -f tex "
1289 process_cmd += string.join ([(' -I %s' % p)
1290 for p in include_path])
1292 ly.identify (sys.stderr)
1293 ly.setup_environment ()
1297 except Compile_error:
1300 if __name__ == '__main__':