4 =======================================================================
5 LilyPond to dvi converter
7 Features include Title information, paper size specification, and image
10 Usage: ly2dvi.py [OPTION]... [FILE]...
11 Input: LilyPond source or LilyPond generated TeX files
13 =======================================================================
32 This class handles all ly2dvi.py input file methods
36 __init__() Constructor
37 open(file) Open a .ly file or .tex file using lilyinclude path
38 close() Close current file
39 type() Determine file type .ly (input) or .tex (output)
40 setVars() Set title definitions found in .tex (output) file
55 open file and set private class variable __fd. The search
56 sequence is: current directory followed by the directories
57 found in include property list. Each directory is searched
58 for file, file.ly, file.sly and file.fly.
62 error: ExitNotFound Exception
65 for i in [''] + Props.get('include')[0:]:
66 ifile = os.path.join(i,file)
67 for j in ['','.ly','.fly', '.sly']:
70 this.__fd = open( jfile, 'r' )
74 sys.exit('ExitNotFound', file)
82 close file object __fd
96 Determine input file type. LilyPond source is 'input' type
97 and LilyPond generated TeX file is 'output' type
100 output: 'input' | 'output'
104 firstline = this.__fd.readline()
106 if re.match('%created by: GNU LilyPond [0-9]+[.0-9]+',firstline ):
117 Search for properties in the current input file and set the
118 appropriate values. The supported properties names are in
119 local variable varTable along with the property list
130 ( 'language', Props.setLanguage ),
131 ( 'latexheaders', Props.setHeader ),
132 ( 'orientation', Props.setOrientation ),
133 ( 'paperpapersize', Props.setPaperZize ),
134 ( 'papertextheight', Props.setTextHeight ),
135 ( 'paperlinewidth', Props.setLineWidth ),
136 ( 'filename', Props.setFilename ),
140 for line in this.__fd.readlines():
141 m=re.match('\\\\def\\\\mudela([\w]+){(.*)}',line)
144 if m.group(1) == var[0]:
145 var[1](m.group(2),'file')
147 for var in Props.get('titledefs'):
148 if m.group(1) == var:
149 titles[var]=m.group(2)
151 Props.setTitles(titles,'file')
158 This class handles all ly2dvi.py output file methods
161 __mudelaDefs(opt) Send title info to output file
164 __init__() Constructor
165 write(str) Write a string to output file
166 start(file) Start the latex file
167 next() Process next output file
168 end() Finish latex file and run latex
182 def __mudelaDefs(this,opt):
184 Write titles to output
186 input: opt Supports header and subheader output
191 titles = Props.get('titles')
192 for key in titles.keys():
193 this.write('%s\\mudela%s{%s}%%\n' % (opt,key,titles[key]))
200 Write str to current output file
202 input: str String to write
212 def start(this,file):
214 Start LaTeX file. Calculates the horizontal and vertical
215 margin using pagewidth, pageheight, linewidth, and textheight.
216 Creates temporary output filename and opens it for write.
217 Sends the LaTeX header information to output. Lastly sends
218 the title information to output.
220 input: file output file name
225 now=time.asctime(time.localtime(time.time()))
226 linewidth = Props.get('linewidth')
227 textheight = Props.get('textheight')
229 if Props.get('orientation') == 'landscape':
230 pagewidth = Props.get('pageheight')
231 pageheight = Props.get('pagewidth')
233 pageheight = Props.get('pageheight')
234 pagewidth = Props.get('pagewidth')
236 horizontalMarginArg = ( (pagewidth - linewidth)/2 )
237 verticalMarginArg = ( (pageheight - textheight)/2 )
241 %% Automatically generated from %s, %s
243 \\documentclass[%s]{article}
246 \\usepackage{geometry}
247 \\usepackage[latin1]{inputenc}
248 %%\\usepackage[T1]{fontenc}
250 %%\\addtolength{\\oddsidemargin}{-1cm}
251 %%\\addtolength{\\topmargin}{-1cm}
252 %%\\setlength{\\textwidth}{%s}
253 %%\\setlength{\\textheight}{%s}
254 \\geometry{width=%spt, left=%spt, height=%spt, top=%spt}
259 """ % ( program_id(), Props.get('filename'), now, Props.get('papersize'),
260 Props.get('language'), Props.get('pagenumber'), linewidth, textheight,
261 linewidth, horizontalMarginArg, textheight, verticalMarginArg,
262 Props.get('header') )
264 base, ext = os.path.splitext(file)
266 tempfile.template= base + '_ly'
267 this.__outfile = tempfile.mktemp(ext)
268 base, ext = os.path.splitext(this.__outfile)
269 this.__tmpbase = base
271 this.__fd = open(this.__outfile,"w")
273 sys.exit('ExitNoWrite', this.__outfile)
275 this.__mudelaDefs('')
285 Write LaTeX subheader information to support more than one
286 score in a document. Lastly send current title information to
298 \\def\\mudelapiece{}%
300 this.__mudelaDefs("\\def")
302 \\def\\theopus{\\mudelaopus}% ugh
303 \\def\\thepiece{\\mudelapiece}%
313 Close output file and run latex on it.
317 error: ExitBadLatex Exception
320 outfile=this.__base + '.dvi'
321 if Props.get('output') != '':
322 outfile = os.path.join(Props.get('output'), outfile )
325 \\vfill\\hfill{\\mudelatagline}
329 if os.path.isfile(outfile):
331 if ( os.name == 'posix' ):
332 stat = os.system('latex \'\\nonstopmode \\input %s\'' %
334 else: # Windows shells don't eat the single quotes
335 stat = os.system('latex \\nonstopmode \\input %s' %
338 sys.exit('ExitBadLatex')
339 if not os.path.isfile(outfile):
340 os.rename(this.__tmpbase + '.dvi', outfile)
342 sys.stderr.write('\n' + program_id() + ': dvi file name is %s\n\n'
345 if Props.get('postscript'):
346 psoutfile=this.__base + '.ps'
347 if Props.get('output') != '':
348 psoutfile = os.path.join(Props.get('output'), psoutfile )
349 stat = os.system('dvips -o %s %s' % (psoutfile,outfile))
351 sys.exit('ExitBadPostscript')
358 This class handles all ly2dvi.py property manipulation
362 __init__() Constructor
363 set<property> methods
369 # Following is the order of priority for property assignment. The
370 # list is organized from lowest to highest priority. Each
371 # assignment is overridden by the next requester in the list.
373 # Requester Description
374 # --------- -----------
375 # init Initial default values
376 # file The values found in the lilypond generated TeX files
377 # environment Envrionment variables LILYINCLUDE, LILYPONDPREFIX
378 # rcfile $LILYPONDPREFIX/.lilyrc
379 # rcfile $HOME/.lilyrc
381 # commandline command line arguments
383 this.__overrideTable = {
392 this.__roverrideTable = {} # reverse lookup used for debug
393 for i in this.__overrideTable.items():
394 this.__roverrideTable[i[1]]=i[0]
397 'pagewidth' : [597, this.__overrideTable['init']],
398 'pageheight' : [845, this.__overrideTable['init']],
399 'papersize' : ['a4paper', this.__overrideTable['init']],
400 'textheight' : [0, this.__overrideTable['init']],
401 'linewidth' : [500, this.__overrideTable['init']],
402 'orientation' : ['portrait', this.__overrideTable['init']],
403 'language' : ['%', this.__overrideTable['init']],
404 'include' : [[], this.__overrideTable['init']],
405 'debug' : [0, this.__overrideTable['init']],
406 'keeplilypond' : [0, this.__overrideTable['init']],
407 'keeply2dvi' : [0, this.__overrideTable['init']],
408 'pagenumber' : ['%', this.__overrideTable['init']],
409 'separate' : [0, this.__overrideTable['init']],
410 'output' : ['', this.__overrideTable['init']],
411 'header' : ['%', this.__overrideTable['init']],
412 'dependencies' : [0, this.__overrideTable['init']],
413 'root' : ['', this.__overrideTable['init']],
414 'tmp' : ['d:\tmp', this.__overrideTable['init']],
415 'filename' : ['', this.__overrideTable['init']],
416 'titledefs' : [[], this.__overrideTable['init']],
417 'titles' : [{}, this.__overrideTable['init']],
418 'lilyOutputFiles' : [[], this.__overrideTable['init']],
419 'postscript' : [0, this.__overrideTable['init']],
423 # Try to set root and HOME first before calling rcfile
425 if os.environ.has_key('LILYPONDPREFIX'):
426 this.setRoot(os.environ['LILYPONDPREFIX'], 'environment')
428 p=os.path.split(sys.argv[0])
429 p=os.path.split(p[0])
430 # bit silly. for ly2dvi, overrules compiled-in datadir...
431 # how to do this better (without running lily, of course?
432 this.setRoot(os.path.join(p[0],'share','lilypond'), 'init')
434 if not os.environ.has_key('HOME'):
435 if os.environ.has_key('HOMEDRIVE') and \
436 os.environ.has_key('HOMEPATH'):
437 os.environ['HOME'] = os.environ['HOMEDRIVE'] + \
438 os.environ['HOMEPATH']
440 os.environ['HOME'] = os.curdir
442 this.rcfile() # Read initialization file(s)
444 if os.environ.has_key('LILYINCLUDE'):
445 tmp=this.get('include')
446 for s in string.split(os.environ['LILYINCLUDE'],os.pathsep):
448 this.__set('include', tmp, 'environment')
452 if os.environ.has_key ('TEXINPUTS'):
453 t = os.environ['TEXINPUTS'] + os.pathsep
454 os.environ['TEXINPUTS'] = t + \
455 os.path.join(this.get('root'), 'tex' ) + \
456 os.pathsep + os.path.join(this.get('root'), 'ps' )
459 if os.environ.has_key ('MFINPUTS'):
460 t = os.environ['MFINPUTS']
461 os.environ['MFINPUTS'] = os.pathsep + t + \
462 os.path.join(this.get('root'), 'mf')
464 if os.environ.has_key('TMP'):
465 this.__set('tmp',os.environ['TMP'],'environment')
468 fd=this.get_texfile_path ('titledefs.tex')
471 for line in fd.readlines():
472 m=re.match('\\\\newcommand\*{\\\\mudela([\w]+)}',line)
474 mudefs.append(m.group(1))
476 this.__set('titledefs', mudefs, 'init')
481 def __set(this,var,value,requester):
483 All of the set methods call this to set a property. If the value
484 was last set by a requestor of lesser priority the new value is
485 assigned, else the old value has priority and is unchanged.
488 if this.__overrideTable[requester] < this.__data[var][1]:
491 this.__data[var] = [value, this.__overrideTable[requester]]
498 All of the get methods call this to get a property value. List
499 variable types are return by value to facilitate an append operation.
502 if var == 'include' or var == 'lilyOutputFiles':
503 return this.__data[var][0][0:] # return a copy not a ref
505 return this.__data[var][0]
510 def get_texfile_path (this, var):
512 locate and open titledefs.tex file
516 path = os.path.join(this.get('root'), 'tex', var)
519 cmd =('kpsewhich tex %s %s' % (var,errorlog))
520 pipe = os.popen (cmd, 'r')
521 path = pipe.readline ()[:-1] # chop off \n
522 return_status = pipe.close()
523 if return_status and not path:
524 path = os.path.join(this.get('root'), 'tex', var)
534 Read initialization file(s)
539 ( 'DEBUG', this.setDebug ),
540 ( 'DEPENDENCIES', this.setDependencies ),
541 ( 'KEEPLILYPOND', this.setKeeplilypond ),
542 ( 'KEEPLY2DVI', this.setKeeply2dvi ),
543 ( 'LANGUAGE', this.setLanguage ),
544 ( 'LATEXHF', this.setHeader ),
545 ( 'LILYINCLUDE', this.setInclude ),
546 ( 'LILYPONDPREFIX', this.setRoot ),
547 ( 'NONUMBER', this.setNonumber ),
548 ( 'ORIENTATION', this.setOrientation ),
549 ( 'OUTPUTDIR', this.setOutput ),
550 ( 'PAPERSIZE', this.setPaperZize ),
551 ( 'PHEIGHT', this.setTextHeight ),
552 ( 'POSTSCRIPT', this.setPostscript ),
553 ( 'PWIDTH', this.setLineWidth ),
554 ( 'SEPARATE', this.setSeparate ),
555 ( 'TMP', this.setTmp ),
558 if ( os.name == 'posix' ):
559 dotFilename='.lilyrc'
560 else: # Windows apps like edit choke on .lilyrc
561 dotFilename='_lilyrc'
563 for d in [os.path.join(this.get('root'),'ly'), \
564 os.environ['HOME'], os.curdir ]:
565 file=os.path.join(d,dotFilename)
567 fd = open( file, 'r' )
571 for line in fd.readlines():
572 if re.match('#.*',line):
574 m=re.search('([\w]+)=(.*)',line)
577 if m.group(1) == var[0]:
578 var[1](m.group(2),'rcfile')
585 def setPaperZize(this,size,requester):
587 Set paper size properties
591 # regex width height name
592 # ----- ----- ------ ----
593 ( 'a0.*', 2389, 3381, 'a0paper' ),
594 ( 'a1$|a1p.*', 1690, 2389, 'a1paper' ),
595 ( 'a2.*', 1194, 1690, 'a2paper' ),
596 ( 'a3.*', 845, 1194, 'a3paper' ),
597 ( 'a4.*', 597, 845, 'a4paper' ),
598 ( 'a5.*', 423, 597, 'a5paper' ),
599 ( 'a6.*', 298, 423, 'a6paper' ),
600 ( 'a7.*', 211, 298, 'a7paper' ),
601 ( 'a8.*', 305, 211, 'a8paper' ),
602 ( 'a9.*', 105, 305, 'a9paper' ),
603 ( 'a10.*', 74, 105, 'a10paper' ),
604 ( 'b0.*', 2847, 4023, 'b0paper' ),
605 ( 'b1.*', 2012, 2847, 'b1paper' ),
606 ( 'b2.*', 1423, 2012, 'b2paper' ),
607 ( 'b3.*', 1006, 1423, 'b3paper' ),
608 ( 'b4.*', 712, 1006, 'b4paper' ),
609 ( 'b5.*', 503, 712, 'b5paper' ),
610 ( 'archA$', 650, 867, 'archApaper' ),
611 ( 'archB$', 867, 1301, 'archBpaper' ),
612 ( 'archC$', 1301, 1734, 'archCpaper' ),
613 ( 'archD$', 1734, 2602, 'archDpaper' ),
614 ( 'archE$', 2602, 3469, 'archEpaper' ),
615 ( 'flsa$|flse$', 614, 940, 'flsapaper' ),
616 ( 'halfletter$', 397, 614, 'halfletterpaper' ),
617 ( 'ledger$', 1229, 795, 'ledgerpaper' ),
618 ( 'legal$', 614, 1012, 'legalpaper' ),
619 ( 'letter$', 614, 795, 'letterpaper' ),
620 ( 'note$', 542, 723, 'notepaper' )
624 for paper in paperTable:
625 if re.match(paper[0],size):
627 this.__set('pagewidth',paper[1],requester)
628 this.__set('pageheight',paper[2],requester)
629 this.__set('papersize',paper[3],requester)
633 sys.exit('ExitBadPaper',size)
638 def setTextHeight(this,size,requester):
640 Set textheight property
643 m=re.match('([0-9][.0-9]*)(cm|mm|pt|$)',size)
645 if m.group(2) == 'cm':
646 this.__set('textheight',\
647 float(m.group(1)) * 72.27/2.54, requester )
648 elif m.group(2) == 'mm':
649 this.__set('textheight',\
650 float(m.group(1)) * 72.27/25.4, requester )
651 elif m.group(2) == 'pt':
652 this.__set('textheight', float(m.group(1)), requester )
653 elif m.group(2) == '':
654 this.__set('textheight', float(m.group(1)), requester )
656 sys.exit('ExitBadHeight', m.group(2))
658 sys.exit('ExitBadHeight', size)
663 def setLineWidth(this,size,requester):
665 Set linewidth propery
668 m=re.match('([0-9][.0-9]*)(cm|mm|pt|$)',size)
670 if m.group(2) == 'cm':
671 this.__set('linewidth', \
672 float(m.group(1)) * 72.27/2.54, requester )
673 elif m.group(2) == 'mm':
674 this.__set('linewidth', \
675 float(m.group(1)) * 72.27/25.4, requester )
676 elif m.group(2) == 'pt':
677 this.__set('linewidth', float(m.group(1)), requester )
678 elif m.group(2) == '':
679 this.__set('linewidth', float(m.group(1)), requester )
681 sys.exit('ExitBadWidth', m.group(2))
683 sys.stderr.write ('ly2dvi: warning: ignoring linewidth: ' + size + '\n')
688 def setOrientation(this,orient,requester):
690 Set orientation property
693 if orient == 'landscape' or orient == 'portrait':
694 this.__set('orientation', orient, requester )
696 sys.exit('ExitBadOrient', orient)
701 def setLanguage(this,lang,requester):
703 Set language property
706 this.__set('language', '\\usepackage[%s]{babel}' % (lang), requester )
711 def setInclude(this,inc, requester):
713 Append an include path
716 tmp = this.get('include')
718 this.__set('include', tmp, requester )
723 def setDebug(this,value,requester):
725 Set or Clear debug flag
729 this.__set('debug',1,requester)
731 this.__set('debug',0,requester)
736 def setKeeplilypond(this, value, requester):
738 Set or Clear keeplilypond flag
742 this.__set('keeplilypond',1,requester)
744 this.__set('keeplilypond',0,requester)
749 def setKeeply2dvi(this, value, requester):
751 Set or Clear keeply2dvi flag
755 this.__set('keeply2dvi',1,requester)
757 this.__set('keeply2dvi',0,requester)
762 def setNonumber(this, value, requester):
768 this.__set('pagenumber','\\pagestyle{empty}',requester)
770 this.__set('pagenumber','%',requester)
775 def setSeparate(this, value, requester):
777 Set or Clear separate flag
781 this.__set('separate',1,requester)
783 this.__set('separate',0,requester)
786 # Set output directory name
788 def setOutput(this,out,requester):
789 this.__set('output',out,requester)
792 # Set latex header name
794 def setHeader(this,head, requester):
795 this.__set('header',head,requester)
798 # Set or Clear Dependencies flag to generate makefile dependencies
800 def setDependencies(this, value, requester):
802 Set or Clear dependencies flag
806 this.__set('dependencies',1,requester)
808 this.__set('dependencies',0,requester)
813 def setTmp(this,dir, requester):
814 this.__set('tmp',dir,requester)
817 # Set mudela source file name
819 def setFilename(this,file, requester):
820 this.__set('filename',file,requester)
825 def setTitles(this,titles, requester):
826 this.__set('titles',titles,requester)
831 def addLilyOutputFiles(this,filelist,requester):
833 Add a to the lily output list
836 tmp = this.get('lilyOutputFiles')
838 this.__set('lilyOutputFiles',tmp,requester)
841 # Set/Clear postscript flag
843 def setPostscript(this,value,requester):
849 this.__set('postscript',1,requester)
851 this.__set('postscript',0,requester)
856 def setRoot(this,path, requester):
858 Set lilypond root directory
861 os.environ['LILYPONDPREFIX'] = path
862 if os.name == 'nt' or os.name == 'dos':
863 path = unc2dos(path);
865 this.__set('root',path,requester)
871 def printProps(this):
876 for key in this.__data.keys():
877 print "%s <%s>:<%s>" % (key,this.get(key),
878 this.__roverrideTable[this.__data[key][1]])
888 if len(Props.get('include')) > 0:
889 inc = string.join (map (lambda x: '-I "%s"' % x, Props.get('include')))
892 if Props.get('dependencies'):
899 def writeLilylog(file,contents):
900 if Props.get('keeplilypond'):
901 base, ext = os.path.splitext(file)
902 tempfile.template=base + "_li"
903 file=tempfile.mktemp('.log')
904 output = Props.get('output')
906 file = os.path.join( output, file )
908 fd = open( file, 'w' )
910 sys.exit('ExitNoWrite', file)
914 def getTeXFile(contents):
916 for line in string.split(contents,'\n'):
917 m = re.search('^Paper output to (.+)\.\.\.', line)
919 texfiles.append(m.group(1))
922 sys.exit('ExitNoTeXName')
928 Convert a path of format //<drive>/this/that/the/other to
929 <drive>:\this\that\the\other
931 m=re.match('^//([A-Za-z])(/.*)$',path)
933 return m.group(1) + ':' + os.path.normpath(m.group(2))
938 return name + ' ' + version;
943 return os.environ['MAILADDRESS']
945 return '(address unknown)'
949 sys.stderr.write (program_id () + '\n')
953 'Generate dvi file from mudela or lilypond output\n'
954 'Usage: ' + name + ' [OPTION]... [FILE]...\n'
957 ' -D,--debug increase verbosity\n'
958 ' -F,--headers= name of additional LaTeX headers file\n'
959 ' -H,--Height= set paper height (points) (see manual page)\n'
960 ' -I,--include=DIR add DIR to LilyPond\'s search path\n'
961 ' -K,--keeplilypond keep lilypond output files\n'
962 ' -L,--landscape set landscape orientation\n'
963 ' -N,--nonumber switch off page numbering\n'
964 ' -O,--orientation= set orientation (obsolete - use -L instead)\n'
965 ' -P,--postscript generate postscript file\n'
966 ' -W,--Width= set paper width (points) (see manual page)\n'
967 ' -M,--dependencies tell lilypond make a dependencies file\n'
968 ' -h,--help this help text\n'
969 ' -k,--keeply2dvi keep ly2dvi output files\n'
970 ' -l,--language= give LaTeX language (babel)\n'
971 ' -o,--output= set output directory\n'
972 ' -p,--papersize= give LaTeX papersize (eg. a4)\n'
973 ' -s,--separate run all files separately through LaTeX\n'
975 'files may be (a mix of) input to or output from lilypond(1)\n'
985 """Generate dvi files from lilypond source/output"""
988 outfile = TeXOutput()
992 (options, files) = getopt.getopt (sys.argv[1:],
993 'DF:H:I:KLNPW:Mhkl:o:p:s',
994 ['debug', 'headers=', 'Height=',
995 'include=', 'keeplilypond', 'landscape',
996 'nonumber', 'Width=', 'dependencies',
997 'help', 'keeply2dvi', 'language=',
998 'output=', 'papersize=', 'separate',
1003 if o == '--debug' or o == '-D':
1004 Props.setDebug(1,'commandline')
1005 elif o == '--headers' or o == '-F':
1006 Props.setHeader(a,'commandline')
1007 elif o == '--include' or o == '-I':
1008 Props.setInclude(a,'commandline')
1009 elif o == '--Height' or o == '-H':
1010 Props.setTextHeight(a,'commandline')
1011 elif o == '--keeplilypond' or o == '-K':
1012 Props.setKeeplilypond(1,'commandline')
1013 elif o == '--landscape' or o == '-L':
1014 Props.setOrientation('landscape','commandline')
1015 elif o == '--nonumber' or o == '-N':
1016 Props.setNonumber(1,'commandline')
1017 elif o == '--Width' or o == '-W':
1018 Props.setLineWidth(a,'commandline')
1019 elif o == '--dependencies' or o == '-M':
1020 Props.setDependencies(1,'commandline')
1021 elif o == '--help' or o == '-h':
1024 elif o == '--keeply2dvi' or o == '-k':
1025 Props.setKeeply2dvi(1,'commandline')
1026 elif o == '--language' or o == '-l':
1027 Props.setLanguage(a,'commandline')
1028 elif o == '--output' or o == '-o':
1029 Props.setOutput(a,'commandline')
1030 elif o == '--papersize' or o == '-p':
1031 Props.setPaperZize(a,'commandline')
1032 elif o == '--separate' or o == '-s':
1033 Props.setSeparate(1,'commandline')
1034 elif o == '--postscript' or o == '-P':
1035 Props.setPostscript(1,'commandline')
1040 type = infile.type()
1042 if type == 'source':
1043 if os.environ.has_key('OS') and \
1044 os.environ['OS'] == 'Windows_95':
1045 cmd = 'ash -c "lilypond %s %s 2>&1"' %(getLilyopts(), file)
1047 cmd = 'lilypond %s %s 2>&1' % (getLilyopts(), file)
1048 sys.stderr.write ('executing: %s\n'% cmd)
1050 fd = os.popen(cmd , 'r')
1055 sys.stderr.write (s)
1062 sys.stderr.write (s)
1068 sys.exit('ExitBadLily', cmd )
1069 texFiles=getTeXFile(log)
1070 writeLilylog(file,log)
1071 Props.addLilyOutputFiles(texFiles,'program')
1072 texInputFiles = texInputFiles + texFiles
1074 texInputFiles.append(file)
1077 for file in texInputFiles:
1079 infile.setVars() # first pass set variables
1081 if Props.get('debug'):
1084 outfile.start(file) # allow for specified name
1090 if Props.get('separate'):
1094 if not Props.get('separate'):
1098 sys.exit('ExitBadArgs','No files specified')
1104 'ExitInterupt' : ['Ouch!', 1 ],
1105 'ExitBadArgs' : ['Wrong number of arguments', 2 ],
1106 'ExitNotFound' : ['File not found', 3 ],
1107 'ExitBadPaper' : ['Unknown papersize', 4 ],
1108 'ExitBadHeight' : ['Invalid Height specification', 5 ],
1109 'ExitBadWidth' : ['Invalid Width specification', 6 ],
1110 'ExitBadOrient' : ['Invalid Orientation specification', 7 ],
1111 'ExitNoWrite' : ['Permission denied', 8 ],
1112 'ExitNoTeXName' : ['hmm, I could not find an output file name', 9 ],
1113 'ExitBadLily' : ['Lilypond failed', 10 ],
1114 'ExitBadLatex' : ['Latex failed', 11 ],
1115 'ExitBadPostscript' : ['Postscript failed', 12 ],
1116 'ExitUnknown' : ['Unknown Exit Code', 20 ],
1122 if not Props.get('keeplilypond'):
1123 lilyfiles = Props.get('lilyOutputFiles')
1124 if not Props.get('keeply2dvi'):
1125 tmpfiles = glob.glob('*_ly[0-9]*.*')
1126 for file in lilyfiles + tmpfiles:
1127 if os.path.isfile(file):
1132 Props = Properties()
1137 except KeyboardInterrupt:
1138 print ExitTable['ExitInterupt'][0]
1140 sys.exit(ExitTable['ExitInterupt'][1])
1142 except SystemExit, errno:
1143 if ExitTable.has_key(errno.args[0]):
1144 msg = ExitTable[errno.args[0]]
1146 msg = ExitTable['ExitUnknown']
1147 if len(errno.args) > 1:
1148 sys.stderr.write( '%s: %s: %s\n' % (name, msg[0], errno.args[1]))
1150 sys.stderr.write( '%s %s\n' % (name, msg[0]))
1151 if Props.get('debug'):