#format python

"""
	IncludeUrlContent macro for MoinMoin
	
	by Erin Mulder (meara @ alumni.princeton.edu)
	
	This is a very simple macro that just grabs the content at the
	specified URL and includes it as raw HTML.   It doesn't strip
	out HTML header tags, so it's most useful for URLs that return
	HTML fragments rather than entire sites.  I'm using it to pull
        in fragments generated by automated processes (e.g. backup
        status, documentation exports, etc.).
	
	Usage: [[IncludeUrlContent(http://www.xyz.org/someFragment.html)]]
"""

import urllib

def execute(macro, url):
	try:
		return macro.formatter.rawHTML(urllib.urlopen(url).read())
	except IOError:
		return "Error reading " + url		
