X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Flilypond-book.py;h=9cdd14742b76e1dda97211f351f818fdc8d15921;hb=0b544cfb7332615ef809b71b57ab656741311ae1;hp=41df22da59ee4aafe1547f2159dd15f32f1925e7;hpb=2f0c6eb19208485a86d3416db3f3640a1d54752a;p=lilypond.git diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 41df22da59..9cdd14742b 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -112,7 +112,7 @@ def warranty (): %s %s -''' % ( _ ('Copyright (c) %s by') % '2001--2012', +''' % ( _ ('Copyright (c) %s by') % '2001--2014', '\n '.join (authors), _ ("Distributed under terms of the GNU General Public License."), _ ("It comes with NO WARRANTY."))) @@ -277,6 +277,11 @@ if 'bindir' in globals () and bindir: if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary): lilypond_binary = 'lilypond' +# Need to shell-quote, issue 3468 + +import pipes +lilypond_binary = pipes.quote (lilypond_binary) + global_options = None @@ -438,7 +443,10 @@ def split_output_files(directory): Return value is a set of strings. """ files = [] - for subdir in glob.glob (os.path.join (directory, '[a-f0-9][a-f0-9]')): + def globquote(x): + return re.sub ("[][*?]", r"[\g<0>]", x) + for subdir in glob.glob (os.path.join (globquote (directory), + '[a-f0-9][a-f0-9]')): base_subdir = os.path.split (subdir)[1] sub_files = [os.path.join (base_subdir, name) for name in os.listdir (subdir)] @@ -464,12 +472,15 @@ def do_process_cmd (chunks, input_name, options): else: progress (_ ("All snippets are up to date...")) - if options.lily_output_dir != options.output_dir: - output_files = split_output_files (options.lily_output_dir) + progress (_ ("Linking files...")) + abs_lily_output_dir = os.path.join (options.original_dir, options.lily_output_dir) + abs_output_dir = os.path.join (options.original_dir, options.output_dir) + if abs_lily_output_dir != abs_output_dir: + output_files = split_output_files (abs_lily_output_dir) for snippet in snippets: - snippet.link_all_output_files (options.lily_output_dir, + snippet.link_all_output_files (abs_lily_output_dir, output_files, - options.output_dir) + abs_output_dir) ### @@ -541,10 +552,12 @@ def do_file (input_filename, included=False): in_handle = file (input_fullname) if input_filename == '-': + global_options.input_dir = os.getcwd () input_base = 'stdin' elif included: input_base = os.path.splitext (input_filename)[0] else: + global_options.input_dir = os.path.split (input_absname)[0] input_base = os.path.basename ( os.path.splitext (input_filename)[0]) @@ -613,7 +626,7 @@ def inverse_relpath (path, relpath): return the first path relative to the second.""" if os.path.isabs (relpath): return os.path.abspath (path) - relparts = [''] + relparts = [] parts = os.path.normpath (path).split (os.path.sep) for part in os.path.normpath (relpath).split (os.path.sep): if part == '..': @@ -641,12 +654,14 @@ def do_options (): global_options.output_dir = os.path.expanduser (global_options.output_dir) global_options.include_path.insert (0, inverse_relpath (original_dir, global_options.output_dir)) + global_options.include_path.insert (0, ".") + # Load the python packages (containing e.g. custom formatter classes) # passed on the command line nr = 0 for i in global_options.custom_packages: nr += 1 - print imp.load_source ("book_custom_package%s" % nr, i) + progress (str(imp.load_source ("book_custom_package%s" % nr, i))) if global_options.warranty: