Page MenuHomePhabricator

listify to file option in category.py
Open, LowPublic

Description

Originally from: http://sourceforge.net/p/pywikipediabot/feature-requests/146/
Reported by: Anonymous user
Created on: 2008-05-15 02:27:02
Subject: listify to file option in category.py
Original description:
Please add an option to listify to file rather than a wikipedia article.


Version: unspecified
Severity: enhancement
See Also:
https://sourceforge.net/p/pywikipediabot/feature-requests/146

Details

Reference
bz55102

Event Timeline

bzimport raised the priority of this task from to Low.
bzimport set Reference to bz55102.
bzimport added a subscriber: Unknown Object (????).
Legoktm created this task.Oct 5 2013, 4:23 AM

....Any updates on this? :-\)

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 7 2015, 6:34 AM
Mpaa added a subscriber: Mpaa.Oct 7 2015, 8:46 PM

If the only purpose is to list pages in a file, I would enhance listpages.py to add this capability, rather than category.py.

@jayvdb already suggested to make CategoryListifyRobot obsolete by the listpages script. And in theory you could also pipe the result simply I guess?

Hello Mpaa,
Would it be okay, if I try to add the aforementioned capability, into listpages.py? It will be my first fix, (if I am able to do it).

Mpaa added a comment.Oct 8 2015, 8:06 PM

Yepp, no need to ask for permission ...

Hello all,
I have got a class similar to CategoryListifyRobot working in listpages.py when invoked with argument '-listify'. What should I do next? Please guide me.

Change 245471 had a related patch set uploaded (by Tokencolour):
Bug Fix(#T57102) - listify to file option in category.py

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

Afaik this but is invalid as listpages already supports redirection?

$ python pwb.py listpages -lang:test -family:test -cat:A
   1 Category page
   2 Incnis Mrsi
   3 Test sortkey
   4 Test sortkey2
   5 Test sortkey3
5 page(s) found
$ python pwb.py listpages -lang:test -family:test -cat:A > list
5 page(s) found
$ cat list 
   1 Category page
   2 Incnis Mrsi
   3 Test sortkey
   4 Test sortkey2
   5 Test sortkey3

The only valid part is that listpages doesn't support everything category listify supports.

would this pattern work?
$ python pwb.py listpages -listify:<path/to/directory>
I'll include subcategories and talkpages and the recurse property so that it yields almost all articles in the category as they appear when we pipe the results using CategoryListifyRobot into a webpage. Furthermore, as you suggest, I will properly integrate it with rest of the script i.e. I won't make a new class for it. I'll collect all the articles and write it into a file in the directory given in the arguments and I shall do both these things in the main function itself, but before a generator is invoked, since we won't need a generator for -listify option. Should I continue with this approach?

XZise added a comment.Oct 13 2015, 3:13 PM

Isn't it already possible to also get subcategories using -subcats/-subcatsr? Now with regard to the talkpages @jayvdb afaik suggested to make the pywikibot.pagegenerators.PageWithTalkPageGenerator visible via the command line so that you can use it's generator. But I don't think that'll be useful for the formatter as the it only works on one page at a time.

So personally, adding a way to also handle the talk pages is more suitable. You just need to enhance the formatter to also provide variables for the talk page. There is Gerrit 239682 upon this could be build. Or we have a proxy class for page instances and the format gets two of those to provide a proxy for each page “variant” (non-talk page and talk page). So that instead of the entries site, title there are site, page.title and talk.title. Maybe we could coordinate and I implement the proxy class in my patch and you provide the talkpage related part (aka creating a proxy instance and providing that) in your patch.

But still I think we don't need an option to save it to disc for listpages. I can understand that it's suggested for category listify as that saves the list to the wiki, but that category listify is mostly redundant with listpages and so it was suggested to deprecate the former. But listpages prints the output to the console so you can use redirection (as I've shown above) so that doesn't need it.

Now in case others disagree and they want that option, please don't use an option like -listify because that doesn't describe what it does. Maybe something like -tofile instead (-file is already used by pagegenerators).

Thank you for your reply.
Redirection shall serve the purpose here. If others decide against it, -tofile will be a better option name.
I just wanted to confirm my part in the patch to come, i.e. you will amend the Formatter class to handle both non-talk and talk pages and I shall instantiate the newly amended class. Is this it?

Framawiki moved this task from Backlog to Doing on the good first bug board.Dec 2 2017, 1:41 PM
Restricted Application added subscribers: Cyberpower678, TerraCodes. · View Herald TranscriptDec 2 2017, 1:41 PM

Change 245471 had a related patch set uploaded (by Zoranzoki21; owner: Tokencolour):
[pywikibot/core@master] Listify to file option in category.py

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