annotate MoinMoin/filter/text_xml.py @ 470:957d482215ac

lupy: some filters, update mode imported from: moin--main--1.5--patch-474
author Thomas Waldmann <tw@waldmann-edv.de>
date Mon, 13 Mar 2006 19:31:36 +0000
parents
children bb2e053067fb
rev   line source
470
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
2 """
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
3 MoinMoin - text/xml file Filter
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
4
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
5 @copyright: 2006 by ThomasWaldmann MoinMoin:ThomasWaldmann
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
7 """
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
8
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
9 import re
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
10 from MoinMoin.filter.text import execute as textfilter
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
11
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
12 rx_stripxml = re.compile("<[^>]*?>", re.DOTALL|re.MULTILINE)
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
13
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
14 def execute(indexobj, filename):
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
15 data = textfilter(indexobj, filename)
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
16 try:
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
17 data = " ".join(rx_stripxml.sub(" ", data).split())
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
18 except RuntimeError, err:
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
19 indexobj.request.log(str(err))
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
20 data = ""
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
21 return data
957d482215ac lupy: some filters, update mode
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
22