Manual talk:Pywikibot/add text.py

Latest comment: 3 years ago by Backlitt in topic -except argument removed
The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

Add Text to pages in Special:WantedCategories

edit

The header says it all... Is it possible to add a specific text to all pages in Special:WantedCategories? --91.33.247.68 21:23, 23 September 2009 (UTC) (Felix)Reply

You can use the cat parameter, multiple times, e.g.
add_text.py -cat:"WandetCat1" -cat:"WantedCat2" -text:"Text to be added"
but I don't know any way to refer on Special:WantedCategories or on any special page. --Plasmarelais 17:37, 29 September 2009 (UTC)Reply

Bot doesn`t see the article

edit

Hello!

I got some troubles while using this bot on my own wiki-site. It starts normally, gets the category. Then following message comes:

 Note: this language does not allow global bots.
 Loading %pagename%...
 Getting page [[%pagename%]]
 Request ru:/wiki/api.php?action=query&format=json&meta=userinfo&uiprop=blockinfo
 Note: this language does not allow global bots.
 %pagename% doesn't exist, skip!
 Traceback (most recent call last):
   File "%path%/pywikipedia/add_text.py", line 312, in <module>
     main()
   File "%path%/pywikipedia/add_text.py", line 308, in main
     (text, newtext, always) = add_text(page, addText, summary, regexSkip, regexSkipUrl, always, up, True)
 ValueError: need more than 2 values to unpack


%pagename%, %path% - i put it here instead of real names. May be I should "turn on" global bots on my wiki somehow? I have mediawiki 1.15.1, python 2.6.2, pywikipedia 7282 installed. I`ll be glad to get any help, `cause this is first time I use pywikipedia bots. 93.89.211.151 13:36, 24 September 2009 (UTC)Reply

Is your bot running with global bot rights or with local bot rights? --Plasmarelais 17:50, 29 September 2009 (UTC)Reply
Plasmarelais, thank you for attention. I can`t tell you such info, just because I don`t know, how to check it. Could you explain more properly what file I can get such info from?
It seems I didn't find out, what is meant with global bot. You say it's your own wiki, is it a wikia-wiki? Maybe these 2 pages may help, but I don't know more about it: m:Talk:Bot policy/Implementation and m:Bot policy#Global bots. Sorry --Plasmarelais 12:37, 5 October 2009 (UTC)Reply
Thank you for trying to help. I`ve looked through these pages, but I still can`t understand, how do I turn these global bots on and do I realy need it to be done to solve my problem...--91.193.253.138 13:29, 5 October 2009 (UTC)Reply
Updating to the 7492-version of pywikipedia fixes the problem.--91.193.253.138 21:52, 17 October 2009 (UTC)Reply

Add text to empty pages

edit

I've got a problem. I want to add a (long) text to ~150 pages. I've got a List of all these pages. Unfortunately it doesn't work.

Here is what I've tried so far (Do not punch me. The error logs prooves that I'm using windows -- and german...):

C:\Users\damrau\Miniprogs\pywikipedia>python add_text.py -links:Spielwiese -text:"Test"
Loading Benutzer Diskussion:-MM-...
Benutzer Diskussion:-MM- doesn't exist, skip!
Traceback (most recent call last):
 File "add_text.py", line 312, in <module>
   main()
 File "add_text.py", line 308, in main
   (text, newtext, always) = add_text(page, addText, summary, regexSkip, regexS
kipUrl, always, up, True)
ValueError: need more than 2 values to unpack

Does anybody know how to solve this? I do not really understand the error message. --91.33.195.178 08:02, 5 October 2009 (UTC) (Felix)Reply

Far as I know, add_text.py only works on existing pages. But you may use Pywikipediabot/pagefromfile.py to create those pages using a file that contains necessary information, which should easily be created from the list you already have. --Plasmarelais 08:13, 5 October 2009 (UTC)Reply
Excuse my offtop. As I see, this problem is quite similar to the one I`ve got (see the previous topic). But in my situation I do have this pages on my wiki, but add_text.py doesn`t see them. Any idea about this? (Please, answer in previous topic).--91.193.253.138 11:15, 5 October 2009 (UTC)Reply
There is a quite new version of this script. Did you download and replace this with the file in your pywikipedia directory? Maybe that will solve your problem --91.33.195.178 22:30, 5 October 2009 (UTC) (Felix)Reply
There is an easy way to make add-text.py not skip non-existent pages. Simply edit the add_text.py file to change "create=talkPage" (sixth line from the bottom) to "create=True". 71.232.44.22 19:21, 24 May 2012 (UTC)Reply

No documented parameters

edit

The readme/docs for this script do not include or state the core parameters that can be used. Currently it only says:

These command line parameters can be used to specify which pages to work on:
  &params;

So my question is... what parameters? --Ccornell 09:08, 20 November 2009 (UTC)Reply

&params will work nicely, when you type add_text.py -help. It takes help from pagegenerators.py. Bináris tell me 11:58, 4 March 2011 (UTC)Reply

Why is this page moved to mw?

edit

What was the reason to move this page from Meta to MediaWiki, while all the similar pages about various scripts are on Meta? Bináris tell me 12:00, 4 March 2011 (UTC)Reply

Merged content

edit

This section, without the section header and the italic comments was here on mw.org before the import of the above content from meta
What was the reason to move this page from Meta to here, while all the similar pages about various scripts are on Meta? Bináris 11:55, 4 March 2011 (UTC)Reply

I didn't find the consensus but suggest to build the JavaScript library at the same place. JackPotte 10:06, 5 March 2011 (UTC)Reply

This stuff is not related to JavaScript, and now it is disconnected from other Pywikibot scripts. Bináris 21:18, 16 March 2011 (UTC)Reply

End merged content
The above thread refers to the import of the add_text.py documentation when most other pages had not been imported. Now all pywikipediabot documentation and talk pages have been imported. The reason for the move is that the pywikipediabot scripts are maintained in the wikimedia subversion repository and therefore documentation for them belongs here on mw.org--Doug.(talk contribs) 21:17, 18 December 2011 (UTC)Reply

Problems with large pages (> 600 kB)

edit

Is it possible that this script doesn't work with large pages of e.g. more than 600 kB? I got a Python error when I tried to add some sections to [1], but with a similar page of about 350 kB it worked perfectly. I don't know if this is a known issue or if I have to file a bug. Regards --CroMagnon (talk) 22:42, 17 November 2012 (UTC)Reply

Sections

edit

How can I add text for a section? (by name, by the number of the section) Thanks, Dekel E (talk) 07:19, 3 January 2014 (UTC)Reply

parameter except

edit

Do I get it right, that whenever i give more than one parameter except, that the script only skips those pages that contain all of the given strings? Example:
add_text.py -start:! -text:"TEXT" -except:"abc" -except:"xyz"
will add text on a page that contains abc but not xyz (and vice versa) but will skip a page that contains abc and xyz? --Plasmarelais (talk) 09:10, 12 August 2015 (UTC)Reply

Solution: Using the pipe in the except parameter. -except:"(\[\[[Cc]ategory)|([Ll]icense)|(\{\{[Ss]ource)" will have the bot skip any page that contains Category or category or License or license or... --Plasmarelais (talk) 21:10, 29 August 2015 (UTC)Reply

Allow to remove minor edit tag

edit

Hello,

I use the script to add a section to a project page which is designed for technical logs (essentially added by bots). But, with this script, I currently can't remove the minor edit tag, which is fixed automatically. Could we add a parameter to add_text(…) to allow the removal of this tag? — Automatik (talk) 16:39, 6 March 2016 (UTC)Reply

[RESOLVED] PWB crashes with "Caught exception of type OOUI" with "add_text.py" on FORM pages

edit

The command: $python3 pwb.py add_text -family:mywiki -lang:en -page:"MyPage" -text:"Foo" works great for all pages except those in the "Forms" namespace. For some reason all Form pages crash "add_text.py" as follows:

[me@myserver core_stable]$python3 pwb.py add_text -family:mywiki -lang:en -page:"Form:MyForm" -text:"Foo"
Loading Form:MyForm...


>>> Form:MyForm <<<
@@ -95,2 +94,0 @@
- [[Category:Crashes Transferbot]]

@@ -101 +99,5 @@
- </noinclude>
+ </noinclude>
+ Foo
+
+ [[Category:Crashes Transferbot]]

Do you want to accept these changes? ([y]es, [N]o, [a]ll, open in [b]rowser,
[q]uit): y


WARNING: API error internal_api_error_OOUI\Exception: [X6MLWZ2b5l25IGNg96uvrwAAAAU] Exception caught: OOUI\Theme::singleton was called with no singleton theme set.
ERROR: Detected MediaWiki API exception internal_api_error_OOUI\Exception: [X6MLWZ2b5l25IGNg96uvrwAAAAU] Exception caught: OOUI\Theme::singleton was called with no singleton theme set.
[errorclass: OOUI\Exception;
 *: OOUI\Exception at /opt/htdocs/mediawiki/vendor/oojs/oojs-ui/php/Theme.php(31)
#0 /opt/htdocs/mediawiki/vendor/oojs/oojs-ui/php/Element.php(241): OOUI\Theme::singleton()
#1 /opt/htdocs/mediawiki/extensions/PageForms/includes/forminputs/PF_DatePickerInput.php(108): OOUI\Element->toString()
#2 /opt/htdocs/mediawiki/extensions/PageForms/includes/PF_FormPrinter.php(1905): PFDatePickerInput->getHtmlText()
#3 /opt/htdocs/mediawiki/extensions/PageForms/includes/PF_FormPrinter.php(1295): PFFormPrinter->formFieldHTML(PFFormField, string)
#4 /opt/htdocs/mediawiki/includes/StubObject.php(112): PFFormPrinter->formHTML(string, NULL, boolean, NULL, NULL, string, NULL)
#5 /opt/htdocs/mediawiki/includes/StubObject.php(138): StubObject->_call(string, array)
#6 /opt/htdocs/mediawiki/extensions/PageForms/includes/PF_Hooks.php(389): StubObject->__call(string, array)
#7 /opt/htdocs/mediawiki/includes/Hooks.php(174): PFHooks::showFormPreview(EditPage, DerivativeRequest)
#8 /opt/htdocs/mediawiki/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#9 /opt/htdocs/mediawiki/includes/EditPage.php(1117): Hooks::run(string, array)
#10 /opt/htdocs/mediawiki/includes/api/ApiEditPage.php(386): EditPage->importFormData(DerivativeRequest)
#11 /opt/htdocs/mediawiki/includes/api/ApiMain.php(1601): ApiEditPage->execute()
#12 /opt/htdocs/mediawiki/includes/api/ApiMain.php(537): ApiMain->executeAction()
#13 /opt/htdocs/mediawiki/includes/api/ApiMain.php(508): ApiMain->executeActionWithErrorHandling()
#14 /opt/htdocs/mediawiki/api.php(87): ApiMain->execute()
#15 {main}]; raising
ERROR: page [[Form:MyForm]] not saved due to internal_api_error_OOUI\Exception: [X6MLWZ2b5l25IGNg96uvrwAAAAU] Exception caught: OOUI\Theme::singleton was called with no singleton theme set.
[errorclass: OOUI\Exception;
 *: OOUI\Exception at /opt/htdocs/mediawiki/vendor/oojs/oojs-ui/php/Theme.php(31)
#0 /opt/htdocs/mediawiki/vendor/oojs/oojs-ui/php/Element.php(241): OOUI\Theme::singleton()
#1 /opt/htdocs/mediawiki/extensions/PageForms/includes/forminputs/PF_DatePickerInput.php(108): OOUI\Element->toString()
#2 /opt/htdocs/mediawiki/extensions/PageForms/includes/PF_FormPrinter.php(1905): PFDatePickerInput->getHtmlText()
#3 /opt/htdocs/mediawiki/extensions/PageForms/includes/PF_FormPrinter.php(1295): PFFormPrinter->formFieldHTML(PFFormField, string)
#4 /opt/htdocs/mediawiki/includes/StubObject.php(112): PFFormPrinter->formHTML(string, NULL, boolean, NULL, NULL, string, NULL)
#5 /opt/htdocs/mediawiki/includes/StubObject.php(138): StubObject->_call(string, array)
#6 /opt/htdocs/mediawiki/extensions/PageForms/includes/PF_Hooks.php(389): StubObject->__call(string, array)
#7 /opt/htdocs/mediawiki/includes/Hooks.php(174): PFHooks::showFormPreview(EditPage, DerivativeRequest)
#8 /opt/htdocs/mediawiki/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#9 /opt/htdocs/mediawiki/includes/EditPage.php(1117): Hooks::run(string, array)
#10 /opt/htdocs/mediawiki/includes/api/ApiEditPage.php(386): EditPage->importFormData(DerivativeRequest)
#11 /opt/htdocs/mediawiki/includes/api/ApiMain.php(1601): ApiEditPage->execute()
#12 /opt/htdocs/mediawiki/includes/api/ApiMain.php(537): ApiMain->executeAction()
#13 /opt/htdocs/mediawiki/includes/api/ApiMain.php(508): ApiMain->executeActionWithErrorHandling()
#14 /opt/htdocs/mediawiki/api.php(87): ApiMain->execute()
#15 {main}]

[me@myserver core_stable]$

This error message does not produce any results when searched for.

Please advise.

Thanks!

/Rich Revansx (talk) 19:24, 4 November 2020 (UTC)Reply

RESOLVED per https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/PageForms/+/ed9394b7a4fa91ac93052817f18b28885e7312f6%5E%21/#F0

-except argument removed

edit

Was removed in v 6.3.0 --Backlitt (talk) 17:26, 22 June 2021 (UTC)Reply

Return to "Pywikibot/add text.py" page.