lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rewrote convertrules.py with a decorator


From: Wilbert Berendsen
Subject: rewrote convertrules.py with a decorator
Date: Fri, 20 Jun 2008 14:59:12 +0200
User-agent: KMail/1.9.9

Hi,

just for fun I rewrote convertrules.py (of current git) so that it uses a 
simple decorator function. Instead of the double procedure (function, and 
then calling conversions.append()) :

def conv(str)
    # manipulate str
    return str

conversions.append((version, conv, message))

you can now simply write:

@rule (version, message)
def conv(str)
    # manipulate str
    return str

This makes more clear what parameters belong to the conversion function, and 
you do not need to type the conversions.append(( )) command each time.

The decorator function does simply the conversions.append() so nothing changes 
otherwise. The conversions list with the convertrules is just the same as 
before. I fixed a few missing slashes in non-raw strings as well. No 
translatable strings have been changed.

I verified (by diffing the output of repr() on both lists) that the 
conversions list is the same as in the old situation.

Maybe this patch makes convertrules.py more readable and even more 
maintainable!

best regards,
Wilbert Berendsen

-- 
LilyKDE, LilyPond for KDE: http://lilykde.googlecode.com/

Attachment: convertrules-decorator.patch.gz
Description: GNU Zip compressed data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]