4 # TODO: Rewrite this. The control structure is too hairy.
7 =======================================================================
8 LilyPond to dvi converter
10 Features include Title information, paper size specification, and image
13 Usage: ly2dvi.py [OPTION]... [FILE]...
14 Input: LilyPond source or LilyPond generated TeX files
16 =======================================================================
20 version = '@TOPLEVEL_VERSION@'
32 os.environ['LANG'] = '' # Can't grep localized msgs
38 This class handles all ly2dvi.py input file methods
42 __init__() Constructor
43 open(file) Open a .ly file or .tex file using lilyinclude path
44 close() Close current file
45 type() Determine file type .ly (input) or .tex (output)
46 setVars() Set title definitions found in .tex (output) file
61 open file and set private class variable __fd. The search
62 sequence is: current directory followed by the directories
63 found in include property list. Each directory is searched
64 for file, file.ly, file.sly and file.fly.
68 error: ExitNotFound Exception
71 for i in [''] + Props.get('include')[0:]:
72 ifile = os.path.join(i,file)
73 for j in ['','.ly','.fly', '.sly']:
76 this.__fd = open( jfile, 'r' )
80 sys.exit('ExitNotFound', file)
88 close file object __fd
102 Determine input file type. LilyPond source is 'input' type
103 and LilyPond generated TeX file is 'output' type
106 output: 'input' | 'output'
110 firstline = this.__fd.readline()
112 if re.match('%created by: GNU LilyPond [0-9]+[.0-9]+',firstline ):
123 Search for properties in the current input file and set the
124 appropriate values. The supported properties names are in
125 local variable varTable along with the property list
136 ( 'language', Props.setLanguage ),
137 ( 'latexheaders', Props.setHeader ),
138 ( 'orientation', Props.setOrientation ),
139 ( 'paperpapersize', Props.setPaperZize ),
140 ( 'papertextheight', Props.setTextHeight ),
141 ( 'paperlinewidth', Props.setLineWidth ),
142 ( 'filename', Props.setFilename ),
146 for line in this.__fd.readlines():
147 m=re.match('\\\\def\\\\mudela([\w]+){(.*)}',line)
150 if m.group(1) == var[0]:
151 var[1](m.group(2),'file')
153 for var in Props.get('titledefs'):
154 if m.group(1) == var:
155 titles[var]=m.group(2)
157 Props.setTitles(titles,'file')
164 This class handles all ly2dvi.py output file methods
167 __mudelaDefs(opt) Send title info to output file
170 __init__() Constructor
171 write(str) Write a string to output file
172 start(file) Start the latex file
173 next() Process next output file
174 end() Finish latex file and run latex
188 def __mudelaDefs(this,opt):
190 Write titles to output
192 input: opt Supports header and subheader output
197 titles = Props.get('titles')
198 for key in titles.keys():
199 this.write('%s\\mudela%s{%s}%%\n' % (opt,key,titles[key]))
206 Write str to current output file
208 input: str String to write
218 def start(this,file):
220 Start LaTeX file. Calculates the horizontal and vertical
221 margin using pagewidth, pageheight, linewidth, and textheight.
222 Creates temporary output filename and opens it for write.
223 Sends the LaTeX header information to output. Lastly sends
224 the title information to output.
226 input: file output file name
231 now=time.asctime(time.localtime(time.time()))
232 linewidth = Props.get('linewidth')
233 textheight = Props.get('textheight')
235 if Props.get('orientation') == 'landscape':
236 pagewidth = Props.get('pageheight')
237 pageheight = Props.get('pagewidth')
239 pageheight = Props.get('pageheight')
240 pagewidth = Props.get('pagewidth')
242 horizontalMarginArg = ( (pagewidth - linewidth)/2 )
243 verticalMarginArg = ( (pageheight - textheight)/2 )
247 %% Automatically generated from %s, %s
249 \\documentclass[%s]{article}
252 \\usepackage{geometry}
253 \\usepackage[latin1]{inputenc}
254 %%\\usepackage[T1]{fontenc}
256 %%\\addtolength{\\oddsidemargin}{-1cm}
257 %%\\addtolength{\\topmargin}{-1cm}
258 %%\\setlength{\\textwidth}{%s}
259 %%\\setlength{\\textheight}{%s}
260 \\geometry{width=%spt, left=%spt, height=%spt, top=%spt}
265 """ % ( program_id(), Props.get('filename'), now, Props.get('papersize'),
266 Props.get('language'), Props.get('pagenumber'), linewidth, textheight,
267 linewidth, horizontalMarginArg, textheight, verticalMarginArg,
268 Props.get('header') )
270 base, ext = os.path.splitext(file)
272 tempfile.template= base + '_ly'
273 this.__outfile = tempfile.mktemp(ext)
274 base, ext = os.path.splitext(this.__outfile)
275 this.__tmpbase = base
277 this.__fd = open(this.__outfile,"w")
279 sys.exit('ExitNoWrite', this.__outfile)
281 this.__mudelaDefs('')
291 Write LaTeX subheader information to support more than one
292 score in a document. Lastly send current title information to
304 \\def\\mudelapiece{}%
306 this.__mudelaDefs("\\def")
308 \\def\\theopus{\\mudelaopus}% ugh
309 \\def\\thepiece{\\mudelapiece}%
319 Close output file and run latex on it.
323 error: ExitBadLatex Exception
326 outfile=this.__base + '.dvi'
327 if Props.get('output') != '':
328 outfile = os.path.join(Props.get('output'), outfile )
331 \\vfill\\hfill{\\mudelatagline}
335 if os.path.isfile(outfile):
337 if ( os.name == 'posix' ):
338 stat = os.system('latex \'\\nonstopmode \\input %s\'' %
340 else: # Windows shells don't eat the single quotes
341 stat = os.system('latex \\nonstopmode \\input %s' %
344 sys.exit('ExitBadLatex')
345 if not os.path.isfile(outfile):
346 os.rename(this.__tmpbase + '.dvi', outfile)
348 sys.stderr.write('\n' + program_id() + ': dvi file name is %s\n\n'
351 if Props.get('postscript'):
352 psoutfile=this.__base + '.ps'
353 if Props.get('output') != '':
354 psoutfile = os.path.join(Props.get('output'), psoutfile )
355 stat = os.system('dvips -o %s %s' % (psoutfile,outfile))
357 sys.exit('ExitBadPostscript')
363 # ARG! THIS CODE IS BLOATED:
364 # FIXME: Junk all set/get methods.
368 This class handles all ly2dvi.py property manipulation
372 __init__() Constructor
373 set<property> methods
379 # Following is the order of priority for property assignment. The
380 # list is organized from lowest to highest priority. Each
381 # assignment is overridden by the next requester in the list.
383 # Requester Description
384 # --------- -----------
385 # init Initial default values
386 # file The values found in the lilypond generated TeX files
387 # environment Envrionment variables LILYINCLUDE, LILYPONDPREFIX
388 # rcfile $LILYPONDPREFIX/.lilyrc
389 # rcfile $HOME/.lilyrc
391 # commandline command line arguments
393 this.__overrideTable = {
402 this.__roverrideTable = {} # reverse lookup used for debug
403 for i in this.__overrideTable.items():
404 this.__roverrideTable[i[1]]=i[0]
407 'pagewidth' : [597, this.__overrideTable['init']],
408 'pageheight' : [845, this.__overrideTable['init']],
409 'papersize' : ['a4paper', this.__overrideTable['init']],
410 'textheight' : [0, this.__overrideTable['init']],
411 'linewidth' : [500, this.__overrideTable['init']],
412 'orientation' : ['portrait', this.__overrideTable['init']],
413 'language' : ['%', this.__overrideTable['init']],
414 'include' : [[], this.__overrideTable['init']],
415 'debug' : [0, this.__overrideTable['init']],
416 'keeplilypond' : [0, this.__overrideTable['init']],
417 'keeply2dvi' : [0, this.__overrideTable['init']],
418 'pagenumber' : ['%', this.__overrideTable['init']],
419 'separate' : [0, this.__overrideTable['init']],
420 'output' : ['', this.__overrideTable['init']],
421 'header' : ['%', this.__overrideTable['init']],
422 'dependencies' : [0, this.__overrideTable['init']],
423 'root' : ['', this.__overrideTable['init']],
424 'tmp' : ['d:\tmp', this.__overrideTable['init']],
425 'filename' : ['', this.__overrideTable['init']],
426 'titledefs' : [[], this.__overrideTable['init']],
427 'titles' : [{}, this.__overrideTable['init']],
428 'lilyOutputFiles' : [[], this.__overrideTable['init']],
429 'postscript' : [0, this.__overrideTable['init']],
433 # Try to set root and HOME first before calling rcfile
435 if os.environ.has_key('LILYPONDPREFIX'):
436 this.setRoot(os.environ['LILYPONDPREFIX'], 'environment')
438 p=os.path.split(sys.argv[0])
439 p=os.path.split(p[0])
440 # bit silly. for ly2dvi, overrules compiled-in datadir...
441 # how to do this better (without running lily, of course?
442 this.setRoot(os.path.join(p[0],'share','lilypond'), 'init')
444 if not os.environ.has_key('HOME'):
445 if os.environ.has_key('HOMEDRIVE') and \
446 os.environ.has_key('HOMEPATH'):
447 os.environ['HOME'] = os.environ['HOMEDRIVE'] + \
448 os.environ['HOMEPATH']
450 os.environ['HOME'] = os.curdir
452 this.rcfile() # Read initialization file(s)
454 if os.environ.has_key('LILYINCLUDE'):
455 tmp=this.get('include')
456 for s in string.split(os.environ['LILYINCLUDE'],os.pathsep):
458 this.__set('include', tmp, 'environment')
462 if os.environ.has_key ('TEXINPUTS'):
463 t = os.environ['TEXINPUTS'] + os.pathsep
464 os.environ['TEXINPUTS'] = t + \
465 os.path.join(this.get('root'), 'tex' ) + \
466 os.pathsep + os.path.join(this.get('root'), 'ps' )
469 if os.environ.has_key ('MFINPUTS'):
470 t = os.environ['MFINPUTS']
471 os.environ['MFINPUTS'] = t + os.pathsep + \
472 os.path.join(this.get('root'), 'mf')
474 if os.environ.has_key('TMP'):
475 this.__set('tmp',os.environ['TMP'],'environment')
478 def read_titledefs (this):
479 fd=this.get_texfile_path ('titledefs.tex')
482 for line in fd.readlines():
483 m=re.match('\\\\newcommand\*{\\\\mudela([\w]+)}',line)
485 mudefs.append(m.group(1))
487 this.__set('titledefs', mudefs, 'init')
492 def __set(this,var,value,requester):
494 All of the set methods call this to set a property. If the value
495 was last set by a requestor of lesser priority the new value is
496 assigned, else the old value has priority and is unchanged.
499 if this.__overrideTable[requester] < this.__data[var][1]:
502 this.__data[var] = [value, this.__overrideTable[requester]]
509 All of the get methods call this to get a property value. List
510 variable types are return by value to facilitate an append operation.
513 if var == 'include' or var == 'lilyOutputFiles':
514 return this.__data[var][0][0:] # return a copy not a ref
516 return this.__data[var][0]
521 def get_texfile_path (this, var):
523 locate and open titledefs.tex file
527 path = os.path.join(this.get('root'), 'tex', var)
530 cmd =('kpsewhich tex %s %s' % (var,errorlog))
531 pipe = os.popen (cmd, 'r')
532 path = pipe.readline ()[:-1] # chop off \n
533 return_status = pipe.close()
534 if return_status and not path:
535 path = os.path.join(this.get('root'), 'tex', var)
545 Read initialization file(s)
550 ( 'DEBUG', this.setDebug ),
551 ( 'DEPENDENCIES', this.setDependencies ),
552 ( 'KEEPLILYPOND', this.setKeeplilypond ),
553 ( 'KEEPLY2DVI', this.setKeeply2dvi ),
554 ( 'LANGUAGE', this.setLanguage ),
555 ( 'LATEXHF', this.setHeader ),
556 ( 'LILYINCLUDE', this.setInclude ),
557 ( 'LILYPONDPREFIX', this.setRoot ),
558 ( 'NONUMBER', this.setNonumber ),
559 ( 'ORIENTATION', this.setOrientation ),
560 ( 'OUTPUTDIR', this.setOutput ),
561 ( 'PAPERSIZE', this.setPaperZize ),
562 ( 'PHEIGHT', this.setTextHeight ),
563 ( 'POSTSCRIPT', this.setPostscript ),
564 ( 'PWIDTH', this.setLineWidth ),
565 ( 'SEPARATE', this.setSeparate ),
566 ( 'TMP', this.setTmp ),
569 if ( os.name == 'posix' ):
570 dotFilename='.lilyrc'
571 else: # Windows apps like edit choke on .lilyrc
572 dotFilename='_lilyrc'
574 for d in [os.path.join(this.get('root'),'ly'), \
575 os.environ['HOME'], os.curdir ]:
576 file=os.path.join(d,dotFilename)
578 fd = open( file, 'r' )
582 for line in fd.readlines():
583 if re.match('#.*',line):
585 m=re.search('([\w]+)=(.*)',line)
588 if m.group(1) == var[0]:
589 var[1](m.group(2),'rcfile')
596 def setPaperZize(this,size,requester):
598 Set paper size properties
602 # regex width height name
603 # ----- ----- ------ ----
604 ( 'a0.*', 2389, 3381, 'a0paper' ),
605 ( 'a1$|a1p.*', 1690, 2389, 'a1paper' ),
606 ( 'a2.*', 1194, 1690, 'a2paper' ),
607 ( 'a3.*', 845, 1194, 'a3paper' ),
608 ( 'a4.*', 597, 845, 'a4paper' ),
609 ( 'a5.*', 423, 597, 'a5paper' ),
610 ( 'a6.*', 298, 423, 'a6paper' ),
611 ( 'a7.*', 211, 298, 'a7paper' ),
612 ( 'a8.*', 305, 211, 'a8paper' ),
613 ( 'a9.*', 105, 305, 'a9paper' ),
614 ( 'a10.*', 74, 105, 'a10paper' ),
615 ( 'b0.*', 2847, 4023, 'b0paper' ),
616 ( 'b1.*', 2012, 2847, 'b1paper' ),
617 ( 'b2.*', 1423, 2012, 'b2paper' ),
618 ( 'b3.*', 1006, 1423, 'b3paper' ),
619 ( 'b4.*', 712, 1006, 'b4paper' ),
620 ( 'b5.*', 503, 712, 'b5paper' ),
621 ( 'archA$', 650, 867, 'archApaper' ),
622 ( 'archB$', 867, 1301, 'archBpaper' ),
623 ( 'archC$', 1301, 1734, 'archCpaper' ),
624 ( 'archD$', 1734, 2602, 'archDpaper' ),
625 ( 'archE$', 2602, 3469, 'archEpaper' ),
626 ( 'flsa$|flse$', 614, 940, 'flsapaper' ),
627 ( 'halfletter$', 397, 614, 'halfletterpaper' ),
628 ( 'ledger$', 1229, 795, 'ledgerpaper' ),
629 ( 'legal$', 614, 1012, 'legalpaper' ),
630 ( 'letter$', 614, 795, 'letterpaper' ),
631 ( 'note$', 542, 723, 'notepaper' )
635 for paper in paperTable:
636 if re.match(paper[0],size):
638 this.__set('pagewidth',paper[1],requester)
639 this.__set('pageheight',paper[2],requester)
640 this.__set('papersize',paper[3],requester)
644 sys.exit('ExitBadPaper',size)
649 def setTextHeight(this,size,requester):
651 Set textheight property
654 m=re.match('([0-9][.0-9]*)(cm|mm|pt|$)',size)
656 if m.group(2) == 'cm':
657 this.__set('textheight',\
658 float(m.group(1)) * 72.27/2.54, requester )
659 elif m.group(2) == 'mm':
660 this.__set('textheight',\
661 float(m.group(1)) * 72.27/25.4, requester )
662 elif m.group(2) == 'pt':
663 this.__set('textheight', float(m.group(1)), requester )
664 elif m.group(2) == '':
665 this.__set('textheight', float(m.group(1)), requester )
667 sys.exit('ExitBadHeight', m.group(2))
669 sys.exit('ExitBadHeight', size)
674 def setLineWidth(this,size,requester):
676 Set linewidth propery
679 m=re.match('([0-9][.0-9]*)(cm|mm|pt|$)',size)
681 if m.group(2) == 'cm':
682 this.__set('linewidth', \
683 float(m.group(1)) * 72.27/2.54, requester )
684 elif m.group(2) == 'mm':
685 this.__set('linewidth', \
686 float(m.group(1)) * 72.27/25.4, requester )
687 elif m.group(2) == 'pt':
688 this.__set('linewidth', float(m.group(1)), requester )
689 elif m.group(2) == '':
690 this.__set('linewidth', float(m.group(1)), requester )
692 sys.exit('ExitBadWidth', m.group(2))
694 sys.stderr.write ('ly2dvi: warning: ignoring linewidth: ' + size + '\n')
699 def setOrientation(this,orient,requester):
701 Set orientation property
704 if orient == 'landscape' or orient == 'portrait':
705 this.__set('orientation', orient, requester )
707 sys.exit('ExitBadOrient', orient)
712 def setLanguage(this,lang,requester):
714 Set language property
717 this.__set('language', '\\usepackage[%s]{babel}' % (lang), requester )
722 def setInclude(this,inc, requester):
724 Append an include path
727 tmp = this.get('include')
729 this.__set('include', tmp, requester )
734 def setDebug(this,value,requester):
736 Set or Clear debug flag
740 this.__set('debug',1,requester)
742 this.__set('debug',0,requester)
747 def setKeeplilypond(this, value, requester):
749 Set or Clear keeplilypond flag
753 this.__set('keeplilypond',1,requester)
755 this.__set('keeplilypond',0,requester)
760 def setKeeply2dvi(this, value, requester):
762 Set or Clear keeply2dvi flag
766 this.__set('keeply2dvi',1,requester)
768 this.__set('keeply2dvi',0,requester)
773 def setNonumber(this, value, requester):
779 this.__set('pagenumber','\\pagestyle{empty}',requester)
781 this.__set('pagenumber','%',requester)
786 def setSeparate(this, value, requester):
788 Set or Clear separate flag
792 this.__set('separate',1,requester)
794 this.__set('separate',0,requester)
797 # Set output directory name
799 def setOutput(this,out,requester):
800 this.__set('output',out,requester)
803 # Set latex header name
805 def setHeader(this,head, requester):
806 this.__set('header',head,requester)
809 # Set or Clear Dependencies flag to generate makefile dependencies
811 def setDependencies(this, value, requester):
813 Set or Clear dependencies flag
817 this.__set('dependencies',1,requester)
819 this.__set('dependencies',0,requester)
824 def setTmp(this,dir, requester):
825 this.__set('tmp',dir,requester)
828 # Set mudela source file name
830 def setFilename(this,file, requester):
831 this.__set('filename',file,requester)
836 def setTitles(this,titles, requester):
837 this.__set('titles',titles,requester)
842 def addLilyOutputFiles(this,filelist,requester):
844 Add a to the lily output list
847 tmp = this.get('lilyOutputFiles')
849 this.__set('lilyOutputFiles',tmp,requester)
852 # Set/Clear postscript flag
854 def setPostscript(this,value,requester):
860 this.__set('postscript',1,requester)
862 this.__set('postscript',0,requester)
867 def setRoot(this,path, requester):
869 Set lilypond root directory
872 os.environ['LILYPONDPREFIX'] = path
873 if os.name == 'nt' or os.name == 'dos':
874 path = unc2dos(path);
876 this.__set('root',path,requester)
882 def printProps(this):
887 for key in this.__data.keys():
888 print "%s <%s>:<%s>" % (key,this.get(key),
889 this.__roverrideTable[this.__data[key][1]])
899 if len(Props.get('include')) > 0:
900 inc = string.join (map (lambda x: '-I "%s"' % x, Props.get('include')))
903 if Props.get('dependencies'):
910 def writeLilylog(file,contents):
911 if Props.get('keeplilypond'):
912 base, ext = os.path.splitext(file)
913 tempfile.template=base + "_li"
914 file=tempfile.mktemp('.log')
915 output = Props.get('output')
917 file = os.path.join( output, file )
919 fd = open( file, 'w' )
921 sys.exit('ExitNoWrite', file)
925 def getTeXFile(contents):
927 for line in string.split(contents,'\n'):
928 m = re.search('^paper output to (.+)\.\.\.', line)
930 texfiles.append(m.group(1))
933 sys.exit('ExitNoTeXName')
939 Convert a path of format //<drive>/this/that/the/other to
940 <drive>:\this\that\the\other
942 m=re.match('^//([A-Za-z])(/.*)$',path)
944 return m.group(1) + ':' + os.path.normpath(m.group(2))
949 return 'ly2dvi (GNU lilypond) ' + version;
954 return os.environ['MAILADDRESS']
956 return '(address unknown)'
960 sys.stderr.write (program_id () + '\n')
962 def print_version ():
963 sys.stdout.write (program_id () + '\n')
967 """Usage: %s [OPTION]... [FILE]...
969 Generate dvi file from mudela or lilypond output
972 -D,--debug increase verbosity
973 -F,--headers= name of additional LaTeX headers file
974 -H,--Height= set paper height (points) (see manual page)
975 -I,--include=DIR add DIR to LilyPond\'s search path
976 -K,--keeplilypond keep lilypond output files
977 -L,--landscape set landscape orientation
978 -N,--nonumber switch off page numbering
979 -O,--orientation= set orientation (obsolete - use -L instead)
980 -P,--postscript generate postscript file
981 -W,--Width= set paper width (points) (see manual page)
982 -M,--dependencies tell lilypond make a dependencies file
983 -h,--help this help text
984 -k,--keeply2dvi keep ly2dvi output files
985 -l,--language= give LaTeX language (babel)
986 -o,--output= set output directory
987 -p,--papersize= give LaTeX papersize (eg. a4)
988 -s,--separate run all files separately through LaTeX
990 files may be (a mix of) input to or output from lilypond(1)
1000 """Generate dvi files from lilypond source/output"""
1003 outfile = TeXOutput()
1007 (options, files) = getopt.getopt (sys.argv[1:],
1008 'DF:H:I:KLNPW:Mhkl:o:p:s',
1009 ['debug', 'headers=', 'Height=',
1010 'include=', 'keeplilypond', 'landscape',
1011 'nonumber', 'Width=', 'dependencies',
1012 'help', 'keeply2dvi', 'language=',
1013 'output=', 'version', 'papersize=', 'separate',
1018 if o == '--debug' or o == '-D':
1019 Props.setDebug(1,'commandline')
1020 elif o == '--headers' or o == '-F':
1021 Props.setHeader(a,'commandline')
1022 elif o == '--include' or o == '-I':
1023 Props.setInclude(a,'commandline')
1024 elif o == '--Height' or o == '-H':
1025 Props.setTextHeight(a,'commandline')
1026 elif o == '--keeplilypond' or o == '-K':
1027 Props.setKeeplilypond(1,'commandline')
1028 elif o == '--landscape' or o == '-L':
1029 Props.setOrientation('landscape','commandline')
1030 elif o == '--nonumber' or o == '-N':
1031 Props.setNonumber(1,'commandline')
1032 elif o == '--Width' or o == '-W':
1033 Props.setLineWidth(a,'commandline')
1034 elif o == '--dependencies' or o == '-M':
1035 Props.setDependencies(1,'commandline')
1036 elif o == '--help' or o == '-h':
1039 elif o == '--keeply2dvi' or o == '-k':
1040 Props.setKeeply2dvi(1,'commandline')
1041 elif o == '--language' or o == '-l':
1042 Props.setLanguage(a,'commandline')
1043 elif o == '--output' or o == '-o':
1044 Props.setOutput(a,'commandline')
1045 elif o == '--papersize' or o == '-p':
1046 Props.setPaperZize(a,'commandline')
1047 elif o == '--separate' or o == '-s':
1048 Props.setSeparate(1,'commandline')
1049 elif o == '--postscript' or o == '-P':
1050 Props.setPostscript(1,'commandline')
1051 elif o == '--version':
1056 Props.read_titledefs ()
1061 type = infile.type()
1063 if type == 'source':
1064 if os.environ.has_key('OS') and \
1065 os.environ['OS'] == 'Windows_95':
1066 cmd = 'ash -c "lilypond %s %s 2>&1"' %(getLilyopts(), file)
1068 cmd = 'lilypond %s %s 2>&1' % (getLilyopts(), file)
1069 sys.stderr.write ('executing: %s\n'% cmd)
1071 fd = os.popen(cmd , 'r')
1076 sys.stderr.write (s)
1083 sys.stderr.write (s)
1089 sys.exit('ExitBadLily', cmd )
1090 texFiles=getTeXFile(log)
1091 writeLilylog(file,log)
1092 Props.addLilyOutputFiles(texFiles,'program')
1093 texInputFiles = texInputFiles + texFiles
1095 texInputFiles.append(file)
1098 for file in texInputFiles:
1100 infile.setVars() # first pass set variables
1102 if Props.get('debug'):
1105 outfile.start(file) # allow for specified name
1111 if Props.get('separate'):
1115 if not Props.get('separate'):
1119 sys.exit('ExitBadArgs','No files specified')
1125 'ExitInterupt' : ['Ouch!', 1 ],
1126 'ExitBadArgs' : ['Wrong number of arguments', 2 ],
1127 'ExitNotFound' : ['File not found', 3 ],
1128 'ExitBadPaper' : ['Unknown papersize', 4 ],
1129 'ExitBadHeight' : ['Invalid Height specification', 5 ],
1130 'ExitBadWidth' : ['Invalid Width specification', 6 ],
1131 'ExitBadOrient' : ['Invalid Orientation specification', 7 ],
1132 'ExitNoWrite' : ['Permission denied', 8 ],
1133 'ExitNoTeXName' : ['hmm, I could not find an output file name', 9 ],
1134 'ExitBadLily' : ['Lilypond failed', 10 ],
1135 'ExitBadLatex' : ['Latex failed', 11 ],
1136 'ExitBadPostscript' : ['Postscript failed', 12 ],
1137 'ExitUnknown' : ['Unknown Exit Code', 20 ],
1143 if not Props.get('keeplilypond'):
1144 lilyfiles = Props.get('lilyOutputFiles')
1145 if not Props.get('keeply2dvi'):
1146 tmpfiles = glob.glob('*_ly[0-9]*.*')
1147 for file in lilyfiles + tmpfiles:
1148 if os.path.isfile(file):
1152 Props = Properties()
1157 except KeyboardInterrupt:
1158 print ExitTable['ExitInterupt'][0]
1160 sys.exit(ExitTable['ExitInterupt'][1])
1162 except SystemExit, errno:
1163 if ExitTable.has_key(errno.args[0]):
1164 msg = ExitTable[errno.args[0]]
1166 msg = ExitTable['ExitUnknown']
1167 if len(errno.args) > 1:
1168 sys.stderr.write( '%s: %s: %s\n' % (name, msg[0], errno.args[1]))
1170 sys.stderr.write( '%s %s\n' % (name, msg[0]))
1171 if Props.get('debug'):