]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-book.py
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[lilypond.git] / scripts / lilypond-book.py
index bfa302375ee962074b58a7aebe76c020e3c3f890..6699ba2dcb8b5a269536238c32f4331b6c5f92cb 100644 (file)
@@ -35,6 +35,7 @@ import commands
 import os
 import sys
 import re
+import md5
 
 ################
 # RELOCATION
@@ -1066,17 +1067,20 @@ class Lilypond_snippet (Snippet):
         d.update (locals())
         return (PREAMBLE_LY + body) % d
 
-    # TODO: Use md5?
     def get_hash (self):
         if not self.hash:
-            self.hash = abs (hash (self.relevant_contents (self.full_ly ())))
+            hash = md5.md5 (self.relevant_contents (self.full_ly ()))
+
+            ## let's not create too long names.
+            self.hash = hash.hexdigest ()[:10]
+            
         return self.hash
 
     def basename (self):
         if FILENAME in self.option_dict:
             return self.option_dict[FILENAME]
         if global_options.use_hash:
-            return 'lily-%d' % self.get_hash ()
+            return 'lily-%s' % self.get_hash ()
         raise 'to be done'
 
     def write_ly (self):
@@ -1098,14 +1102,17 @@ class Lilypond_snippet (Snippet):
             and os.path.exists (systems_file)
             and os.stat (systems_file)[stat.ST_SIZE]
             and re.match ('% eof', open (systems_file).readlines ()[-1])
-            and (not global_options.use_hash or FILENAME in self.option_dict)
+            and (global_options.use_hash or FILENAME in self.option_dict)
             and (self.relevant_contents (self.full_ly ())
                  == self.relevant_contents (open (ly_file).read ()))):
             return None
+        if global_options.verbose:
+            print 'OUT OF DATE: ', ly_file
         return self
 
     def png_is_outdated (self):
         base = self.basename ()
+        # FIXME: refactor stupid OK stuff
         ok = not self.ly_is_outdated ()
         if global_options.format in (HTML, TEXINFO):
             ok = ok and os.path.exists (base + '.eps')
@@ -1127,6 +1134,7 @@ class Lilypond_snippet (Snippet):
         if backend == 'ps':
             return 0
 
+        # FIXME: refactor stupid OK stuff
         base = self.basename ()
         ok = self.ly_is_outdated ()
         ok = ok and (os.path.exists (base + '.texstr'))
@@ -1761,6 +1769,7 @@ def do_options ():
     return args
 
 def main ():
+    # FIXME: 85 lines of `main' macramee??
     files = do_options ()
 
     file = files[0]