From: Julien Rioux Date: Thu, 7 Aug 2014 18:25:03 +0000 (+0200) Subject: Fix references when using --use-source-file-names (issue 4046) X-Git-Tag: release/2.19.13-1~32 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=512b082a1c470d0315ae8c5f48da3b374a2de716;p=lilypond.git Fix references when using --use-source-file-names (issue 4046) --- 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())