]> git.donarmstrong.com Git - lilypond.git/blob - buildscripts/makelsr.py
Trivial fix for makelsr.py
[lilypond.git] / buildscripts / makelsr.py
1 #!/usr/bin/python
2 import sys
3 import os
4 import os.path
5 import shutil
6
7 dirs = ['ancient','chords','connecting','contemporary','expressive','education','guitar','parts','pitch','repeats','scheme','spacing','staff','text','vocal','other','non-music','engravers','instrument-specific']
8 notsafe=[]
9
10 try:
11         in_dir = sys.argv[1]
12 except:
13         print "Please specify input_file."
14         sys.exit()
15
16 def copy_with_warning(src, dest):
17         msg = '%%  Do not edit this file; it is auto-generated from LSR!\n'
18         open (dest, 'w').write( msg + open (src).read() )
19
20
21 def copy_dir_with_test(srcdir, destdir):
22         if not(os.path.exists(srcdir)):
23                 return
24         file_names = os.listdir (srcdir)
25         for file in file_names:
26                 if (file.endswith ('.ly')):
27                         src = os.path.join (srcdir, file)
28                         dest = os.path.join (destdir, file)
29                         copy_with_warning(src, dest)
30                         os.system('convert-ly -e ' + dest)
31                         s = os.system('nice lilypond -dno-print-pages -dsafe -o /tmp/lsrtest ' + dest)
32                         if s:
33                                 notsafe.append(dest)
34
35
36 for dir in dirs:
37         srcdir = os.path.join (in_dir, dir)
38         destdir = os.path.join ('input', 'lsr', dir)
39         if not(os.path.isdir(destdir)):
40                 print "Please run this script from the head of the source tree,"
41                 print "  and/or check that you have the right categories."
42                 sys.exit()
43
44         ## clean out existing files
45         file_names = os.listdir (destdir)
46         for file in file_names:
47                 if (file.endswith ('.ly')):
48                         os.remove( os.path.join(destdir,file) )
49         ## copy in new files from LSR download
50         copy_dir_with_test( srcdir, destdir )
51         ## copy in new files in source tree
52         copy_dir_with_test( os.path.join ('input', 'new', dir), destdir )
53
54
55 file=open("lsr-unsafe.txt", 'w')
56 for s in notsafe:
57         file.write(s+'\n')
58 file.close()
59 print
60 print
61 print "Unsafe files printed in lsr-unsafe.txt: CHECK MANUALLY!"
62 print "  xargs git-diff < lsr-unsafe.txt"
63 print
64