def contenttypes(self): E = ElementMaker(namespace=self.namespace.namespaces['ct'], nsmap={None:self.namespace.namespaces['ct']}) types = E.Types() for partname, mt in iteritems({ "/word/footnotes.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", "/word/document.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", "/word/numbering.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", "/word/styles.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", "/word/endnotes.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml", "/word/settings.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", "/word/theme/theme1.xml": "application/vnd.openxmlformats-officedocument.theme+xml", "/word/fontTable.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml", "/word/webSettings.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml", "/docProps/core.xml": "application/vnd.openxmlformats-package.core-properties+xml", "/docProps/app.xml": "application/vnd.openxmlformats-officedocument.extended-properties+xml", }): types.append(E.Override(PartName=partname, ContentType=mt)) added = {'png', 'gif', 'jpeg', 'jpg', 'svg', 'xml'} for ext in added: types.append(E.Default(Extension=ext, ContentType=guess_type('a.'+ext)[0])) for ext, mt in iteritems({ "rels": "application/vnd.openxmlformats-package.relationships+xml", "odttf": "application/vnd.openxmlformats-officedocument.obfuscatedFont", }): added.add(ext) types.append(E.Default(Extension=ext, ContentType=mt)) for fname in self.images: ext = fname.rpartition(os.extsep)[-1] if ext not in added: added.add(ext) mt = guess_type('a.' + ext)[0] if mt: types.append(E.Default(Extension=ext, ContentType=mt)) return xml2str(types)
def contenttypes(self): E = ElementMaker(namespace=namespaces['ct'], nsmap={None: namespaces['ct']}) types = E.Types() for partname, mt in { "/word/footnotes.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", "/word/document.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", "/word/numbering.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", "/word/styles.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", "/word/endnotes.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml", "/word/settings.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", "/word/theme/theme1.xml": "application/vnd.openxmlformats-officedocument.theme+xml", "/word/fontTable.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml", "/word/webSettings.xml": "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml", "/docProps/core.xml": "application/vnd.openxmlformats-package.core-properties+xml", "/docProps/app.xml": "application/vnd.openxmlformats-officedocument.extended-properties+xml", }.iteritems(): types.append(E.Override(PartName=partname, ContentType=mt)) added = {'png', 'gif', 'jpeg', 'jpg', 'svg', 'xml'} for ext in added: types.append( E.Default(Extension=ext, ContentType=guess_type('a.' + ext)[0])) for ext, mt in { "rels": "application/vnd.openxmlformats-package.relationships+xml", "odttf": "application/vnd.openxmlformats-officedocument.obfuscatedFont", }.iteritems(): added.add(ext) types.append(E.Default(Extension=ext, ContentType=mt)) # TODO: Iterate over all resources and add mimetypes for any that are # not already added return xml2str(types)