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