From 7eb3deeb7e8c7025322336b83ab54a5b43b15942 Mon Sep 17 00:00:00 2001 From: Julien Rioux Date: Tue, 17 Jan 2012 21:21:50 -0500 Subject: [PATCH] lilypond-book: Specify filename and ext for all snippets. Filename is used to link to the source file, ext is used to link to the generated file base.ext (usually a lily-????.ly, although for musicxml input files we copy the original to lily-????.xml). For inline snippets use an empty filename and '.ly' as ext. --- python/book_snippets.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/python/book_snippets.py b/python/book_snippets.py index e5a43110ff..7e5e946863 100644 --- a/python/book_snippets.py +++ b/python/book_snippets.py @@ -329,6 +329,8 @@ class IncludeSnippet (Snippet): class LilypondSnippet (Snippet): def __init__ (self, type, match, formatter, line_number, global_options): Snippet.__init__ (self, type, match, formatter, line_number, global_options) + self.filename = '' + self.ext = '.ly' os = match.group ('options') self.parse_snippet_options (os, self.type) @@ -651,7 +653,10 @@ printing diff against existing file." % filename) def additional_files_to_consider (self, base, full): return [] def additional_files_required (self, base, full): - return [] + result = []; + if self.ext != '.ly': + result.append (base + self.ext) + return result def all_output_files (self, output_dir, output_dir_files): @@ -803,7 +808,6 @@ class LilypondFileSnippet (LilypondSnippet): def __init__ (self, type, match, formatter, line_number, global_options): LilypondSnippet.__init__ (self, type, match, formatter, line_number, global_options) self.filename = self.substring ('filename') - self.ext = os.path.splitext (os.path.basename (self.filename))[1] self.contents = file (BookBase.find_file (self.filename, global_options.include_path, global_options.original_dir)).read () @@ -838,6 +842,7 @@ class MusicXMLFileSnippet (LilypondFileSnippet): LilypondFileSnippet.__init__ (self, type, match, formatter, line_number, global_options) self.compressed = False self.converted_ly = None + self.ext = os.path.splitext (os.path.basename (self.filename))[1] self.musicxml_options_dict = { 'verbose': '--verbose', 'lxml': '--lxml', @@ -881,14 +886,6 @@ class MusicXMLFileSnippet (LilypondFileSnippet): return ('\\sourcefilename \"%s\"\n\\sourcefileline 0\n%s' % (name, self.converted_ly)) - def additional_files_required (self, base, full): - result = []; - if self.compressed: - result.append (base + '.mxl') - else: - result.append (base + '.xml') - return result - def write_ly (self): base = self.basename () path = os.path.join (self.global_options.lily_output_dir, base) -- 2.39.2