#!/usr/bin/env python """Given a url on the command line, transforms it to go through UCT's ezproxy. Useful for accessing online journals. Probably buggy.""" import re import sys urlpattern = re.compile("""(?P[a-z]+://)? (?P[^:/]+) (?::(?P\d+))? (?P.*)""", re.VERBOSE) match = urlpattern.match(sys.argv[1]) print """http://%(port)s-%(host)s.ezproxy.uct.ac.za:2048%(path)s""" % \ {'port': match.group('port') or 80, 'host': match.group('host'), 'path': match.group('path')}