X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=python%2Fbook_snippets.py;h=4bc4252e79da3bad9cb15876eb2f4218a4f24d2f;hb=a6a51abfd0195a3cf7d6ea095cf69808852f21ce;hp=69fdc4fa6867401cdcd40fecbf16b4e6324ed4b7;hpb=7a717cd92bdd69fda8e830a80f3f644d6185d9de;p=lilypond.git diff --git a/python/book_snippets.py b/python/book_snippets.py index 69fdc4fa68..4bc4252e79 100644 --- a/python/book_snippets.py +++ b/python/book_snippets.py @@ -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())