"""Filter the output by running it through HTML Tidy."""
__docformat__ = "restructuredtext"
# Created: Mon Feb 9 10:57:11 PST 2004
# Author: Shannon -jj Behrens
# Email: jjinux@users.sourceforge.net
#
# Copyright (c) Shannon -jj Behrens. All rights reserved.
from popen2 import popen2
from aquarium.util.AquariumClass import AquariumClass
class Tidy(AquariumClass):
"""Filter the output by running it through `HTML Tidy`_.
This is probably prohibitively expensive, but it sure is a cool proof of
concept!
The following attributes are used:
tidy
This is the name (or path) of the HTML Tidy executable plus args.
.. _HTML Tidy: http://tidy.sf.net
"""
tidy = "tidy -q -wrap 79 --indent auto"
def __call__(self, str):
"""Filter the output by running it through HTML Tidy."""
fin, fout = popen2(self.tidy)
fout.write(str)
fout.close()
str = fin.read()
fin.close()
return str
|