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