Page MenuHomePhabricator

Pagegenerator does not use the specified site for categories
Closed, ResolvedPublic

Description

Not using the specified site:

>>> import pywikibot
>>> from pywikibot import pagegenerators
>>> generatorFactory = pagegenerators.GeneratorFactory(pywikibot.Site('commons', 'commons'))
>>> print('Default site is %s' % pywikibot.Site())
Default site is wikipedia:test
>>> print('generatorFactory.site is %s' % generatorFactory.site)
generatorFactory.site is commons:commons
>>> generatorFactory.handleArg('-cat:User en')
True
>>> gen = generatorFactory.getCombinedGenerator()
>>> print(len(list(gen)))
69
>>> # This is from wikipedia:test, instead of commons:commons.

Using the specified site:

>>> import pywikibot
>>> from pywikibot import pagegenerators
>>> generatorFactory = pagegenerators.GeneratorFactory(pywikibot.Site('commons', 'commons'))
>>> print('Default site is %s' % pywikibot.Site())
Default site is wikipedia:test
>>> print('generatorFactory.site is %s' % generatorFactory.site)
generatorFactory.site is commons:commons
>>> generatorFactory.handleArg('-prefixindex:File:BSicon_')
True
>>> gen = generatorFactory.getCombinedGenerator()
>>> print(len(list(gen)))
32993
>>> # This is from commons:commons.

Version:

Pywikibot: [https] r-pywikibot-core.git (ef42bb1, g1, 2017/01/15, 16:38:36, n/a)
Release version: 3.0-dev
requests version: 2.2.1
  cacerts: /etc/ssl/certs/ca-certificates.crt
    certificate test: ok
Python: 3.4.0 (default, Jun 19 2015, 14:20:21)
[GCC 4.8.2]

Event Timeline

Change 332939 had a related patch set uploaded (by Zhuyifei1999):
GeneratorFactory: make getCategory respect self.site

https://gerrit.wikimedia.org/r/332939

Testing with the patch:

>>> import pywikibot
>>> from pywikibot import pagegenerators
>>> generatorFactory = pagegenerators.GeneratorFactory(pywikibot.Site('commons', 'commons'))
>>> print('Default site is %s' % pywikibot.Site())
Default site is wikipedia:test
>>> print('generatorFactory.site is %s' % generatorFactory.site)
generatorFactory.site is commons:commons
>>> generatorFactory.handleArg('-cat:User en')
True
>>> gen = generatorFactory.getCombinedGenerator()
>>> print(len(list(gen)))
20739

Testing with the patch

Looks good. Thanks.

Change 333216 had a related patch set uploaded (by Dalba):
pagegenerators_tests.py: Test that getCategory returns the correct site

https://gerrit.wikimedia.org/r/333216

Change 332939 merged by jenkins-bot:
GeneratorFactory: make getCategory respect self.site

https://gerrit.wikimedia.org/r/332939

Change 333216 merged by jenkins-bot:
pagegenerators_tests.py: Test that getCategory returns the correct site

https://gerrit.wikimedia.org/r/333216