Page MenuHomePhabricator

Pywikibot-redirect ignoring -namespace
Closed, ResolvedPublicFeature

Description

I ran this command to fix redirects only on File namespace

python pwb.py redirect double -namespace:6

but it ignored the -namespace:6 part and simply processed all pages in Special:DoubleRedirect.

I'm using Python 3.7.3, pywikibot up to date with https://gerrit.wikimedia.org/r/pywikibot/core.git (commit 23dcbe6b)

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript

The namespace filtering is not determined for cross-namespaces i.e. the namespace of the source page is different from the namespaces in the target chain. Should -namespace option filter the source page or target page or the page(s) to be changed?

Xqt triaged this task as Low priority.Oct 4 2019, 12:57 PM
Xqt changed the subtype of this task from "Task" to "Feature Request".Oct 4 2019, 6:40 PM
Aklapper added a subscriber: Dvorapa.

@Dvorapa: good first task tasks are self-contained, non-controversial issues with a clear approach and should be well-described with pointers to help a completely new contributor. Given the current short task description and Xqt's open question I'm removing the good first task tag. Please add details what exactly has to happen where and how for a new contributor and then add back the good first task project tag. Thanks a lot in advance.

@Xqt -namespace should always filter the source. This behavior is default in 100 % of scripts and should not be interrupted.

@Aklapper The goal is easy. Add a support for namespace filter from pagegenerators.py into redirect.py. I am ready to explain the goal more deeply to any novice who would ask in this task.

@Xqt -namespace should always filter the source. This behavior is default in 100 % of scripts and should not be interrupted.

Normally no script follow the redirect chain like redirect.py does and -namespace option can be seen from writing point of view (and I would prefer that). That will follow your intention but also cares the namespace for all pages following that chain if they has to be updated. The goal is to check the namespace of the page to be changed.

Parameter for the page to be changed should be done using a different parameter (-targetns), not -ns used for filtering the source code. The description seems to talk about the generator filter

Parameter for the page to be changed should be done using a different parameter (-targetns), not -ns used for filtering the source code. The description seems to talk about the generator filter

Redirect target is not the same as the page to be changed.

Yeah, but you got my point: -ns reserved to generator filder, -targetns -changens -whateverns to the others. The task description talks about the generator filter clearly

Sorry for the late response: what I (as a user) was expecting from -ns:6 was to filter source pages by ns, then fix them.
However I never thought that source and destination ns may be different (because I expect a redirect from the file namespace to point to an actual file, so again to the file ns), but in the end I would expect it to filter the source.

Hello @Dvorapa I am new here. Can I work on this? Though I do not fully understand the problem yet.

Hello @HAKSOAT! Yes, you can work on this. The issue is that many Pywikibot scripts understand -ns or -namespace parameter and work only on pages using that namespace specified. This script does not understand that parameter. The task is to add missing namespace support into the script. It should be pretty straightforward as this has been implemented in many scripts before. Feel free to ask more questions!

You can choose to implement either -namespace/-ns (source page), or -finalns/-editns (page to be edited), or -targetns (redirect target). Or more of these. Any of these would be helpful I guess.

Thanks @Dvorapa I've spent some time first checking another script, then the redirect script. I see that the script has the ability to pass namespaces to RedirectGenerator. But the value is not being extracted from the arguments as expected. So I'm to get it to extract and pass to RedirectGenerator. Am I thinking in the right direction?

Yes, this should be the way :)

This comment was removed by HAKSOAT.

@Dvorapa I realized that the argument for namespace doesn't even send to redirect. I made use of the example python pwb.py redirect double -namespace:6

Change 654412 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] use pagegenerators namespace filter for redirect.py

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

Change 654412 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] use pagegenerators namespace filter for redirect.py

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