]> git.donarmstrong.com Git - lilypond.git/blobdiff - buildscripts/makelsr.py
Rename input/tolsr/ to input/new/.
[lilypond.git] / buildscripts / makelsr.py
index 25a1d9c043a7a9ba389da1413f56117d6ba6a1db..26ac31aec1ba80012f5e8eb957ef31a3b0a37ce5 100755 (executable)
@@ -4,8 +4,7 @@ import os
 import os.path
 import shutil
 
-# 'expressive' not available yet
-dirs = ['ancient','chords','connecting','contemporary','expressive','guitar','parts','repeats','spacing','staff','text','vocal']
+dirs = ['ancient','chords','connecting','contemporary','expressive','guitar','parts','repeats','scheme','spacing','staff','text','vocal']
 notsafe=[]
 
 try:
@@ -14,15 +13,25 @@ except:
        print "Please specify input_file."
        sys.exit()
 
-def copyWithWarning(src, dest):
-       readFile = open(src, 'r')
-       readFileLines = readFile.readlines()
-       readFile.close()
-       writeFile = open(dest, 'w')
-       writeFile.write('%%  Do not edit this file; it is auto-generated from LSR!\n')
-       for line in readFileLines:
-               writeFile.write(line)
-       writeFile.close()
+def copy_with_warning(src, dest):
+       msg = '%%  Do not edit this file; it is auto-generated from LSR!\n'
+       open (dest, 'w').write( msg + open (src).read() )
+
+
+def copy_dir_with_test(srcdir, destdir):
+       if not(os.path.exists(srcdir)):
+               return
+       file_names = os.listdir (srcdir)
+       for file in file_names:
+               if (file.endswith ('.ly')):
+                       src = os.path.join (srcdir, file)
+                       dest = os.path.join (destdir, file)
+                       copy_with_warning(src, dest)
+                       os.system('convert-ly -e ' + dest)
+                       s = os.system('lilypond -dsafe -dbackend=svg -o /tmp/lsrtest ' + dest)
+                       if s:
+                               notsafe.append(dest)
+
 
 for dir in dirs:
        srcdir = os.path.join (in_dir, dir)
@@ -32,22 +41,17 @@ for dir in dirs:
                print "  and/or check that you have the right categories."
                sys.exit()
 
+       ## clean out existing files
        file_names = os.listdir (destdir)
        for file in file_names:
                if (file.endswith ('.ly')):
                        if (file[:3] != 'AAA'):
                                os.remove( os.path.join(destdir,file) )
+       ## copy in new files from LSR download
+       copy_dir_with_test( srcdir, destdir )
+       ## copy in new files in source tree
+       copy_dir_with_test( os.path.join ('input', 'new', dir), destdir )
 
-       file_names = os.listdir (in_dir + dir)
-       for file in file_names:
-               src = os.path.join (srcdir, file)
-               dest = os.path.join (destdir, file)
-               copyWithWarning(src, dest)
-#              shutil.copyfile (src, dest)
-               s = os.system('lilypond -dsafe -dbackend=svg -o /tmp/lsrtest ' + dest)
-               if s:
-                       notsafe.append(dest)
-                       #raise 'Failed'
 
 file=open("lsr-unsafe.txt", 'w')
 for s in notsafe:
@@ -56,7 +60,6 @@ file.close()
 print
 print
 print "Unsafe files printed in lsr-unsafe.txt: CHECK MANUALLY!"
-print "  (probably with  xargs git-diff < lsr-unsafe.txt  )"
+print "  xargs git-diff < lsr-unsafe.txt"
 print
 
-