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')
357 # ARG! THIS CODE IS BLOATED:
358 # FIXME: Junk all set/get methods.
362 This class handles all ly2dvi.py property manipulation
366 __init__() Constructor
367 set<property> methods
373 # Following is the order of priority for property assignment. The
374 # list is organized from lowest to highest priority. Each
375 # assignment is overridden by the next requester in the list.
377 # Requester Description
378 # --------- -----------
379 # init Initial default values
380 # file The values found in the lilypond generated TeX files
381 # environment Envrionment variables LILYINCLUDE, LILYPONDPREFIX
382 # rcfile $LILYPONDPREFIX/.lilyrc
383 # rcfile $HOME/.lilyrc
385 # commandline command line arguments
387 this.__overrideTable = {
396 this.__roverrideTable = {} # reverse lookup used for debug
397 for i in this.__overrideTable.items():
398 this.__roverrideTable[i[1]]=i[0]
401 'pagewidth' : [597, this.__overrideTable['init']],
402 'pageheight' : [845, this.__overrideTable['init']],
403 'papersize' : ['a4paper', this.__overrideTable['init']],
404 'textheight' : [0, this.__overrideTable['init']],
405 'linewidth' : [500, this.__overrideTable['init']],
406 'orientation' : ['portrait', this.__overrideTable['init']],
407 'language' : ['%', this.__overrideTable['init']],
408 'include' : [[], this.__overrideTable['init']],
409 'debug' : [0, this.__overrideTable['init']],
410 'keeplilypond' : [0, this.__overrideTable['init']],
411 'keeply2dvi' : [0, this.__overrideTable['init']],
412 'pagenumber' : ['%', this.__overrideTable['init']],
413 'separate' : [0, this.__overrideTable['init']],
414 'output' : ['', this.__overrideTable['init']],
415 'header' : ['%', this.__overrideTable['init']],
416 'dependencies' : [0, this.__overrideTable['init']],
417 'root' : ['', this.__overrideTable['init']],
418 'tmp' : ['d:\tmp', this.__overrideTable['init']],
419 'filename' : ['', this.__overrideTable['init']],
420 'titledefs' : [[], this.__overrideTable['init']],
421 'titles' : [{}, this.__overrideTable['init']],
422 'lilyOutputFiles' : [[], this.__overrideTable['init']],
423 'postscript' : [0, this.__overrideTable['init']],
427 # Try to set root and HOME first before calling rcfile
429 if os.environ.has_key('LILYPONDPREFIX'):
430 this.setRoot(os.environ['LILYPONDPREFIX'], 'environment')
432 p=os.path.split(sys.argv[0])
433 p=os.path.split(p[0])
434 # bit silly. for ly2dvi, overrules compiled-in datadir...
435 # how to do this better (without running lily, of course?
436 this.setRoot(os.path.join(p[0],'share','lilypond'), 'init')
438 if not os.environ.has_key('HOME'):
439 if os.environ.has_key('HOMEDRIVE') and \
440 os.environ.has_key('HOMEPATH'):
441 os.environ['HOME'] = os.environ['HOMEDRIVE'] + \
442 os.environ['HOMEPATH']
444 os.environ['HOME'] = os.curdir
446 this.rcfile() # Read initialization file(s)
448 if os.environ.has_key('LILYINCLUDE'):
449 tmp=this.get('include')
450 for s in string.split(os.environ['LILYINCLUDE'],os.pathsep):
452 this.__set('include', tmp, 'environment')
456 if os.environ.has_key ('TEXINPUTS'):
457 t = os.environ['TEXINPUTS'] + os.pathsep
458 os.environ['TEXINPUTS'] = t + \
459 os.path.join(this.get('root'), 'tex' ) + \
460 os.pathsep + os.path.join(this.get('root'), 'ps' )
463 if os.environ.has_key ('MFINPUTS'):
464 t = os.environ['MFINPUTS']
465 os.environ['MFINPUTS'] = os.pathsep + t + \
466 os.path.join(this.get('root'), 'mf')
468 if os.environ.has_key('TMP'):
469 this.__set('tmp',os.environ['TMP'],'environment')
472 fd=this.get_texfile_path ('titledefs.tex')
475 for line in fd.readlines():
476 m=re.match('\\\\newcommand\*{\\\\mudela([\w]+)}',line)
478 mudefs.append(m.group(1))
480 this.__set('titledefs', mudefs, 'init')
485 def __set(this,var,value,requester):
487 All of the set methods call this to set a property. If the value
488 was last set by a requestor of lesser priority the new value is
489 assigned, else the old value has priority and is unchanged.
492 if this.__overrideTable[requester] < this.__data[var][1]:
495 this.__data[var] = [value, this.__overrideTable[requester]]
502 All of the get methods call this to get a property value. List
503 variable types are return by value to facilitate an append operation.
506 if var == 'include' or var == 'lilyOutputFiles':
507 return this.__data[var][0][0:] # return a copy not a ref
509 return this.__data[var][0]
514 def get_texfile_path (this, var):
516 locate and open titledefs.tex file
520 path = os.path.join(this.get('root'), 'tex', var)
523 cmd =('kpsewhich tex %s %s' % (var,errorlog))
524 pipe = os.popen (cmd, 'r')
525 path = pipe.readline ()[:-1] # chop off \n
526 return_status = pipe.close()
527 if return_status and not path:
528 path = os.path.join(this.get('root'), 'tex', var)
538 Read initialization file(s)
543 ( 'DEBUG', this.setDebug ),
544 ( 'DEPENDENCIES', this.setDependencies ),
545 ( 'KEEPLILYPOND', this.setKeeplilypond ),
546 ( 'KEEPLY2DVI', this.setKeeply2dvi ),
547 ( 'LANGUAGE', this.setLanguage ),
548 ( 'LATEXHF', this.setHeader ),
549 ( 'LILYINCLUDE', this.setInclude ),
550 ( 'LILYPONDPREFIX', this.setRoot ),
551 ( 'NONUMBER', this.setNonumber ),
552 ( 'ORIENTATION', this.setOrientation ),
553 ( 'OUTPUTDIR', this.setOutput ),
554 ( 'PAPERSIZE', this.setPaperZize ),
555 ( 'PHEIGHT', this.setTextHeight ),
556 ( 'POSTSCRIPT', this.setPostscript ),
557 ( 'PWIDTH', this.setLineWidth ),
558 ( 'SEPARATE', this.setSeparate ),
559 ( 'TMP', this.setTmp ),
562 if ( os.name == 'posix' ):
563 dotFilename='.lilyrc'
564 else: # Windows apps like edit choke on .lilyrc
565 dotFilename='_lilyrc'
567 for d in [os.path.join(this.get('root'),'ly'), \
568 os.environ['HOME'], os.curdir ]:
569 file=os.path.join(d,dotFilename)
571 fd = open( file, 'r' )
575 for line in fd.readlines():
576 if re.match('#.*',line):
578 m=re.search('([\w]+)=(.*)',line)
581 if m.group(1) == var[0]:
582 var[1](m.group(2),'rcfile')
589 def setPaperZize(this,size,requester):
591 Set paper size properties
595 # regex width height name
596 # ----- ----- ------ ----
597 ( 'a0.*', 2389, 3381, 'a0paper' ),
598 ( 'a1$|a1p.*', 1690, 2389, 'a1paper' ),
599 ( 'a2.*', 1194, 1690, 'a2paper' ),
600 ( 'a3.*', 845, 1194, 'a3paper' ),
601 ( 'a4.*', 597, 845, 'a4paper' ),
602 ( 'a5.*', 423, 597, 'a5paper' ),
603 ( 'a6.*', 298, 423, 'a6paper' ),
604 ( 'a7.*', 211, 298, 'a7paper' ),
605 ( 'a8.*', 305, 211, 'a8paper' ),
606 ( 'a9.*', 105, 305, 'a9paper' ),
607 ( 'a10.*', 74, 105, 'a10paper' ),
608 ( 'b0.*', 2847, 4023, 'b0paper' ),
609 ( 'b1.*', 2012, 2847, 'b1paper' ),
610 ( 'b2.*', 1423, 2012, 'b2paper' ),
611 ( 'b3.*', 1006, 1423, 'b3paper' ),
612 ( 'b4.*', 712, 1006, 'b4paper' ),
613 ( 'b5.*', 503, 712, 'b5paper' ),
614 ( 'archA$', 650, 867, 'archApaper' ),
615 ( 'archB$', 867, 1301, 'archBpaper' ),
616 ( 'archC$', 1301, 1734, 'archCpaper' ),
617 ( 'archD$', 1734, 2602, 'archDpaper' ),
618 ( 'archE$', 2602, 3469, 'archEpaper' ),
619 ( 'flsa$|flse$', 614, 940, 'flsapaper' ),
620 ( 'halfletter$', 397, 614, 'halfletterpaper' ),
621 ( 'ledger$', 1229, 795, 'ledgerpaper' ),
622 ( 'legal$', 614, 1012, 'legalpaper' ),
623 ( 'letter$', 614, 795, 'letterpaper' ),
624 ( 'note$', 542, 723, 'notepaper' )
628 for paper in paperTable:
629 if re.match(paper[0],size):
631 this.__set('pagewidth',paper[1],requester)
632 this.__set('pageheight',paper[2],requester)
633 this.__set('papersize',paper[3],requester)
637 sys.exit('ExitBadPaper',size)
642 def setTextHeight(this,size,requester):
644 Set textheight property
647 m=re.match('([0-9][.0-9]*)(cm|mm|pt|$)',size)
649 if m.group(2) == 'cm':
650 this.__set('textheight',\
651 float(m.group(1)) * 72.27/2.54, requester )
652 elif m.group(2) == 'mm':
653 this.__set('textheight',\
654 float(m.group(1)) * 72.27/25.4, requester )
655 elif m.group(2) == 'pt':
656 this.__set('textheight', float(m.group(1)), requester )
657 elif m.group(2) == '':
658 this.__set('textheight', float(m.group(1)), requester )
660 sys.exit('ExitBadHeight', m.group(2))
662 sys.exit('ExitBadHeight', size)
667 def setLineWidth(this,size,requester):
669 Set linewidth propery
672 m=re.match('([0-9][.0-9]*)(cm|mm|pt|$)',size)
674 if m.group(2) == 'cm':
675 this.__set('linewidth', \
676 float(m.group(1)) * 72.27/2.54, requester )
677 elif m.group(2) == 'mm':
678 this.__set('linewidth', \
679 float(m.group(1)) * 72.27/25.4, requester )
680 elif m.group(2) == 'pt':
681 this.__set('linewidth', float(m.group(1)), requester )
682 elif m.group(2) == '':
683 this.__set('linewidth', float(m.group(1)), requester )
685 sys.exit('ExitBadWidth', m.group(2))
687 sys.stderr.write ('ly2dvi: warning: ignoring linewidth: ' + size + '\n')
692 def setOrientation(this,orient,requester):
694 Set orientation property
697 if orient == 'landscape' or orient == 'portrait':
698 this.__set('orientation', orient, requester )
700 sys.exit('ExitBadOrient', orient)
705 def setLanguage(this,lang,requester):
707 Set language property
710 this.__set('language', '\\usepackage[%s]{babel}' % (lang), requester )
715 def setInclude(this,inc, requester):
717 Append an include path
720 tmp = this.get('include')
722 this.__set('include', tmp, requester )
727 def setDebug(this,value,requester):
729 Set or Clear debug flag
733 this.__set('debug',1,requester)
735 this.__set('debug',0,requester)
740 def setKeeplilypond(this, value, requester):
742 Set or Clear keeplilypond flag
746 this.__set('keeplilypond',1,requester)
748 this.__set('keeplilypond',0,requester)
753 def setKeeply2dvi(this, value, requester):
755 Set or Clear keeply2dvi flag
759 this.__set('keeply2dvi',1,requester)
761 this.__set('keeply2dvi',0,requester)
766 def setNonumber(this, value, requester):
772 this.__set('pagenumber','\\pagestyle{empty}',requester)
774 this.__set('pagenumber','%',requester)
779 def setSeparate(this, value, requester):
781 Set or Clear separate flag
785 this.__set('separate',1,requester)
787 this.__set('separate',0,requester)
790 # Set output directory name
792 def setOutput(this,out,requester):
793 this.__set('output',out,requester)
796 # Set latex header name
798 def setHeader(this,head, requester):
799 this.__set('header',head,requester)
802 # Set or Clear Dependencies flag to generate makefile dependencies
804 def setDependencies(this, value, requester):
806 Set or Clear dependencies flag
810 this.__set('dependencies',1,requester)
812 this.__set('dependencies',0,requester)
817 def setTmp(this,dir, requester):
818 this.__set('tmp',dir,requester)
821 # Set mudela source file name
823 def setFilename(this,file, requester):
824 this.__set('filename',file,requester)
829 def setTitles(this,titles, requester):
830 this.__set('titles',titles,requester)
835 def addLilyOutputFiles(this,filelist,requester):
837 Add a to the lily output list
840 tmp = this.get('lilyOutputFiles')
842 this.__set('lilyOutputFiles',tmp,requester)
845 # Set/Clear postscript flag
847 def setPostscript(this,value,requester):
853 this.__set('postscript',1,requester)
855 this.__set('postscript',0,requester)
860 def setRoot(this,path, requester):
862 Set lilypond root directory
865 os.environ['LILYPONDPREFIX'] = path
866 if os.name == 'nt' or os.name == 'dos':
867 path = unc2dos(path);
869 this.__set('root',path,requester)
875 def printProps(this):
880 for key in this.__data.keys():
881 print "%s <%s>:<%s>" % (key,this.get(key),
882 this.__roverrideTable[this.__data[key][1]])
892 if len(Props.get('include')) > 0:
893 inc = string.join (map (lambda x: '-I "%s"' % x, Props.get('include')))
896 if Props.get('dependencies'):
903 def writeLilylog(file,contents):
904 if Props.get('keeplilypond'):
905 base, ext = os.path.splitext(file)
906 tempfile.template=base + "_li"
907 file=tempfile.mktemp('.log')
908 output = Props.get('output')
910 file = os.path.join( output, file )
912 fd = open( file, 'w' )
914 sys.exit('ExitNoWrite', file)
918 def getTeXFile(contents):
920 for line in string.split(contents,'\n'):
921 m = re.search('^Paper output to (.+)\.\.\.', line)
923 texfiles.append(m.group(1))
926 sys.exit('ExitNoTeXName')
932 Convert a path of format //<drive>/this/that/the/other to
933 <drive>:\this\that\the\other
935 m=re.match('^//([A-Za-z])(/.*)$',path)
937 return m.group(1) + ':' + os.path.normpath(m.group(2))
942 return name + ' ' + version;
947 return os.environ['MAILADDRESS']
949 return '(address unknown)'
953 sys.stderr.write (program_id () + '\n')
957 'Generate dvi file from mudela or lilypond output\n'
958 'Usage: ' + name + ' [OPTION]... [FILE]...\n'
961 ' -D,--debug increase verbosity\n'
962 ' -F,--headers= name of additional LaTeX headers file\n'
963 ' -H,--Height= set paper height (points) (see manual page)\n'
964 ' -I,--include=DIR add DIR to LilyPond\'s search path\n'
965 ' -K,--keeplilypond keep lilypond output files\n'
966 ' -L,--landscape set landscape orientation\n'
967 ' -N,--nonumber switch off page numbering\n'
968 ' -O,--orientation= set orientation (obsolete - use -L instead)\n'
969 ' -P,--postscript generate postscript file\n'
970 ' -W,--Width= set paper width (points) (see manual page)\n'
971 ' -M,--dependencies tell lilypond make a dependencies file\n'
972 ' -h,--help this help text\n'
973 ' -k,--keeply2dvi keep ly2dvi output files\n'
974 ' -l,--language= give LaTeX language (babel)\n'
975 ' -o,--output= set output directory\n'
976 ' -p,--papersize= give LaTeX papersize (eg. a4)\n'
977 ' -s,--separate run all files separately through LaTeX\n'
979 'files may be (a mix of) input to or output from lilypond(1)\n'
989 """Generate dvi files from lilypond source/output"""
992 outfile = TeXOutput()
996 (options, files) = getopt.getopt (sys.argv[1:],
997 'DF:H:I:KLNPW:Mhkl:o:p:s',
998 ['debug', 'headers=', 'Height=',
999 'include=', 'keeplilypond', 'landscape',
1000 'nonumber', 'Width=', 'dependencies',
1001 'help', 'keeply2dvi', 'language=',
1002 'output=', 'papersize=', 'separate',
1007 if o == '--debug' or o == '-D':
1008 Props.setDebug(1,'commandline')
1009 elif o == '--headers' or o == '-F':
1010 Props.setHeader(a,'commandline')
1011 elif o == '--include' or o == '-I':
1012 Props.setInclude(a,'commandline')
1013 elif o == '--Height' or o == '-H':
1014 Props.setTextHeight(a,'commandline')
1015 elif o == '--keeplilypond' or o == '-K':
1016 Props.setKeeplilypond(1,'commandline')
1017 elif o == '--landscape' or o == '-L':
1018 Props.setOrientation('landscape','commandline')
1019 elif o == '--nonumber' or o == '-N':
1020 Props.setNonumber(1,'commandline')
1021 elif o == '--Width' or o == '-W':
1022 Props.setLineWidth(a,'commandline')
1023 elif o == '--dependencies' or o == '-M':
1024 Props.setDependencies(1,'commandline')
1025 elif o == '--help' or o == '-h':
1028 elif o == '--keeply2dvi' or o == '-k':
1029 Props.setKeeply2dvi(1,'commandline')
1030 elif o == '--language' or o == '-l':
1031 Props.setLanguage(a,'commandline')
1032 elif o == '--output' or o == '-o':
1033 Props.setOutput(a,'commandline')
1034 elif o == '--papersize' or o == '-p':
1035 Props.setPaperZize(a,'commandline')
1036 elif o == '--separate' or o == '-s':
1037 Props.setSeparate(1,'commandline')
1038 elif o == '--postscript' or o == '-P':
1039 Props.setPostscript(1,'commandline')
1044 type = infile.type()
1046 if type == 'source':
1047 if os.environ.has_key('OS') and \
1048 os.environ['OS'] == 'Windows_95':
1049 cmd = 'ash -c "lilypond %s %s 2>&1"' %(getLilyopts(), file)
1051 cmd = 'lilypond %s %s 2>&1' % (getLilyopts(), file)
1052 sys.stderr.write ('executing: %s\n'% cmd)
1054 fd = os.popen(cmd , 'r')
1059 sys.stderr.write (s)
1066 sys.stderr.write (s)
1072 sys.exit('ExitBadLily', cmd )
1073 texFiles=getTeXFile(log)
1074 writeLilylog(file,log)
1075 Props.addLilyOutputFiles(texFiles,'program')
1076 texInputFiles = texInputFiles + texFiles
1078 texInputFiles.append(file)
1081 for file in texInputFiles:
1083 infile.setVars() # first pass set variables
1085 if Props.get('debug'):
1088 outfile.start(file) # allow for specified name
1094 if Props.get('separate'):
1098 if not Props.get('separate'):
1102 sys.exit('ExitBadArgs','No files specified')
1108 'ExitInterupt' : ['Ouch!', 1 ],
1109 'ExitBadArgs' : ['Wrong number of arguments', 2 ],
1110 'ExitNotFound' : ['File not found', 3 ],
1111 'ExitBadPaper' : ['Unknown papersize', 4 ],
1112 'ExitBadHeight' : ['Invalid Height specification', 5 ],
1113 'ExitBadWidth' : ['Invalid Width specification', 6 ],
1114 'ExitBadOrient' : ['Invalid Orientation specification', 7 ],
1115 'ExitNoWrite' : ['Permission denied', 8 ],
1116 'ExitNoTeXName' : ['hmm, I could not find an output file name', 9 ],
1117 'ExitBadLily' : ['Lilypond failed', 10 ],
1118 'ExitBadLatex' : ['Latex failed', 11 ],
1119 'ExitBadPostscript' : ['Postscript failed', 12 ],
1120 'ExitUnknown' : ['Unknown Exit Code', 20 ],
1126 if not Props.get('keeplilypond'):
1127 lilyfiles = Props.get('lilyOutputFiles')
1128 if not Props.get('keeply2dvi'):
1129 tmpfiles = glob.glob('*_ly[0-9]*.*')
1130 for file in lilyfiles + tmpfiles:
1131 if os.path.isfile(file):
1136 Props = Properties()
1141 except KeyboardInterrupt:
1142 print ExitTable['ExitInterupt'][0]
1144 sys.exit(ExitTable['ExitInterupt'][1])
1146 except SystemExit, errno:
1147 if ExitTable.has_key(errno.args[0]):
1148 msg = ExitTable[errno.args[0]]
1150 msg = ExitTable['ExitUnknown']
1151 if len(errno.args) > 1:
1152 sys.stderr.write( '%s: %s: %s\n' % (name, msg[0], errno.args[1]))
1154 sys.stderr.write( '%s %s\n' % (name, msg[0]))
1155 if Props.get('debug'):