Let's say I've got the following wikitext:
Some stuff
More stuff
{{MyTemplate}}<!-- comment -->
Blah
Blah
I want to find {{MyTemplate}} but only if it's immediately followed by <!-- comment -->, and insert something after the comment. Is there anything that does that kind of pattern matching? I can use mwparserfromhell to find the template:
> for node in wikicode.nodes:
> if isinstance(node, mwp.nodes.Template) and node.name.matches("MyTemplate"):
but I don't see any way to match on two consecutive nodes without building my own little state machine in the loop to keep track of what the previous node was.
How do people install their bots into toolforge? In the past, I've just done a "git pull" to the bastion host and run with the code directly out of the source tree, but I'm not sure that's a good plan.
My current project is a more complicated, with a bot that I'm going to run on krb as a toolforge cron job <https://wikitech.wikimedia.org/wiki/Help:Toolforge/Jobs_framework#Creating_…>, a web service that's going to run via "webservice --backend=kubernetes python3.9 start" and also some command-line scripts that I'll want to run interactively. All this code will be in the same git repo. So I'm thinking of building a wheel and installing it that way. So, I guess that means building the wheel locally with setuptools, scp the wheel over to the bastion, shell into a krb node to do "pip install" into my virtualenv.
The stumbling block with that plan seems to be that toolforge insists on your webapp being installed at $HOME/www/python/src/app.py, which isn't going to play well with a wheel installation.
I never thought I'd ever write this, but after close to 40 years of using emacs for everything, I'm thinking of switching to a real IDE for python development. My latest evolution is emacs with elpy, which is pretty powerful as these things go, but I seem to spend more time configuring emacs and less time writing code than I want to. I got clarity on this the other day when I was comparing the toolforge bastion hosts, the cloud VPS images, and the kubernetes back ends to see which versions of emacs each one had and realized this really was the tail wagging the dog.
I'm kind of in "big paradigm shift" mode right now. Moving from Django to Flask. From mwclient to pywikibot. From unittest to pytest. I guess since I'm reinventing the universe, I might as well look at editors too. Other than the basic syntax coloring and auto-completion, I'm looking for good integrations with running unit tests and with git. I also need support for web technologies like HTML, jinja templates, and javascript in the same tool.
I've heard good things about Sublime, but never used it. I'm not averse to purchasing a license if it's worth it.
I've used Eclipse in the past for Java, and was pretty happy with that. I gather that Eclipse + PyDev is pretty neat but never tried it.
I know a lot of people live in Jupyter, but that's not really my style.
What else should I be looking at? What are folks out there using?
I got a mail from Gerrit with the above subject.
Just to put my 2 cents: while this change may help the regex to be more
readable, such changes in high-scale may harden the transforming of regexes
between Pywikibot format and AWB format, and we have a Phab ticket about
the cooperation. As we use more Python-specific regexes, the Pywikibot
users and AWB uers may be able to help each other less on bot owners'
noticeboards.
This is not a critics, just a point of view which may worth to consider.
--
Bináris
I'm trying to implement the idea that was suggested in this edit. <https://en.wikipedia.org/w/index.php?title=Wikipedia:Bots/Requests_for_appr…>
I see how I can find the existing {{DYK-Tools-Bot was here}}, with Page.templatesWithParams(). But once I've got that, how do I actually change the parameters in the wikitext?
In commons_information.py
try:
import mwparserfromhell
except ImportError as e:
mwparserfromhell = e
try:
import langdetect
except ImportError:
langdetect = None
Later it examines
if isinstance(mwparserfromhell, Exception):
raise mwparserfromhell
Why is it good to delay in such complicated way? Why does not handle the
script the error at once?
I want to invent a script dealing with tables. It could be used directly
with simple arguments and imported in order to use advanced functions. What
is the good way of handling import error? I don't like this mismatch that
mwparserfromhell is either a module or an Exception, is there any advantage
of this solution?
--
Bináris
At left of articles there is a page information link, which shows recent
page views on a diagram.
Can I get these page views numerically by Pywikibot?
--
Bináris