In line 91 of the diff, you can replace v[0] by a randomized choice function:

    repl = lambda m: random.choice(v)
    s = re.sub(k, repl, s, flags=re.IGNORECASE)

And you may optimize it by:
 - pre-compiling regular expressions in the dictionary
 - replacing lists in translations by the function above

REPL = dict([(re.compile(k), lambda m: random.choice(v) if isinstance(v, list) 
else v) for k, v in REPL.iteritems()])

Raphael ;-)

-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-lolcat/+merge/113264
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-server/trunk-lolcat.

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to