scripts/editarticle.py is not simple enough to make edits (or create pages).
I suggest this script.
Here's an example how to use it:
$ echo "Hello world" > Test.wiki
$ python pwb.py simpleedit.py "The edit summary" "Test" Test.wiki
scripts/editarticle.py is not simple enough to make edits (or create pages).
I suggest this script.
Here's an example how to use it:
$ echo "Hello world" > Test.wiki
$ python pwb.py simpleedit.py "The edit summary" "Test" Test.wiki
Project | Branch | Lines +/- | Subject | |
---|---|---|---|---|
pywikibot/core | master | +28 -16 | [IMPR] New options for pagefromfile.py |
I really no know what is not ok with that script. Can you add more details what is wrong with script? Thanks!
CC`ing @Xqt @Framawiki @Dvorapa
scripts/editarticle.py is not simple enough to make edits (or create pages).
Please explain why you think so. Thanks!
I should note that I need to edit directory.fsf.org (not Wikipedia).
However, editarticle.py reads: "Edit a Wikipedia article with your favourite editor."
What is the simplest way to use editarticle.py to do the same thing as:
$ echo "Hello world" > Test.wiki
$ python pwb.py simpleedit.py "The edit summary" "Test" Test.wiki
I'm sorry but I have absolutely no idea how that happened. I just edited the text and saved it.
First of all, the file should have correct Pywikibot license. Also the args should be in the same format like in other scripts (-summary) and there should be handled other args added (like "These args are not supported by this script: %s"). You can upload your file directly to Gerrit using Git/Svn or using a Gerrit patch uploader.
Finally for this purpose we already have pagefromfile.py or a little bit easier add_text.py. You can also use basic.py, which has the same functionality as add_text.py, but contains everything the proper Pywikibot script should have (so it is left here as an example to novice PWB script programmers).
Finally for this purpose we already have pagefromfile.py or a little bit easier add_text.py. You can also use basic.py, which has the same functionality as add_text.py, but contains everything the proper Pywikibot script should have (so it is left here as an example to novice PWB script programmers).
Thanks, that's really useful. Can you please give me the lines needed for these scripts to do the same things as:
$ echo "Hello world" > Test.wiki
$ python pwb.py simpleedit.py "The edit summary" "Test" Test.wiki
Can you please give me the lines needed for these scripts to do the same things as:
That would be slightly different but can be used with:
$ echo "{{-start-}}" > Test.wiki
$ echo "‘‘‘Test‘‘‘" >> Test.wiki
$ echo "Hello world" >> Test.wiki
$ echo "{{-stop-}}" >> Test.wiki
pwb.py pagefromfile -file:Test.wiki -notitle
Don’t see any real workflow to simplify this.
That's a non-issue. I sent this quick-and-dirty script to FSF so they can use it whatever they want. If license is a concern, the licenses allows re-publishing under a different license.
Finally for this purpose we already have pagefromfile.py or a little bit easier add_text.py
We have discussed this. pagefromfile.py cannot read from a non-seekable stream (such as pipe) and add_text.py cannot do page replacements when the page exists.
You can also use basic.py
Only works on existing pages.
Both licenses are Free Software Foundation (FSF) approved.
That's a non-issue. I sent this quick-and-dirty script to FSF so they can use it whatever they want. If license is a concern, the licenses allows re-publishing under a different license.
Yes that is how everything started. I'm a FSF intern during this summer and I work with the tech team. I requested zhuyifei1999 to write this script for me since I needed to batch upload .wiki files to directory.fsf.org.
Finally for this purpose we already have pagefromfile.py or a little bit easier add_text.py
We have discussed this. pagefromfile.py cannot read from a non-seekable stream (such as pipe) and add_text.py cannot do page replacements when the page exists.
You can also use basic.py
Only works on existing pages.
The script authored by zhuyifei1999 is very useful since it 1) updates pages if it already exist and create pages if they don't exist. 2) doesn't require files that starts with "{{-start-}}" and ends with "{{-stop-}}" -- we will batch upload 25 000 .wiki files so it will be a tedious task to generate 25 000 files just for this purpose.
- doesn't require files that starts with "{{-start-}}" and ends with "{{-stop-}}" -- we will batch upload 25 000 .wiki files so it will be a tedious task to generate 25 000 files just for this purpose.
You may easily add 25 000 delimited entries to that single file and upload them by a single command at once.
Delimiting is a non-solution, unless there are ways to 'escape' delimiters *and* the script can read from non-seekable streams.
Do One Thing and Do It Well. pagefromfile.py is neither.
I suggest to improve both pagefromfile.py and add_text.py/basic.py:
This should work too if page does not exist:
$ echo "Hello world" > Test.wiki $ python pwb.py add_text -text:"$(cat Test.wiki)" -page:"Test"
Yeah, the script can get one huge file like:
{{-start-}} '''Test''' Hello world {{-stop-}} {{-start-}} '''Test 2''' Hi world {{-stop-}} ...
This should work too if page does not exist:
$ echo "Hello world" > Test.wiki $ python pwb.py add_text -text:"$(cat Test.wiki)" -page:"Test"
It does not (might be it does for others than windows)
Probably Linux only, I do not know, hot to write Windows shell/Powershell command like this (I've found only https://stackoverflow.com/questions/43225925/windows-cmd-pass-output-of-one-command-as-parameter-to-another so far)
Probably Linux only, I do not know, hot to write Windows shell/Powershell command like this
I am wondering that it is able for Linux because the option parameter -text:"$(cat Test.wiki)" is just a text. No glue why/how the bot can Interpret this as a batch command
It doesn't. That's bash. Double quotes allows interpretation of some tokens, and $() makes command substitution. Therefore, in bash, -text:"$(cat Test.wiki)" means execute cat Test.wiki, get its stdout, then prepend its stdout with -text: and use the entire prepended string as a single argument to python.
Change 444011 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] New options for pagefromfile.py
Change 444011 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] New options for pagefromfile.py
Exactly, pagefromfile.py can't overwrite pages. It says:
Page Test already exists, not adding!
You may use one of these options:
-appendtop Add the text to the top of the existing page -appendbottom Add the text to the bottom of the existing page -force Overwrite the existing page
Probably also https://www.mediawiki.org/wiki/Manual:Pywikibot/pagefromfile.py needs to be updated with the new parameters
Not sure why, we should ask mediawiki.org or ContentTranslation communities for some support
pagefromfile.py is very useful now. To get the script working I have to run this to download the required scripts/i18n/ directory:
git clone https://gerrit.wikimedia.org/r/pywikibot/core pywikibot-core
cd pywikibot-core
git submodule update --init
Is there a shorter way to do it?
Please give me an example how to use editarticle.py to do this:
echo "Hello world" > Test.wiki;
python pwb.py pagefromfile -summary:"The edit summary" -title:"Test" -file:"Test.wiki" -textonly -force