Hi everyone. When trying to use a version of replace.py I get this error:
Traceback (most recent call last): File "pande_replace.py", line 742, in <module> main() File "pande_replace.py", line 725, in main gen = genFactory.getCombinedGenerator(gen) TypeError: getCombinedGenerator() takes exactly 1 argument (2 given) Exception exceptions.TypeError: "'NoneType' object is not callable" in <bound method SharedSocket.__del__ of <httplib.SharedSocket instance at 0x1a45200>> ignored
Line 725 is:
query = u""" SELECT page_namespace, page_title FROM page JOIN text ON (page_id = old_id) %s %s LIMIT 200""" % (whereClause, exceptClause) gen = pagegenerators.MySQLPageGenerator(query) elif PageTitles: pages = [pywikibot.Page(pywikibot.getSite(), PageTitle) for PageTitle in PageTitles] gen = iter(pages)
gen = genFactory.getCombinedGenerator(gen)
running parameters for script are:
python pande_replace.py -fix:comunes -start:! -always
I'm using latest revision from SVN.
Any ideas?
Matias wrote:
Hi everyone. When trying to use a version of replace.py I get this error:
Traceback (most recent call last): File "pande_replace.py", line 742, in <module> main() File "pande_replace.py", line 725, in main gen = genFactory.getCombinedGenerator(gen) TypeError: getCombinedGenerator() takes exactly 1 argument (2 given)
Line 725 is:
query = u"""
SELECT page_namespace, page_title FROM page JOIN text ON (page_id = old_id) %s %s LIMIT 200""" % (whereClause, exceptClause) gen = pagegenerators.MySQLPageGenerator(query) elif PageTitles: pages = [pywikibot.Page(pywikibot.getSite(), PageTitle) for PageTitle in PageTitles] gen = iter(pages)
gen = genFactory.getCombinedGenerator(gen)
You're not using genFactory correctly here; genFactory can only return a generator based on the standard command-line arguments, but it looks like you are trying to define your own generator from a MySQL query. Without seeing the rest of your program it's hard to tell, but maybe you should just eliminate the references to genFactory entirely.
If you do use a generator factory, the correct method call is "gen = genFactory.getCombinedGenerator()" without any argument(s).
Russ
On Thu, Sep 24, 2009 at 6:39 PM, Russell Blau russblau@imapmail.org wrote:
You're not using genFactory correctly here; genFactory can only return a generator based on the standard command-line arguments, but it looks like you are trying to define your own generator from a MySQL query. Without seeing the rest of your program it's hard to tell, but maybe you should just eliminate the references to genFactory entirely.
If you do use a generator factory, the correct method call is "gen = genFactory.getCombinedGenerator()" without any argument(s).
The script i'm using is replace.py. I didn't made any modifications to that part (only template validations for skipping the page at all if present). That part is entirely untouched.
Thanks for the fast response.
Matias wrote:
On Thu, Sep 24, 2009 at 6:39 PM, Russell Blau russblau@imapmail.org wrote:
If you do use a generator factory, the correct method call is "gen = genFactory.getCombinedGenerator()" without any argument(s).
The script i'm using is replace.py. I didn't made any modifications to that part (only template validations for skipping the page at all if present). That part is entirely untouched.
Actually, that's not quite true. The relevant loop in the current revision of rewrite/scripts/replace.py is as follows:
# Read commandline parameters. for arg in pywikibot.handleArgs(*args): if genFactory.handleArg(arg): continue if arg == '-regex': regex = True # ... many elif: clauses omitted else: commandline_replacements.append(arg)
gen = genFactory.getCombinedGenerator()
The code snippet included in your original posting was significantly different, and the last line read gen = genFactory.getCombinedGenerator(gen).
Russ
On Fri, Sep 25, 2009 at 11:50 AM, Russell Blau russblau@imapmail.orgwrote:
Actually, that's not quite true. The relevant loop in the current revision of rewrite/scripts/replace.py is as follows:
# Read commandline parameters. for arg in pywikibot.handleArgs(*args): if genFactory.handleArg(arg): continue if arg == '-regex': regex = True # ... many elif: clauses omitted else: commandline_replacements.append(arg)
gen = genFactory.getCombinedGenerator()
The code snippet included in your original posting was significantly different, and the last line read gen = genFactory.getCombinedGenerator(gen).
You are right, I messed the revisions in this particular file. Sorry about that and thanks for your time.