Okay, This code works for me.
#------- user-fixes.py ------- import re
def homophix(match): return re.sub(r'({{homophones|)([^}=]*}})', r'\1lang={{subst:langrev|'+match.group(1)+r'}}|\2', match.group(0) )
fixes['homophones'] = { 'regex': True, 'msg': {'_default':u'add lang to homophones'}, 'replacements': [ (r'(?m)^== *([^\n]+) *== *((?!==(?!=))[^\n]*\n)*', homophix) ] } #--------------
See http://en.wiktionary.org/w/index.php?title=Wiktionary%3ASandbox&diff=203... its edit.
On Fri, May 3, 2013 at 4:02 AM, Michael Hamm msh210@gmail.com wrote:
Several hours ago, I wrote, in part:
the following user-fixes.py :
def homophix(match): return re.sub(r'({{homophones|)([^}=]*}})',
r'\1lang={{subst:langrev|'+re.escape(match.group(1))+r'}}|\2',
match.group(0) )
fixes['homophones'] = { 'regex': True, 'msg': {'_default':u'add lang to homophones'}, 'replacements': [ (ur'^==([a-zA-Z ]+)==\n+(?:(?:===|[^=]).*\n+)*', homophix) ] }
...which I then tried to call using python replace.py -fix:homophones -page:accapare
(Note that [[wikt:en:accapare]] has {{homophones|...}} without = .)
Python told me: No changes were necessary in [[accapare]] 0 pages were changed.
So I guess it's either not matching or not replacing.
What am I doing wrong?
And what can I do instead?
I've taken the advice I've gotten on-list, but the script still doesn't work. I'd appreciate any further ideas.
Thanks,
Michael Hamm
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l