5 ly-options: intertext, quote ?
8 check latex parameters, twocolumn, multicolumn?
13 lilypond-book --filter="tr '[a-z]' '[A-Z]'" BOOK
16 lilypond-book --filter="convert-ly --no-version --from=1.6.11 -" BOOK
18 classic lilypond-book:
19 lilypond-book --process="lilypond-bin" BOOK.tely
22 @mbinclude foo.itely -> @include foo.itely
31 ################################################################
32 # Users of python modules should include this snippet
33 # and customize variables below.
35 # We'll suffer this path init stuff as long as we don't install our
36 # python packages in <prefix>/lib/pythonx.y (and don't kludge around
37 # it as we do with teTeX on Red Hat Linux: set some environment var
38 # (PYTHONPATH) in profile)
40 # If set, LILYPONDPREFIX must take prevalence
41 # if datadir is not set, we're doing a build and LILYPONDPREFIX
42 import getopt, os, sys
43 datadir = '@local_lilypond_datadir@'
44 if not os.path.isdir (datadir):
45 datadir = '@lilypond_datadir@'
46 if os.environ.has_key ('LILYPONDPREFIX') :
47 datadir = os.environ['LILYPONDPREFIX']
48 while datadir[-1] == os.sep:
51 sys.path.insert (0, os.path.join (datadir, 'python'))
54 #if __name__ == '__main__':
62 program_version = '@TOPLEVEL_VERSION@'
63 program_name = 'lilypond-book'
66 original_dir = os.getcwd ()
69 help_summary = _ ("""Process LilyPond snippets in hybrid HTML, LaTeX or texinfo document. Example usage:
71 lilypond-book --filter="tr '[a-z]' '[A-Z]'" BOOK
72 lilypond-book --filter="convert-ly --no-version --from=2.0.0 -" BOOK
73 lilypond-book --process='lilypond-bin -I include' BOOK
77 copyright = ('Jan Nieuwenhuizen <janneke@gnu.org>',
78 'Han-Wen Nienhuys <hanwen@cs.uu.nl>')
80 option_definitions = [
81 (_ ("EXT"), 'f', 'format', _ ("use output format EXT (texi [default], texi-html, latex, html)")),
82 (_ ("FILTER"), 'F', 'filter', _ ("pipe snippets through FILTER [convert-ly -n -]")),
83 ('', 'h', 'help', _ ("print this help")),
84 (_ ("DIR"), 'I', 'include', _ ("add DIR to include path")),
85 (_ ("COMMAND"), 'P', 'process', _ ("process ly_files using COMMAND FILE...")),
86 (_ ("DIR"), 'o', 'output', _ ("write output to DIR")),
87 ('', 'V', 'verbose', _ ("be verbose")),
88 ('', 'v', 'version', _ ("print version information")),
89 ('', 'w', 'warranty', _ ("show warranty and copyright")),
92 include_path = [ly.abspath (os.getcwd ())]
93 lilypond_binary = os.path.join ('@bindir@', 'lilypond-bin')
95 # only use installed binary when we're installed too.
96 if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary):
97 lilypond_binary = 'lilypond-bin'
103 latex_filter_cmd = 'latex "\\nonstopmode \input /dev/stdin"'
105 process_cmd = lilypond_binary
106 default_ly_options = {}
111 FRAGMENT = 'fragment'
114 LINEWIDTH = 'linewidth'
115 NOFRAGMENT = 'nofragment'
119 PREAMBLE = 'preamble'
120 PRINTFILENAME = 'printfilename'
121 RAGGEDRIGHT = 'raggedright'
122 RELATIVE = 'relative'
123 STAFFSIZE = 'staffsize'
126 VERBATIM = 'verbatim'
128 # Recognize special sequences in the input
130 # (?P<name>regex) -- assign result of REGEX to NAME
131 # *? -- match non-greedily.
132 # (?m) -- multiline regex: make ^ and $ match at each line
133 # (?s) -- make the dot match all characters including newline
138 'lilypond' : '(?m)(?P<match><lilypond((?P<options>[^:]*):)(?P<code>.*?)/>)',
139 'lilypond_block': r'''(?ms)(?P<match><lilypond(?P<options>[^>]+)?>(?P<code>.*?)</lilypond>)''',
140 'lilypond_file': r'(?m)(?P<match><lilypondfile(?P<options>[^>]+)?>\s*(?P<filename>[^<]+)\s*</lilypondfile>)',
141 'multiline_comment': r"(?sm)\s*(?!@c\s+)(?P<code><!--\s.*?!-->)\s",
142 'singleline_comment': no_match,
143 'verb': r'''(?P<code><pre>.*?</pre>)''',
144 'verbatim': r'''(?s)(?P<code><pre>\s.*?</pre>\s)''',
148 'include': r'(?m)^[^%\n]*?(?P<match>\\input{(?P<filename>[^}]+)})',
149 'lilypond' : r'(?m)^[^%\n]*?(?P<match>\\lilypond\s*(\[(?P<options>.*?)\])?\s*{(?P<code>.*?)})',
150 'lilypond_block': r"(?sm)^[^%\n]*?(?P<match>\\begin\s*(\[(?P<options>.*?)\])?\s*{lilypond}(?P<code>.*?)\\end{lilypond})",
151 'lilypond_file': r'(?m)^[^%\n]*?(?P<match>\\lilypondfile\s*(\[(?P<options>.*?)\])?\s*\{(?P<filename>.+)})',
152 'multiline_comment': no_match,
153 'singleline_comment': r"(?m)^.*?(?P<match>(?P<code>^%.*$\n+))",
154 'verb': r"(?P<code>\\verb(?P<del>.).*?(?P=del))",
155 'verbatim': r"(?s)(?P<code>\\begin\s*{verbatim}.*?\\end{verbatim})",
159 'include': '(?m)^[^%\n]*?(?P<match>@include\s+(?P<filename>\S+))',
160 'lilypond' : '(?m)^(?P<match>@lilypond(\[(?P<options>[^]]*)\])?{(?P<code>.*?)})',
161 'lilypond_block': r'''(?ms)^(?P<match>@lilypond(\[(?P<options>[^]]*)\])?\s(?P<code>.*?)@end lilypond)\s''',
162 'lilypond_file': '(?m)^(?P<match>@lilypondfile(\[(?P<options>[^]]*)\])?{(?P<filename>[^}]+)})',
163 'multiline_comment': r'(?sm)^\s*(?!@c\s+)(?P<code>@ignore\s.*?@end\s+ignore)\s',
164 'singleline_comment': r'(?m)^.*(?P<match>(?P<code>@c([ \t][^\n]*|)\n))',
166 # don't do this: fucks up with @code{@{}
167 # 'verb': r'''(?P<code>@code{.*?})''',
168 'verbatim': r'''(?s)(?P<code>@example\s.*?@end\s+example\s)''',
174 'option-sep' : '\s*',
175 'intertext': r',?\s*intertext=\".*?\"',
178 'intertext': r',?\s*intertext=\".*?\"',
179 'option-sep' : ',\s*',
182 'intertext': r',?\s*intertext=\".*?\"',
183 'option-sep' : ',\s*',
189 RELATIVE: r'''\relative c%(relative_quotes)s''',
193 indent = %(indent)s''',
195 linewidth = %(linewidth)s''',
201 \remove Time_signature_engraver
205 raggedright = ##t''',
209 #(set-global-staff-size %(staffsize)s)''',
215 FILTER: r'''<lilypond %(options)s>
225 <a href="%(base)s.ly">''',
227 <img align="center" valign="center"
228 border="0" src="%(image)s" alt="[image of music]">''',
229 PRINTFILENAME:'<p><tt><a href="%(base)s.ly">%(filename)s</a></tt></p>',
237 OUTPUT: r'''{\parindent 0pt
239 \ifx\preLilyPondExample\preLilyPondExample\fi
242 \ifx\preLilyPondExample\postLilyPondExample\fi
244 PRINTFILENAME: '''\\texttt{%(filename)s}
247 VERBATIM: r'''\begin{verbatim}
248 %(verb)s\end{verbatim}
250 FILTER: r'''\begin{lilypond}[%(options)s]
256 FILTER: r'''@lilypond[%(options)s]
262 @image{%(base)s,,,[image of music],%(ext)s}
264 PRINTFILENAME: '''@file{%(filename)s}
267 VERBATIM: r'''@example
273 PREAMBLE_LY = r'''%% Generated by %(program_name)s
274 %% Options: [%(option_string)s]
276 \paper {%(paper_string)s
280 FRAGMENT_LY = r'''\score{
281 \notes%(notes_string)s{
286 texinfo_linewidths = {
287 '@afourpaper': '160 \\mm',
288 '@afourwide': '6.5 \\in',
289 '@afourlatex': '150 \\mm',
290 '@smallbook': '5 \\in' ,
291 '@letterpaper': '6\\in',
294 def classic_lilypond_book_compatibility (o):
295 if o == 'singleline':
297 m = re.search ('relative\s*([-0-9])', o)
299 return 'relative=%s' % m.group (1)
300 m = re.match ('([0-9]+)pt', o)
302 return 'staffsize=%s' % m.group (1)
303 m = re.match ('indent=([-.0-9]+)(cm|in|mm|pt)', o)
305 f = float (m.group (1))
306 return 'indent=%f\\%s' % (f, m.group (2))
307 m = re.match ('linewidth=([-.0-9]+)(cm|in|mm|pt)', o)
309 f = float (m.group (1))
310 return 'linewidth=%f\\%s' % (f, m.group (2))
313 def compose_ly (code, options):
315 for i in default_ly_options.keys ():
319 m = re.search (r'''\\score''', code)
320 if not m and (not options \
321 or not NOFRAGMENT in options or FRAGMENT in options):
322 if RAGGEDRIGHT not in options:
323 options.append (RAGGEDRIGHT)
332 override.update (default_ly_options)
334 option_string = string.join (options, ',')
337 preamble_options = []
339 c = classic_lilypond_book_compatibility (i)
341 ly.warning (_ ("deprecated ly-option used: %s" % i))
342 ly.warning (_ ("compatibility mode translation: %s" \
346 if string.find (i, '=') > 0:
347 key, value = string.split (i, '=')
348 override[key] = value
351 if i not in override.keys ():
354 if key in ly_options[NOTES].keys ():
355 notes_options.append (ly_options[NOTES][key])
356 elif key in ly_options[PREAMBLE].keys ():
357 preamble_options.append (ly_options[PREAMBLE][key])
358 elif key in ly_options[PAPER].keys ():
359 paper_options.append (ly_options[PAPER][key])
360 elif key not in (FRAGMENT, NOFRAGMENT, PRINTFILENAME,
361 RELATIVE, VERBATIM, TEXIDOC):
362 ly.warning (_("ignoring unknown ly option: %s") % i)
365 if RELATIVE in override.keys () and override[RELATIVE]:
366 relative = string.atoi (override[RELATIVE])
372 relative_quotes += ',' * (- relative)
374 relative_quotes += "'" * relative
376 program_name = __main__.program_name
377 paper_string = string.join (paper_options, '\n ') % override
378 preamble_string = string.join (preamble_options, '\n ') % override
379 notes_string = string.join (notes_options, '\n ') % vars ()
380 return (PREAMBLE_LY + body) % vars ()
383 # use lilypond-bin for latex (.lytex) books,
384 # and lilypond --preview for html, texinfo books?
386 cmd = r'latex "\nonstopmode \input %s"' % file
387 # Ugh. (La)TeX writes progress and error messages on stdout
389 cmd = '(( %s >&2 ) >&- )' % cmd
391 ly.system ('dvips -Ppdf -u+lilypond.map -E -o %s.eps %s' \
394 def find_file (name):
395 for i in include_path:
396 full = os.path.join (i, name)
397 if os.path.exists (full):
399 ly.error (_ ('file not found: %s\n' % name))
403 def verbatim_html (s):
404 return re.sub ('>', '>',
406 re.sub ('&', '&', s)))
408 def verbatim_texinfo (s):
409 return re.sub ('{', '@{',
411 re.sub ('@', '@@', s)))
413 def split_options (option_string):
414 return re.split (format_res[format]['option-sep'], option_string)
418 def replacement_text (self):
421 def filter_text (self):
422 return self.replacement_text ()
425 def is_outdated (self):
428 class Substring (Chunk):
429 def __init__ (self, source, start, end):
434 def replacement_text (self):
435 return self.source [self.start:self.end]
437 class Snippet (Chunk):
438 def __init__ (self, type, match, format):
445 def replacement_text (self):
446 return self.match.group (0)
448 def substring (self, s):
449 return self.match.group (s)
452 return `self.__class__` + " type = " + self.type
454 class Include_snippet (Snippet):
455 def processed_filename (self):
456 f = self.substring ('filename')
457 return os.path.splitext (f)[0] + format2ext[format]
459 def replacement_text (self):
460 s = self.match.group (0)
461 f = self.substring ('filename')
463 return re.sub (f, self.processed_filename (), s)
465 class Lilypond_snippet (Snippet):
466 def __init__ (self, type, match, format):
467 Snippet.__init__ (self, type, match, format)
468 os = match.group ('options')
470 self.options = split_options (os)
473 return self.substring ('code')
478 return compose_ly (s, self.options)
483 self.hash = abs (hash (self.full_ly ()))
488 return 'lily-%d' % self.get_hash ()
492 outf = open (self.basename () + '.ly', 'w')
493 outf.write (self.full_ly ())
495 def is_outdated (self):
496 base = self.basename ()
497 ## FIXME: adding PNG to is_outdated test fixes
498 ## interrupted (web) builds.
499 ## should only do this if PNG is actually target
500 if os.path.exists (base + '.ly') \
501 and os.path.exists (base + '.tex') \
502 and os.path.exists (base + '.png') \
504 or self.ly () == open (base + '.ly').read ()):
505 # TODO: something smart with target formats
506 # (ps, png) and m/ctimes
510 def filter_text (self):
511 code = self.substring ('code')
512 s = run_filter (code)
514 'options': self.match.group ('options')
517 return output[self.format][FILTER] % d
519 def replacement_text (self):
520 func = Lilypond_snippet.__dict__ ['output_' + self.format]
523 def get_images (self):
524 base = self.basename ()
526 single = '%(base)s.png' % vars ()
527 multiple = '%(base)s-page1.png' % vars ()
529 if os.path.exists (multiple) \
530 and (not os.path.exists (single)\
531 or (os.stat (multiple)[stat.ST_MTIME] \
532 > os.stat (single)[stat.ST_MTIME])):
533 images = glob.glob ('%(base)s-page*.png' % vars ())
536 def output_html (self):
538 base = self.basename ()
540 str += self.output_print_filename (HTML)
541 if VERBATIM in self.options:
542 verb = verbatim_html (self.substring ('code'))
543 str += write (output[HTML][VERBATIM] % vars ())
545 str += output[HTML][BEFORE] % vars ()
546 for image in self.get_images ():
547 base, ext = os.path.splitext (image)
548 str += output[HTML][OUTPUT] % vars ()
549 str += output[HTML][AFTER] % vars ()
552 def output_info (self):
553 str = self.output_print_filename (HTML)
554 str = output[TEXINFO][BEFORE] % vars ()
555 for image in self.get_images ():
556 base, ext = os.path.splitext (image)
557 # URG, makeinfo implicitely prepends dot to ext
558 # specifying no extension is most robust
560 str += output[TEXINFO][OUTPUT] % vars ()
561 str += output[TEXINFO][AFTER] % vars ()
564 def output_latex (self):
566 base = self.basename ()
568 str += self.output_print_filename (LATEX)
569 if VERBATIM in self.options:
570 verb = self.substring ('code')
571 str += (output[LATEX][VERBATIM] % vars ())
572 str += (output[LATEX][BEFORE]
573 + (output[LATEX][OUTPUT] % vars ())
574 + output[LATEX][AFTER])
577 def output_print_filename (self,format):
579 if PRINTFILENAME in self.options:
580 base = self.basename ()
581 filename = self.substring ('filename')
582 str = output[format][PRINTFILENAME] % vars ()
585 def output_texinfo (self):
587 # self.output_print_filename (TEXINFO)
588 str += ('@html\n' + self.output_print_filename (HTML)
590 str += ('@tex\n' + self.output_print_filename (LATEX)
592 base = self.basename ()
593 if TEXIDOC in self.options:
594 texidoc = base + '.texidoc'
595 if os.path.exists (texidoc):
596 str += '@include %(texidoc)s\n' % vars ()
598 if VERBATIM in self.options:
599 verb = verbatim_texinfo (self.substring ('code'))
600 str += (output[TEXINFO][VERBATIM] % vars ())
602 str += ('@ifinfo\n' + self.output_info () + '\n@end ifinfo\n')
603 str += ('@tex\n' + self.output_latex () + '\n@end tex\n')
604 str += ('@html\n' + self.output_html () + '\n@end html\n')
605 # need par after image
610 class Lilypond_file_snippet (Lilypond_snippet):
612 name = self.substring ('filename')
613 return '\\renameinput \"%s\"\n' % name\
614 + open (find_file (name)).read ()
617 snippet_type_to_class = {
618 'lilypond_file' : Lilypond_file_snippet,
619 'lilypond_block' : Lilypond_snippet,
620 'lilypond' : Lilypond_snippet,
621 'include' : Include_snippet,
624 def find_toplevel_snippets (s, types):
627 res[i] = ly.re.compile (snippet_res[format][i])
631 ## found = dict (map (lambda x: (x, None), types))
634 map (lambda x, f=found: f.setdefault (x, None), types)
636 # We want to search for multiple regexes, without searching
637 # the string multiple times for one regex.
638 # Hence, we use earlier results to limit the string portion
640 # Since every part of the string is traversed at most once for
641 # every type of snippet, this is linear.
647 if not found[type] or found[type][0] < index:
649 m = res[type].search (s[index:endex])
654 if snippet_type_to_class.has_key (type):
655 cl = snippet_type_to_class[type]
656 snip = cl (type, m, format)
657 start = index + m.start (0)
658 found[type] = (start, snip)
661 and (not first or found[type][0] < found[first][0]):
666 # Limiting the search space is a cute
667 # idea, but this *requires* to search
668 # for possible containing blocks
669 # first, at least long as we do not
670 # search for the start of blocks, but
671 # always/directly for the entire
672 # @block ... @end block.
674 endex = found[first][0]
677 snippets.append (Substring (s, index, len (s)))
680 (start , snip) = found[first]
681 snippets.append (Substring (s, index, start))
682 snippets.append (snip)
684 index = start + len (snip.match.group (0))
688 def filter_pipe (input, cmd):
690 ly.progress (_ ("Opening filter `%s\'") % cmd)
692 stdin, stdout, stderr = os.popen3 (cmd)
694 status = stdin.close ()
698 output = stdout.read ()
699 status = stdout.close ()
700 error = stderr.read ()
704 signal = 0x0f & status
705 if status or (not output and error):
706 exit_status = status >> 8
707 ly.error (_ ("`%s\' failed (%d)") % (cmd, exit_status))
708 ly.error (_ ("The error log is as follows:"))
709 sys.stderr.write (error)
710 sys.stderr.write (stderr.read ())
719 return filter_pipe (s, filter_cmd)
721 def is_derived (object, base):
722 def recurse (cl, baseclass):
725 for b in cl.__bases__:
726 if recurse (b, baseclass):
730 cl = object.__class__
731 return recurse (cl, base)
734 def process_snippets (cmd, snippets):
735 names = filter (lambda x: x, map (Lilypond_snippet.basename, snippets))
737 ly.system (string.join ([cmd] + names))
739 if format == HTML or format == TEXINFO:
741 if os.path.exists (i + '.tex'):
743 ly.make_ps_images (i + '.eps', resolution=110)
745 LATEX_DOCUMENT = r'''
748 \typeout{textwidth=\the\textwidth}
749 \typeout{columnsep=\the\columnsep}
750 \makeatletter\if@twocolumn\typeout{columns=2}\fi\makeatother
753 #need anything else besides textwidth?
754 def get_latex_textwidth (source):
755 m = re.search (r'''(?P<preamble>\\begin\s*{document})''', source)
756 preamble = source[:m.start (0)]
757 latex_document = LATEX_DOCUMENT % vars ()
758 parameter_string = filter_pipe (latex_document, latex_filter_cmd)
761 m = re.search ('columns=([0-9.]*)', parameter_string)
763 columns = string.atoi (m.group (1))
766 m = re.search ('columnsep=([0-9.]*)pt', parameter_string)
768 columnsep = string.atof (m.group (1))
771 m = re.search('textwidth=([0-9.]*)pt', parameter_string)
773 textwidth = string.atof (m.group (1))
775 textwidth = (textwidth - columnsep) / columns
786 '.texinfo' : TEXINFO,
792 #TEXINFO: '.texinfo',
797 def do_file (input_filename):
801 e = os.path.splitext (input_filename)[1]
802 if e in ext2format.keys ():
804 format = ext2format[e]
806 ly.error (_ ("cannot determine format for: %s" \
809 if not input_filename or input_filename == '-':
810 in_handle = sys.stdin
811 input_fullname = '<stdin>'
813 if os.path.exists (input_filename):
814 input_fullname = input_filename
815 elif format == LATEX:
816 # urg python interface to libkpathsea?
817 input_fullname = ly.read_pipe ('kpsewhich '
818 + input_filename)[:-1]
820 input_fullname = find_file (input_filename)
821 in_handle = open (input_fullname)
823 if input_filename == '-':
826 input_base = os.path.basename \
827 (os.path.splitext (input_filename)[0])
829 # only default to stdout when filtering
830 if output_name == '-' or (not output_name and filter_cmd):
831 output_filename = '-'
832 output_file = sys.stdout
835 output_filename = input_base + format2ext[format]
837 if not os.path.isdir (output_name):
838 os.mkdir (output_name, 0777)
839 output_filename = (output_name
841 + format2ext[format])
844 if (os.path.exists (input_filename) and
845 os.path.exists (output_filename) and
846 os.path.samefile (output_filename, input_fullname)):
847 ly.error (_("Output would overwrite input file; use --output."))
850 output_file = open (output_filename, 'w')
852 os.chdir (output_name)
854 ly.progress (_ ("Reading %s...") % input_fullname)
855 source = in_handle.read ()
858 # FIXME: containing blocks must be first, see find_toplevel_snippets
864 'singleline_comment',
868 ly.progress (_ ("Dissecting..."))
869 chunks = find_toplevel_snippets (source, snippet_types)
872 global default_ly_options
874 if LINEWIDTH not in default_ly_options.keys ():
876 textwidth = get_latex_textwidth (source)
877 default_ly_options[LINEWIDTH] = '''%.0f\\pt''' \
879 elif format == TEXINFO:
880 for (k, v) in texinfo_linewidths.items ():
881 # FIXME: @paper is usually not in chunk #0:
882 # \input texinfo @c -*-texinfo-*-
883 # bluntly search first K of source
884 # s = chunks[0].replacement_text ()
885 if re.search (k, source[:1024]):
886 default_ly_options[LINEWIDTH] = v
890 output_file.writelines ([c.filter_text () for c in chunks])
894 outdated = filter (lambda x: is_derived (x, Lilypond_snippet) \
895 and x.is_outdated (), chunks)
896 ly.progress (_ ("Writing snippets..."))
897 map (Lilypond_snippet.write_ly, outdated)
901 ly.progress (_ ("Processing..."))
902 process_snippets (process_cmd, outdated)
904 ly.progress (_ ("All snippets are up to date..."))
907 ly.progress (_ ("Compiling %s...") % output_filename)
908 output_file.writelines ([s.replacement_text () \
912 def process_include (snippet):
913 os.chdir (original_dir)
914 name = snippet.substring ('filename')
915 ly.progress (_ ('Processing include: %s') % name)
919 map (process_include,
920 filter (lambda x: is_derived (x, Include_snippet), chunks))
923 global format, output_name
924 global filter_cmd, process_cmd, verbose_p
926 (sh, long) = ly.getopt_args (option_definitions)
928 (options, files) = getopt.getopt (sys.argv[1:], sh, long)
929 except getopt.error, s:
930 sys.stderr.write ('\n')
931 ly.error (_ ("getopt says: `%s\'" % s))
932 sys.stderr.write ('\n')
942 elif o == '--filter' or o == '-F':
945 elif o == '--format' or o == '-f':
947 if a == 'texi-html' or a == 'texi':
949 elif o == '--help' or o == '-h':
952 elif o == '--include' or o == '-I':
953 include_path.append (os.path.join (original_dir,
955 elif o == '--output' or o == '-o':
957 elif o == '--outdir':
959 elif o == '--process' or o == '-P':
962 elif o == '--version' or o == '-v':
963 ly.identify (sys.stdout)
965 elif o == '--verbose' or o == '-V':
967 elif o == '--warranty' or o == '-w':
974 files = do_options ()
977 process_cmd += string.join ([(' -I %s' % p)
978 for p in include_path])
980 ly.identify (sys.stderr)
981 ly.setup_environment ()
985 if __name__ == '__main__':