/usr/share/pyshared/MoinMoin/wikixml/util.py is in python-moinmoin 1.9.3-1ubuntu2.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # -*- coding: iso-8859-1 -*-
"""
MoinMoin - XML Utilities
@copyright: 2001 Juergen Hermann <jh@web.de>
@license: GNU GPL, see COPYING for details.
"""
from xml.sax import saxutils
from MoinMoin import config
class XMLGenerator(saxutils.XMLGenerator):
default_xmlns = {}
def __init__(self, out):
saxutils.XMLGenerator.__init__(self, out=out, encoding=config.charset)
self.xmlns = self.default_xmlns
def _build_tag(self, tag):
if type(tag) == type(""):
qname = tag
tag = (None, tag)
else:
qname = "%s:%s" % tag
tag = (self.xmlns[tag[0]], tag[1])
return tag, qname
def startNode(self, tag, attr={}):
tag, qname = self._build_tag(tag)
self.startElementNS(tag, qname, attr)
def endNode(self, tag):
tag, qname = self._build_tag(tag)
self.endElementNS(tag, qname)
def simpleNode(self, tag, value, attr={}):
self.startNode(tag, attr)
if value:
self.characters(value)
self.endNode(tag)
def startDocument(self):
saxutils.XMLGenerator.startDocument(self)
for prefix, uri in self.xmlns.items():
self.startPrefixMapping(prefix or None, uri)
def endDocument(self):
for prefix in self.xmlns:
self.endPrefixMapping(prefix or None)
saxutils.XMLGenerator.endDocument(self)
class RssGenerator(XMLGenerator):
default_xmlns = {
None: "http://purl.org/rss/1.0/",
'rdf': "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
'xlink': "http://www.w3.org/1999/xlink",
'dc': "http://purl.org/dc/elements/1.1/",
'wiki': "http://purl.org/rss/1.0/modules/wiki/",
}
def __init__(self, out):
XMLGenerator.__init__(self, out=out)
def startDocument(self):
XMLGenerator.startDocument(self)
self.startElementNS((self.xmlns['rdf'], 'RDF'), 'rdf:RDF', {})
def endDocument(self):
self.endElementNS((self.xmlns['rdf'], 'RDF'), 'rdf:RDF')
XMLGenerator.endDocument(self)
|