On Sun, Dec 13, 2009 at 05:49:13PM +0100, Matthias Kilian wrote: > If the a file with the same name always has the same content, > regardless from which document it has been generated, would something > like the following help (no real code, i'm not good at all if it > comes to python)?
Don't laugh at me -- I can't even test this here on OpenBSD, because I don't have all prerequisites available in the necessery versions. diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 392ddd0..35a1d8a 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -1273,8 +1273,17 @@ left-margin-default right-margin-default)" directory = os.path.split(path)[0] if not os.path.isdir (directory): os.makedirs (directory) - out = file (path + '.ly', 'w') + out = tempfile.NamedTemporaryFile(mode = 'w', suffix = '.lytmp', + dir = directory, delete = False) out.write (self.full_ly ()) + out.close() + filename = path + '.ly' + if os.path.exists(filename): + # What else? Print a warning? Compare both files and error + # out if they differ? + os.remove(out.name) + else: + os.rename(out.name, filename) file (path + '.txt', 'w').write ('image of music') def relevant_contents (self, ly): _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel