It's not hard to do this in python directly either, see the attached branch (not heavily tested, but since getting this exactly right isn't critical it may be good enough).
It's not hard to do this in python directly either, see the attached branch (not heavily tested, but since getting this exactly right isn't critical it may be good enough).