[EMAIL PROTECTED] writes:
> A rough draft of ly2dvi32.py is enclosed.
>
Gosh, it looks more like a final version than a draft.
> Please be candid with your comments, for I am new to Python.
yup. It's a bit baroque in some places; and you take an enormous
effort to copy in stead of sharing objects. It would make the source
more readable if you didn't
> # ------ ----------
> ( 'language', Props.setLanguage ),
> ( 'latexheaders', Props.setHeader ),
> ( 'orientation', Props.setOrientation ),
> ( 'paperpapersize', Props.setPaperZize ),
do we have a var named like this ? (ugh)
> ( 'papertextheight', Props.setTextHeight ),
> ( 'paperlinewidth', Props.setLineWidth ),
> ( 'filename', Props.setFilename ),
> ]
>
> titles={}
> line='prime the pump' # ugh
try
for line in file.readlines ():
>
> def start(this,file):
> """Start the latex file"""
> now=time.asctime(time.localtime(time.time()))
> linewidth = Props.get('linewidth')
> textheight = Props.get('textheight')
>
> if ( Props.get('orientation') == 'landscape' ):
> pagewidth = Props.get('pageheight')
> pageheight = Props.get('pagewidth')
> else:
> pageheight = Props.get('pageheight')
> pagewidth = Props.get('pagewidth')
>
(w,h) = (Props.get (), Props.get))
if orientation:
w,h = h,w
>
> def __set(this,var,value,requester):
> if ( this.__overrideTable[requester] < this.__data[var][1] ):
> return 0
> else:
> this.__data[var] = [value, this.__overrideTable[requester]]
>
> def get(this,var):
> if ( var == 'include' or var == 'lilyOutputFiles' ):
> return this.__data[var][0][0:] # return a copy not a ref
> else:
> return this.__data[var][0]
>
> def __init__(this):
> this.__overrideTable = {
> 'init' : 0,
> 'environment' : 1,
> 'rcfile' : 2,
> 'file' : 3,
> 'commandline' : 4,
> 'program' : 5
> }
>
> this.__roverrideTable = {} # reverse lookup
> for i in this.__overrideTable.items():
> this.__roverrideTable[i[1]]=i[0]
>
> this.__data = {
> 'pagewidth' : [597, this.__overrideTable['init']],
(597, this.__overrideTable[]) ?
> 'root' : ['', this.__overrideTable['init']],
> 'tmp' : ['d:\tmp', this.__overrideTable['init']],
> 'filename' : ['', this.__overrideTable['init']],
> 'titledefs' : [[], this.__overrideTable['init']],
> 'titles' : [{}, this.__overrideTable['init']],
> 'lilyOutputFiles' : [[], this.__overrideTable['init']],
> }
>
> if( os.environ.has_key('LILYINCLUDE') ):
> tmp=this.get('include')
> for s in string.split(os.environ['LILYINCLUDE'],os.pathsep):
> tmp.append(s)
tmp = tmp + string.split ( )
> def setTmp(this,dir, requester):
> this.__set('tmp',dir,requester)
I probably wouldn't use your requester field, and let the order of the
assignments specify overriding semantics.
> if( len(Props.get('include')) > 0 ):
> inc = '-I ' + string.join(Props.get('include'),os.pathsep)
> else:
> inc = ''
> if ( Props.get('dependencies') ):
> dep=' -d'
> else:
> dep=''
> return inc + dep
It would be cool if ly2dvi would read the generated .dep file and
change .tex to .dvi
> def getTeXFile(contents):
> m = re.search('^TeX output to (.+)\.tex', contents,re.M)
tricky: the .tex suffix can also be overriden
> if( len(files) ):
> for file in files:
> infile.open(file)
> type = infile.type()
> infile.close()
> if ( type == 'source' ):
> cmd = 'lilypond %s %s 2>&1' % (getLilyopts(), file)
> fd = os.popen( cmd , 'r' )
> log = fd.read()
> stat = fd.close()
> print log
> if( stat ):
> sys.exit('ExitBadLily', cmd )
It would be nice to have more detailed info. For instance: a core
dump of LilyPond should be signaled to the user explicitly.
--
Han-Wen Nienhuys, [EMAIL PROTECTED] ** GNU LilyPond - The Music Typesetter
http://www.cs.uu.nl/people/hanwen/lilypond/index.html