Posts tagged: python

semver will not save you

https://hynek.me/articles/semver-will-not-save-you/ matches up exactly with how I feel about versioning and semver. Semver is great, but at the end of the day it's a best effort by maintainers and not perfect. It's also not applicable to literally everything and shouldn't be used as such.

Speeding up Toolforge tools with Redis

Over the past two weeks I significantly sped up two of my Toolforge tools by using Redis, a key-value database. The two tools, checker and shorturls were slow for different reasons, but now respond instantaneously. Note that I didn't do any proper benchmarking, it's just noticably faster. If you're not…

mwparser on wheels

mwparserfromhell is now fully on wheels. Well...not those wheels - Python wheels! If you're not familiar with it, mwparserfromhell is a powerful parser for MediaWiki's wikitext syntax with an API that's really convenient for bots to use. It is primarily developed and maintained by Earwig, who originally wrote it for…

Trying pytest

I finally had the opportunity to give pytest a real try (I'm porting tests from ruby to Python), and it's amazing! Waaay better than unittest/nosetests. I especially liked the parametrization feature, which I think PHPUnit could probably benefit from. Specifically, I like how I could specify two parameters separately, and…

Parsing PHP in Python

Today I found a legitimate use for https://github.com/danielquinn/python-phpPython's default ConfigParser requires each ini file to have a [section]. PHP doesn't, so to read a PHP-formatted INI file in Python requires some kind of custom parser (maybe it would be possible to extend ConfigParser?), where the python-php project came in handy.…

Thoughts on SQLAlchemy

I've recently been using SQLAlchemy's ORM for a Python web app I'm developing. I really like the idea of declaring tables using a class, which provides you with an object class too.For querying, I'm still a bit undecided. I like .filter_by(), .first(), and .all(), but I'm worried that losing visibility…

Requiring HTTPS for my Toolforge tools

My Toolforge (formerly "Tool Labs") tools will now start requiring HTTPS, and redirecting any HTTP traffic. It's a little bit of common code for each tool, so I put it in a shared "toolforge" library. from flask import Flask import toolforge app = Flask(__name__) app.before_request(toolforge.redirect_to_https) And that's it! Your tool…

Pelican theming

Pelican theming isn't actually that difficult. It's based on jinja2 templates, and there were enough themes already out there to pick one and just start forking it. I'm not too happy that they want themes installed into your system python path (or a virtualenv in my case), but since you…