def __replaceGenerator(self): """ Removes a previous 'generator' stance and declares TOOLSVERSION as the new generator. Section 3.1.1: The application MUST NOT export the original identifier belonging to the application that created the document. """ for m in self.meta.childNodes[:]: if m.qname == (METANS, u'generator'): self.meta.removeChild(m) self.meta.addElement(meta.Generator(text=TOOLSVERSION))
def __init__(self, mimetype, add_generator=True): """ the constructor @param mimetype a unicode string @param add_generator a boolean """ assert (type(mimetype) == type(u"")) assert (isinstance(add_generator, True .__class__)) self.mimetype = mimetype self.childobjects = [] self._extra = [] self.folder = u"" # Always empty for toplevel documents self.topnode = Document(mimetype=self.mimetype) self.topnode.ownerDocument = self self.clear_caches() self.Pictures = {} self.meta = Meta() self.topnode.addElement(self.meta) if add_generator: self.meta.addElement(meta.Generator(text=TOOLSVERSION)) self.scripts = Scripts() self.topnode.addElement(self.scripts) self.fontfacedecls = FontFaceDecls() self.topnode.addElement(self.fontfacedecls) self.settings = Settings() self.topnode.addElement(self.settings) self.styles = Styles() self.topnode.addElement(self.styles) self.automaticstyles = AutomaticStyles() self.topnode.addElement(self.automaticstyles) self.masterstyles = MasterStyles() self.topnode.addElement(self.masterstyles) self.body = Body() self.topnode.addElement(self.body)