view MoinMoin/filter/application_vnd_sun_xml_writer.py @ 454:e099072bba24

changed filters to use mimetypes imported from: moin--main--1.5--patch-458
author Thomas Waldmann <tw@waldmann-edv.de>
date Sat, 25 Feb 2006 08:11:57 +0000
parents
children 957d482215ac
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - OpenOffice SXW Filter

    @copyright: 2006 by ThomasWaldmann MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.
"""

import re, sys
import zipfile

rx_stripxml = re.compile("<[^>]*?>", re.DOTALL|re.MULTILINE)

def execute(indexobj, filename):
        try:
            zf = zipfile.ZipFile(filename, "r")
            data = zf.read("content.xml")
            zf.close()
            data = " ".join(rx_stripxml.sub(" ", data).split())
        except RuntimeError, err:
            indexobj.request.log(str(err))
            data = ""
        return data.decode('utf-8')