]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-book: Specify filename and ext for all snippets.
authorJulien Rioux <jrioux@physics.utoronto.ca>
Wed, 18 Jan 2012 02:21:50 +0000 (21:21 -0500)
committerJulien Rioux <jrioux@physics.utoronto.ca>
Mon, 23 Jan 2012 19:42:55 +0000 (14:42 -0500)
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

index e5a43110ffa268ae6733d09e7c96dc768503ef61..7e5e94686352fd413148dc7f01eabf7ca64c3f50 100644 (file)
@@ -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)