Page MenuHomePhabricator

Add "-only" option to add_text.py
Closed, ResolvedPublic

Description

Originally from: http://sourceforge.net/p/pywikipediabot/patches/537/
Reported by: phoenixca
Created on: 2012-01-21 20:06:11
Subject: Minor improvements on add_text.py
Original description:
Added an open in browser option to confirmation dialogue \(similar to replace.py \) and added a new -only arg \(essentially the opposite of -except\). If a page text doesn't match the -only regex given, it skips.

Example use:
I added this while trying to clean-up a Wikia wiki. Wikia's RTE leaves \[\[File:Placeholder on pages often. With this addition, the bot can use -only:"\[\[File:Placeholder" -except:"\{\{image\}\}" -text:"\{\{image\}\}" -up , to add a meta tag to pages that have image placeholders, but not ones that already have the \{\{image\}\} tag.


Version: unspecified
Severity: enhancement
See Also:
https://sourceforge.net/p/pywikipediabot/patches/537

Details

Reference
bz54567

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:11 AM
bzimport set Reference to bz54567.

diff file for add_text.py -only and open in browser additions

diff file for add_text.py -only and open in browser additions (take two! :) )

I know this is not a real pagegenerator, but why don't make regexOnly a global parameter, which can be used for every other script? It may be useful for many other scripts \(like replace.py, but also templatecount.py or category.py sometimes\).

Looks very nice. There are a few \(minor\) issues that should be fixed though:
\* the regexOnly should be added at \*last\* parameter in add\_text, so as not to break API compatibility
\* Match was %s""" % result\) doesn't make sense if there is no match \(result will always be \[\]\)

and I cnanot see this \(I'm only looking at the diff, lazy me\) - what is the goal of the 'continue' on line 61 of the diff? If I look at the return just above, there is no for loop going on, which makes the continue do nothing... but I may be wrong.

Ah, all good points. I'll fix those up and upload a new diff here. \(Forgive the newbie to programming. I'm learning out of necessity for wiki administration.\)

@nickanc: yes, this would be a good idea. There are several parameters in replace.py that really should be moved to pagegenerators as a 'filter' generator \(-requiretitle with/without regex, excepttext with/without regex,\). However, given this, I don't think there is a huge harm in adding another one. Xqt, what do you think?

I have applied the webbrowser part in r10034 \[ http://toolserver.org/~pywikipedia/r10034 \], as I think that part is good in any case \(and the patch should be applied in seperate commits anyway\)

Change 175427 had a related patch set uploaded (by Ladsgroup):
[T56567] Add -only and -onlytitle options to add_text.py

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

Patch-For-Review

Ladsgroup set Security to None.

You should use -titleregex for -onlytitle and -grep for -only option. It's already implemented

Change 175427 abandoned by Ladsgroup:
[T56567] Add -only and -onlytitle options to add_text.py

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