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