Last active
May 12, 2016 00:00
-
-
Save tbreeds/7f09e506fafbfbde0ffe83e8c61b2741 to your computer and use it in GitHub Desktop.
Grovel around in the pypi simple API and generate Apache rewrite rules to get to the non-std. packagenames
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import contextlib | |
import HTMLParser | |
from packaging.utils import canonicalize_name | |
import urllib | |
class SimpleParser(HTMLParser.HTMLParser): | |
def handle_data(self, data): | |
name = data.rstrip().lstrip() | |
pep_name = canonicalize_name(name) | |
if name and name != pep_name: | |
print("RewriteRule %s %s" % (pep_name, name)) | |
SimpleParser().feed(urllib.urlopen('http://pypi.python.org/simple').read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@r1chardj0n3s laughed at me.
It didn't handle errors very well anyway ;P