import htmlentitydefs from xml.sax.saxutils import escape def valueOrExec(value): if hasattr(value, 'im_func'): return value() return value def convert_to_ents(txt): buf = '' for c in txt: mat = '' for x in htmlentitydefs.entitydefs: a = htmlentitydefs.entitydefs[x].decode('iso-8859-1') if c == a: mat = x continue if mat: buf += '&%s;' % mat else: buf += c return escape(buf) def xhtml(entries, conf={}): """ package results as RSS """ formatted = u"""' return formatted.encode('utf-8')