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