Topic on User talk:Dvorapa

Help with Pywikibot

23
Klein Muçi (talkcontribs)

Hey there! :) I saw your name on the contributors list of this page. I had a question, maybe you can help me: I know that by using the -summary parameter we can set up a specific message to appear on all our edit's summaries. Is there a way we can have that "generic message" + the specific change made on each edit? Something like this: Summary: XYZ [XX -> YY].

Dvorapa (talkcontribs)

You have to change script's code of course. Look into the code and search for "message", "summary" or "comment" and change that part of code to your needs. For further help try to ask @Xqt. I love to help, but due to Covid all my free time is gone :/

Klein Muçi (talkcontribs)

Thank you for your response! Unfortunately, that's exactly the problem. I have no formal technical background so the code (written by me) is just made following the instructions on that page I mentioned above. And at the moment, it just says ...-summary:Generic message I've written -another parameter:.... I wanted to know how should I change it so I can make that possible. But don't worry at all. Fully understandable and I hope you stay safe during these times. :)

Xqt (talkcontribs)

Currently there is no way to modify the default messages. Either you can give your own message with -summary option or auto summary message is used. But you can file a feature request at Phabricator to propose the implementation modifying the generic summary.

Xqt (talkcontribs)
Klein Muçi (talkcontribs)

Oh... There wasn't a way... That's why I couldn't find anything for it. I've spent quite some days going through the whole documentation in regard to setting summaries but I couldn't find anything in combining the 2 methods mentioned above. So now we can use -summary: %(description)s to get the needed results? Or isn't the change implemented yet?

Xqt (talkcontribs)

The change is ready to submit to the current master (6.0.0-dev0). It will be part of the stable release 6.0.0 comming soon.

Klein Muçi (talkcontribs)

Thank you a lot! :) Given your knowledge on Pywikibots, can I reach to you in the future for anything related to it if I encounter a problem or anything of the sort?

Xqt (talkcontribs)
Klein Muçi (talkcontribs)

@Xqt, -summary: %(description)s still doesn't work as a command (the system perceives it as a literal text string). Should I still be waiting or am I doing something wrong?

Xqt (talkcontribs)

It works for me as follows:

C:\pwb\GIT\core>pwb replace a b -page:user:xqt/Test -summary:"foo bar baz: %(description)s" -simulate
Retrieving 1 pages from wikipedia:de.


>>> Benutzer:Xqt/Test <<<
@@ -1 +1 @@
- <code>&amp;</code>
+ <code>&bmp;</code>

Do you want to accept these changes? ([y]es, [N]o, [e]dit original, edit
[l]atest, open in [b]rowser, [m]ore context, [a]ll, [q]uit): y
Edit summary: foo bar baz:  (-a +b)
SIMULATION: edit action blocked.

1 pages read
1 pages written
0 pages skipped
Execution time: 12 seconds
Read operation time: 10.0 seconds
Write operation time: 12.0 seconds
Script terminated successfully.

C:\pwb\GIT\core>

The change was deployed with 6.0.0. Did you update your bot? What is your Pywikibot version actually?

Klein Muçi (talkcontribs)

Retrieving 50 pages from wikiquote:sq. Working on 'Esat Stavileci'

>>> Esat Stavileci <<< @@ -34 +34 @@ - BLABLU + TEST

Edit summary: Smallem: Përmirësime teknike dhe rregullime të gabimeve me referimet: %(description)s Sleeping for 9.1 seconds, 2021-04-13 11:18:41 Page Esat Stavileci saved


This is what I get when I try to use it on a random page on SqQuote which has been changed specifically to include the needed string for testing purposes. As you can see, the command gets included as a literal text string on the summary.


How do I update my bot? How do I check for my current version? I run it through Toolforge and, judging by what I read at this page: Help:Toolforge/Pywikibot when I started dealing with this thing, I'm supposedly always running the latest version automatically, no?

Xqt (talkcontribs)

just run

pwb.py version

to check the Pywikibot version

Klein Muçi (talkcontribs)

-bash: pwb.py: command not found

What am I doing wrong?

Xqt (talkcontribs)

OK try:

python3 pwb.py version or python3 /data/project/shared/pywikibot/stable/scripts/version.py

I don't know were pwb.py resides and which directory settings are made for your local repository.

Klein Muçi (talkcontribs)

With the second command, I get this.


PS: The deprecation warnings seem to be there after most of the commands I type now. They weren't there before.

Xqt (talkcontribs)

Ah, the new summary feature only works with -summary option and not with fixes msg :-(yet)

Klein Muçi (talkcontribs)

And I was thinking that to be honest but then I thought that everything else works nearly just the same between the two methods so that wouldn't be a problem. But I still suspected it and that's why I posted the whole thing that I was using. Turns out it was a good idea.

So, is there any chance to make it work with fixes aswell soon? I need the list of fixes because I have around 40k regexes to make and I don't want to double the list for every wikiproject that I activate my bot on. Using fixes allows me to have 1 single list for every wikiproject.

Also, I don't believe I need to do any kind of updates, do I? I do have the latest version, no? What are those warnings though? Do I need to do anything about those?

Xqt (talkcontribs)

No there is no chance to implement it with fixes msg because you can use multiple -fix options in the same run which would duplicate the description. The only way is to enable the -summary option even if msg keys are given. Currently you can remove the msg key from fixes setting.

Klein Muçi (talkcontribs)

I'm pushing in unknown territory here but can't you use the "msg" part of the command as an anchor and basically make it work with that? No matter how many fix options you have, the msg part will be the same in all of them, won't it?

If not, I'll try transporting the summary from the fixes to the script itself. I was trying to keep the script pages as small as possible, that's why I asked. :)

Xqt (talkcontribs)

No, every fixes option has its own msg and they will be combines finally. You can omit the msg from fixes entry and use -summary instead.

Klein Muçi (talkcontribs)

I see. Okay then. That's what I did. It works fine. Should this whole thing be documented in a page though? It's not written anywhere on MediaWiki currently, is it?

Klein Muçi (talkcontribs)

What I'm currently using:


At user-fixes.py:

fixes['Smallem2'] = {

    'regex': True,

        'nocase': True,

    'msg': {

        '_default':'Smallem: Përmirësime teknike dhe rregullime të gabimeve me referimet: %(description)s',

    },

    'replacements': [

        (r"BLABLU", r"TEST")

        ]

}


At my script:

#!/bin/bash

source $HOME/.bash_profile

python3 /data/project/shared/pywikibot/stable/scripts/replace.py -log -v -ns:0 -transcludes:Moduli:Citation/CS1 -fix:Smallem2 -family:wikiquote -always

Reply to "Help with Pywikibot"