Archive for the ‘Python’ Category

Merge Trac tickets 0

Below (open post to see) is a quickly hacked together script to copy tickets from one Trac database to another. It’s sets a new component on each ticket and removes a milestone, if set, so if you don’t want that, you’ll have to change that part (it’s pretty easy). Public domain, use at your own [...]

Python: What I learned today 0

Actually, the title of this post should be Python: What I learned this week, as I’ve been trying to debug this problem for at least that long. What problem, you ask? First let me say that I’m writing this down mostly as a recap and for my own reference, but if it can help a [...]

Python: Normalize whitespace 0

While we’re at it, another Python snippet. While parsing websites, I also needed to normalize extracted blocks of text with respect to whitespace. The function below does exactly that. It Replaces multiple whitespace characters with a single one. Completely removes spaces at the beginning and at the end of a line. Note that it is [...]

htmlspecialchars() in Python 0

I was just looking for a way to unescape html entities in Python. Turns out this is not quite as simple as you might expect. Not as simple as PHP’s htmlspecialchars(), anyway. There is a translation table in htmlentitydefs, but you have to do the actual work yourself. Also, while that works for named entities, [...]