]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/book_snippets.py
Web-ja: update introduction
[lilypond.git] / python / book_snippets.py
index 69fdc4fa6867401cdcd40fecbf16b4e6324ed4b7..4bc4252e79da3bad9cb15876eb2f4218a4f24d2f 100644 (file)
@@ -644,10 +644,20 @@ printing diff against existing file." % filename)
             if not os.path.isdir (dst_path):
                 os.makedirs (dst_path)
             try:
-                os.link (src, dst)
-            except AttributeError:
-                shutil.copyfile (src, dst)
-            except OSError:
+                if (self.global_options.use_source_file_names
+                        and isinstance (self, LilypondFileSnippet)):
+                    fout = open (dst, 'w')
+                    fin = open (src, 'r')
+                    for line in fin.readlines ():
+                        fout.write (line.replace (self.basename (), self.final_basename ()))
+                    fout.close ()
+                    fin.close ()
+                else:
+                    try:
+                        os.link (src, dst)
+                    except AttributeError:
+                        shutil.copyfile (src, dst)
+            except (IOError, OSError):
                 error (_ ('Could not overwrite file %s') % dst)
                 raise CompileError(self.basename())