Han-Wen Nienhuys writes:
|[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; 

I look at it as a matter of perspective.  On one hand using tight
loops and method references is hard to read at a glance.  On the other
hand, once the algorithm is understood, it is significantly easier to
enhance.  So I gave up some readability for flexibility.  We certainly
could use so code comments.  That might help a bit.

|and you take an enormous effort to copy in stead of sharing objects.  

I don't understand this point.

|>             ( 'papertextheight', Props.setTextHeight ),
|
|do we have a var named like this ? (ugh)
|

I most likely trashed several proper names.  Please suggest more
appropriate ones.

|> 
|>         titles={}
|>         line='prime the pump' # ugh
|
|try
|
|for line in file.readlines ():
|

_excellent_!!!

|> 
|>     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
|

Ah, I little bit of perl in there I see.

|>             
|>     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]
|>         
|
|I probably wouldn't use your requester field, and let the order of the
|assignments specify overriding semantics.
|

I am anticipating a discussion on the initialization precedence.
Lilypond ships with only a4.ly.  So it is convenient for me to set a
global or local rcfile variable for papersize.  Otherwise I have to
continually use the -p option to override the lily generated tex file.
With the overrideTable approach I have once again sacrificed
readability for versatility.  Besides on person's baroque is another
person's paint by numbers. :7)

|>     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
|

Could you elaborate on this.  

|
|> def getTeXFile(contents):
|>     m = re.search('^TeX output to (.+)\.tex', contents,re.M)
|
|tricky: the .tex suffix can also be overriden
|

I'll look into that.

|>     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.

I agree, that shouldn't be difficult.

|I hacked a bit to make it work on unix, results attached.  Could you
|use tabs (indent 8) for editing?

I am flexible, but we may experience excessive line wrapping.  I will
however adhere to any standard you think is reasonable.

|More remarks:
|
|* requester is way too baroque

To reiterate this allows us to settle in on a initialization
precedence without having to do major flow changes.  The way the flow
is presently rcfile, getopt, texfile so you can not simply override as
you go.  The same code in ly2dvi.sh is very hard to read, because you
want to override the texfile settings with the command line switches,
but the switches are read first.  I actually was trying to improve the
approach, but apparently I failed miserably.

|* There is no need for
|
|       try:
|               ..
|       except:
|               error ()
|
|without the try/except the error will be signaled anyway.
|
|* while (cond):
|
|should be
|
|       while cond:
|
|the same for if cond:

Okay I understand, thanks.

Jeff

-- 
Jeffrey B. Reed
[EMAIL PROTECTED]

Reply via email to