Last modified: 2014-09-02 00:35:23 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T56567, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 54567 - Add "-only" option to add_text.py
Add "-only" option to add_text.py
Status: NEW
Product: Pywikibot
Classification: Unclassified
Other scripts (Other open bugs)
unspecified
All All
: High enhancement
: ---
Assigned To: Amir Ladsgroup
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-24 22:33 UTC by Kunal Mehta (Legoktm)
Modified: 2014-09-02 00:35 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Kunal Mehta (Legoktm) 2013-09-24 22:33:56 UTC
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.
Comment 1 Kunal Mehta (Legoktm) 2013-09-24 22:33:58 UTC
diff file for add_text.py -only and open in browser additions
Comment 2 Kunal Mehta (Legoktm) 2013-09-24 22:34:00 UTC
diff file for add_text.py -only and open in browser additions (take two! :) )
Comment 3 Kunal Mehta (Legoktm) 2013-09-24 22:34:02 UTC
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\).
Comment 4 Kunal Mehta (Legoktm) 2013-09-24 22:34:03 UTC
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.
Comment 5 Kunal Mehta (Legoktm) 2013-09-24 22:34:05 UTC
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.\)
Comment 6 Kunal Mehta (Legoktm) 2013-09-24 22:34:07 UTC
@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/﷒1﷓ \], as I think that part is good in any case \(and the patch should be applied in seperate commits anyway\)
Comment 7 Amir Ladsgroup 2014-07-24 08:39:56 UTC
Really interesting patch

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links