Created
March 13, 2009 06:43
-
-
Save khafatech/78459 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
Generate graph of prerequisites. | |
http://www.csupomona.edu/~cs/student/undergrad.shtml | |
""" | |
import urllib | |
import re | |
data = urllib.urlopen('http://www.csupomona.edu/~cs/student/undergrad.shtml').read() | |
d = {} | |
for c in re.finditer(r'name="(.*?)"(.*?)</block', data, re.M|re.S): | |
d[c.group(1)] = re.findall(r'#(.*?)"', c.group(2)) | |
# generate graph | |
outf = open('classes.dot', 'w') | |
print >> outf, 'digraph classes {' | |
for k, v in d.items(): | |
if v: | |
for preq in v: print >> outf, '%s -> %s;' %(preq, k) | |
else: | |
print >> outf, '%s;' % k | |
print >> outf, '}' | |
outf.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment