def main(): if "LILYPOND_BOOK_LOGLEVEL" in os.environ: ly.set_loglevel(os.environ["LILYPOND_BOOK_LOGLEVEL"]) files = do_options() basename = os.path.splitext(files[0])[0] basename = os.path.split(basename)[1] if global_options.format: # Retrieve the formatter for the given format for formatter in book_base.all_formats: if formatter.can_handle_format(global_options.format): global_options.formatter = formatter else: global_options.formatter = guess_format(files[0]) global_options.format = global_options.formatter.format # make the global options available to the formatters: global_options.formatter.global_options = global_options formats = global_options.formatter.image_formats if global_options.process_cmd == '': global_options.process_cmd = (lilypond_binary + ' --formats=%s -dbackend=eps ' % formats) if global_options.process_cmd: includes = global_options.include_path global_options.process_cmd += ' '.join( [' -I %s' % mkarg(p) for p in includes]) global_options.formatter.process_options(global_options) if global_options.lily_loglevel: ly.debug_output( _("Setting LilyPond's loglevel to %s") % global_options.lily_loglevel, True) global_options.process_cmd += " --loglevel=%s" % global_options.lily_loglevel elif ly.is_verbose(): if os.environ.get("LILYPOND_LOGLEVEL", None): ly.debug_output( _("Setting LilyPond's loglevel to %s (from environment variable LILYPOND_LOGLEVEL)" ) % os.environ.get("LILYPOND_LOGLEVEL", None), True) global_options.process_cmd += " --loglevel=%s" % os.environ.get( "LILYPOND_LOGLEVEL", None) else: ly.debug_output( _("Setting LilyPond's output to --verbose, implied by lilypond-book's setting" ), True) global_options.process_cmd += " --verbose" if global_options.padding_mm: global_options.process_cmd += " -deps-box-padding=%f " % global_options.padding_mm global_options.process_cmd += " -dread-file-list -dno-strip-output-dir" if global_options.lily_output_dir: global_options.lily_output_dir = os.path.abspath( global_options.lily_output_dir) else: global_options.lily_output_dir = os.path.abspath( global_options.output_dir) relative_output_dir = global_options.output_dir identify() try: chunks = do_file(files[0]) except book_snippets.CompileError: exit(1) inputs = note_input_file('') inputs.pop() base_file_name = os.path.splitext(os.path.basename(files[0]))[0] dep_file = os.path.join(global_options.output_dir, base_file_name + '.dep') final_output_file = os.path.join( relative_output_dir, base_file_name + global_options.formatter.default_extension) os.chdir(original_dir) open(dep_file, 'w').write('%s: %s\n' % (final_output_file, ' '.join(inputs)))
def main (): # FIXME: 85 lines of `main' macramee?? if (os.environ.has_key ("LILYPOND_BOOK_LOGLEVEL")): ly.set_loglevel (os.environ["LILYPOND_BOOK_LOGLEVEL"]) files = do_options () basename = os.path.splitext (files[0])[0] basename = os.path.split (basename)[1] if global_options.format: # Retrieve the formatter for the given format for formatter in BookBase.all_formats: if formatter.can_handle_format (global_options.format): global_options.formatter = formatter else: global_options.formatter = guess_format (files[0]) global_options.format = global_options.formatter.format # make the global options available to the formatters: global_options.formatter.global_options = global_options formats = global_options.formatter.image_formats if global_options.process_cmd == '': global_options.process_cmd = (lilypond_binary + ' --formats=%s -dbackend=eps ' % formats) if global_options.process_cmd: includes = global_options.include_path if global_options.lily_output_dir: # This must be first, so lilypond prefers to read .ly # files in the other lybookdb dir. includes = [global_options.lily_output_dir] + includes global_options.process_cmd += ' '.join ([' -I %s' % ly.mkarg (p) for p in includes]) global_options.formatter.process_options (global_options) if global_options.lily_loglevel: ly.debug_output (_ ("Setting LilyPond's loglevel to %s") % global_options.lily_loglevel, True) global_options.process_cmd += " --loglevel=%s" % global_options.lily_loglevel elif ly.is_verbose (): if os.environ.get ("LILYPOND_LOGLEVEL", None): ly.debug_output (_ ("Setting LilyPond's loglevel to %s (from environment variable LILYPOND_LOGLEVEL)") % os.environ.get ("LILYPOND_LOGLEVEL", None), True) global_options.process_cmd += " --loglevel=%s" % os.environ.get ("LILYPOND_LOGLEVEL", None) else: ly.debug_output (_ ("Setting LilyPond's output to --verbose, implied by lilypond-book's setting"), True) global_options.process_cmd += " --verbose" if global_options.padding_mm: global_options.process_cmd += " -deps-box-padding=%f " % global_options.padding_mm global_options.process_cmd += " -dread-file-list -dno-strip-output-dir" if global_options.lily_output_dir: global_options.lily_output_dir = os.path.abspath(global_options.lily_output_dir) if not os.path.isdir (global_options.lily_output_dir): os.makedirs (global_options.lily_output_dir) else: global_options.lily_output_dir = os.path.abspath(global_options.output_dir) relative_output_dir = global_options.output_dir identify () try: chunks = do_file (files[0]) except BookSnippet.CompileError: exit (1) inputs = note_input_file ('') inputs.pop () base_file_name = os.path.splitext (os.path.basename (files[0]))[0] dep_file = os.path.join (global_options.output_dir, base_file_name + '.dep') final_output_file = os.path.join (relative_output_dir, base_file_name + global_options.formatter.default_extension) os.chdir (original_dir) file (dep_file, 'w').write ('%s: %s\n' % (final_output_file, ' '.join (inputs)))