]> git.donarmstrong.com Git - lilypond.git/blob - buildscripts/makelsr.py
LSR: tags.
[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 = ['pitches']
8 #dirs = ['ancient','chords','connecting','contemporary','expressive','education','guitar','parts','pitch','repeats','scheme','spacing','staff','text','vocal','other','nonmusic','engravers','instrument']
9 notsafe=[]
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                         destname = file.replace (';', '-')
32                         dest = os.path.join (destdir, destname)
33                         copy_with_warning(src, dest)
34                         os.system('convert-ly -e ' + dest)
35                         if os.path.exists( dest + '~' ):
36                                 os.remove( dest + '~' )
37                         # the -V seems to make unsafe snippets fail nicer/sooner.
38                         s = os.system('nice lilypond -V -dno-print-pages -dsafe -o /tmp/lsrtest ' + dest)
39                         #s = os.system('nice lilypond -dno-print-pages -dsafe -o /tmp/lsrtest ' + dest)
40                         if s:
41                                 notsafe.append(dest)
42
43
44 for dir in dirs:
45         srcdir = os.path.join (in_dir, dir)
46         destdir = os.path.join ('input', 'lsr', dir)
47         if not(os.path.isdir(destdir)):
48                 print "Please run this script from the head of the source tree,"
49                 print "  and/or check that you have the right categories."
50                 sys.exit()
51
52         ## clean out existing files
53         file_names = os.listdir (destdir)
54         for file in file_names:
55                 if (file.endswith ('.ly')):
56                         os.remove( os.path.join(destdir,file) )
57         ## copy in new files from LSR download
58         copy_dir_with_test( srcdir, destdir )
59         ## copy in new files in source tree
60         copy_dir_with_test( os.path.join ('input', 'new', dir), destdir )
61
62
63 file=open("lsr-unsafe.txt", 'w')
64 for s in notsafe:
65         file.write(s+'\n')
66 file.close()
67
68 print
69 print
70 print "Unsafe files printed in lsr-unsafe.txt: CHECK MANUALLY!"
71 print "  xargs git-diff < lsr-unsafe.txt"
72 print
73