]> git.donarmstrong.com Git - lilypond.git/blob - buildscripts/makelsr.py
LSR: update to build system.
[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 notconvert=[]
10
11 try:
12         in_dir = sys.argv[1]
13 except:
14         print "Please specify input_file."
15         sys.exit()
16
17 def copy_with_warning(src, dest):
18         msg = '%%  Do not edit this file; it is auto-generated from LSR!\n'
19         open (dest, 'w').write( msg + open (src).read() )
20
21
22 def copy_dir_with_test(srcdir, destdir):
23         global notsafe
24         global notconvert
25         if not(os.path.exists(srcdir)):
26                 return
27         file_names = os.listdir (srcdir)
28         for file in file_names:
29                 if (file.endswith ('.ly')):
30                         src = os.path.join (srcdir, file)
31                         dest = os.path.join (destdir, file)
32                         copy_with_warning(src, dest)
33                         os.system('convert-ly -e ' + dest)
34                         if os.path.exists( dest + '~' ):
35                                 os.remove( dest + '~' )
36                         # the -V seems to make unsafe snippets fail nicer/sooner.
37                         s = os.system('nice lilypond -V -dno-print-pages -dsafe -o /tmp/lsrtest ' + dest)
38                         #s = os.system('nice lilypond -dno-print-pages -dsafe -o /tmp/lsrtest ' + dest)
39                         if s:
40                                 notsafe.append(dest)
41
42
43 for dir in dirs:
44         srcdir = os.path.join (in_dir, dir)
45         destdir = os.path.join ('input', 'lsr', dir)
46         if not(os.path.isdir(destdir)):
47                 print "Please run this script from the head of the source tree,"
48                 print "  and/or check that you have the right categories."
49                 sys.exit()
50
51         ## clean out existing files
52         file_names = os.listdir (destdir)
53         for file in file_names:
54                 if (file.endswith ('.ly')):
55                         os.remove( os.path.join(destdir,file) )
56         ## copy in new files from LSR download
57         copy_dir_with_test( srcdir, destdir )
58         ## copy in new files in source tree
59         copy_dir_with_test( os.path.join ('input', 'new', dir), destdir )
60
61
62 file=open("not-converted.txt", 'w')
63 for s in notconvert:
64         file.write(s+'\n')
65 file.close()
66
67 file=open("lsr-unsafe.txt", 'w')
68 for s in notsafe:
69         file.write(s+'\n')
70 file.close()
71
72 print
73 print
74 print "List of files that could not be automatically updated printed",
75 print "in not-converted.txt: CHECK MANUALLY!"
76 print
77 print "Unsafe files printed in lsr-unsafe.txt: CHECK MANUALLY!"
78 print "  xargs git-diff < lsr-unsafe.txt"
79 print
80