Page MenuHomePhabricator

Improve CLI of the pywikibot category.py script
Open, Needs TriagePublic

Description

Hello,

In a nutshell:

  • rename remove subcommand into void
  • add a drop subcommand

I'm just starting to use pywikibot to help me making batch edit of categories for Wiki Loves Love on Commons. So I was happy to see that an existing script was already making what I wanted out of the box, thank you for that.

However I've been confused by the CLI: while adding a category to a list of pages stored in a file was straight forward, the script help was very clear on the add subcommand and worked as I expected.

However removing an existing category from a list of pages was not so obvious: the lake of difficulty with the add command gave me confidence to try directly the "remove" option in the exact same way, providing the same file listing targeted images as input. But it happens that remove actually void the category, using all items it contains as input. Admittedly, it's clear once you read the command help thoroughly, but it's nonetheless a surprising behaviour, at least to me. Thus I would suggest to rename this subcommand void, drain, empty, gut, deplete or something like that.

Next seeing no clear option to remove a category from a list of pages, I started to edit the script in order to evaluate if I could quickly add a drop subcommand. I then discovered that actually one can apparently use the move command to remove a category if the target category is "none". That should at minimum appear in the subcommand help I think. However, I would suggest to rather add a drop subcommand, and deprecate the move to oblivion behaviour.

Cheers

Event Timeline

Ho, actually it seems that the move subcommand don't allow to provide a list of target as add does, but like remove will only work on the complete list of items in a category. So it doesn't give out of the box what I was looking for, as I had supposed in my initial description. But the evolution proposal seems still valid to me.

-remove is removing the category from pages given by the generator. The category is only emptied if all pages of the given category are processed.

Well, @Xqt, except if there is a way to tweak the generator to use the provided list of page as target, this still doesn't provide a way to do what I wanted with this script. In the midtime I however successfully used ./pwb.py replace -file:./targets/acceptables.txt "Images from Wiki Loves Love 2019 to check" "Accepted images from Wiki Loves Love 2019" -automaticsummary -always to do what I wanted.

So I think that the suggested evolutions remain relevant, but at least be aware that it's not a blocking issue, as far as I'm concerned.

Cheers, and thank you for your quick reply.

@Psychoslave Could you explain it once more to me in a different way please? I do understand there are some two tasks you want to achieve and one is not possible with category.py, but I don't really understand the difference between them, I'm sorry. What would be the task for your suggested void command and what would be tha task for drop command specifically? What pages will be processed by each of these and in which way?

In other words I feel like the thing you are describing has an existing solution you haven't discovered. But I don't really understand your description (my poor english knowledge)

In other words I feel like the thing you are describing has an existing solution you haven't discovered. But I don't really understand your description (my poor english knowledge)

@Psychoslave Your input is needed here.