]> git.donarmstrong.com Git - lilypond.git/blobdiff - buildscripts/makelsr.py
Merge branch 'master' of git://git.sv.gnu.org/lilypond
[lilypond.git] / buildscripts / makelsr.py
index c902131d04619ae6d5b85bc3a7202beeb93240a9..2206e61eeb38f00084f4d87cdcf45fe38c57b620 100755 (executable)
@@ -4,28 +4,62 @@ import os
 import os.path
 import shutil
 
-dirs=['advanced','trick']
+dirs = ['ancient','chords','connecting','contemporary','expressive','education','guitar','parts','pitches','repeats','scheme','spacing','staff','text','vocal','other']
+notsafe=[]
 
 try:
-       in_dir=sys.argv[1]
+       in_dir = sys.argv[1]
 except:
        print "Please specify input_file."
-       exit
+       sys.exit()
+
+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 -dno-print-pages -dsafe -o /tmp/lsrtest ' + dest)
+                       if s:
+                               notsafe.append(dest)
+
 
 for dir in dirs:
-       srcdir = os.path.join(in_dir, dir)
-       destdir = os.path.join(os.getcwd(), 'lsr', dir)
+       srcdir = os.path.join (in_dir, dir)
+       destdir = os.path.join ('input', 'lsr', dir)
+       if not(os.path.isdir(destdir)):
+               print "Please run this script from the head of the source tree,"
+               print "  and/or check that you have the right categories."
+               sys.exit()
 
-       file_names=os.listdir(destdir)
+       ## clean out existing files
+       file_names = os.listdir (destdir)
        for file in file_names:
-               if (file[-3:]=='.ly'):
-                       if not(file=='+.ly'):
+               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:
-               out_name=file
-               src = os.path.join(srcdir, file)
-               dest = os.path.join(destdir, out_name)
-               shutil.copyfile(src, dest)
+
+file=open("lsr-unsafe.txt", 'w')
+for s in notsafe:
+       file.write(s+'\n')
+file.close()
+print
+print
+print "Unsafe files printed in lsr-unsafe.txt: CHECK MANUALLY!"
+print "  xargs git-diff < lsr-unsafe.txt"
+print