%s
%s
-''' % ( _ ('Copyright (c) %s by') % '2001--2010',
+''' % ( _ ('Copyright (c) %s by') % '2001--2011',
'\n '.join (authors),
_ ("Distributed under terms of the GNU General Public License."),
_ ("It comes with NO WARRANTY.")))
action='store',
dest='process_cmd', default='')
+ p.add_option ('--redirect-lilypond-output',
+ help = _ ("Redirect the lilypond output"),
+ action='store_true',
+ dest='redirect_output', default=False)
+
+ p.add_option ('-s', '--safe', help=_ ("Compile snippets in safe mode"),
+ action="store_true",
+ default=False,
+ dest="safe_mode")
+
p.add_option ('--skip-lily-check',
help=_ ("do not fail if no lilypond output is found"),
metavar=_ ("DIR"),
return snippets
-def system_in_directory (cmd, directory):
+def system_in_directory (cmd, directory, logfile):
"""Execute a command in a different directory.
Because of win32 compatibility, we can't simply use subprocess.
current = os.getcwd()
os.chdir (directory)
- ly.system(cmd, be_verbose=global_options.verbose,
+ ly.system(cmd,
+ be_verbose=global_options.verbose,
+ redirect_output=global_options.redirect_output,
+ log_file=logfile,
progress_p=1)
os.chdir (current)
+ list (set ([snip.basename() + '.ly' for snip in snippets])))
name = os.path.join (lily_output_dir,
'snippet-names-%d.ly' % checksum)
+ logfile = name.replace('.ly', '')
file (name, 'wb').write (contents)
system_in_directory (' '.join ([cmd, ly.mkarg (name)]),
- lily_output_dir)
+ lily_output_dir,
+ logfile)
def snippet_list_checksum (snippets):
def do_file (input_filename, included=False):
# Ugh.
+ input_absname = input_filename
if not input_filename or input_filename == '-':
in_handle = sys.stdin
input_fullname = '<stdin>'
else:
input_fullname = global_options.formatter.input_fullname (input_filename)
# Normalize path to absolute path, since we will change cwd to the output dir!
- input_fullname = os.path.abspath (input_fullname)
+ # Otherwise, "lilypond-book -o out test.tex" will complain that it is
+ # overwriting the input file (which it is actually not), since the
+ # input filename is relative to the CWD...
+ input_absname = os.path.abspath (input_fullname)
note_input_file (input_fullname)
in_handle = file (input_fullname)
input_base + global_options.formatter.default_extension)
if (os.path.exists (input_filename)
and os.path.exists (output_filename)
- and samefile (output_filename, input_fullname)):
+ and samefile (output_filename, input_absname)):
error (
_ ("Output would overwrite input file; use --output."))
exit (2)
source = in_handle.read ()
progress ('\n')
- global_options.formatter.init_default_snippet_options (source)
+ if not included:
+ global_options.formatter.init_default_snippet_options (source)
progress (_ ("Dissecting..."))