work in progress: use MHT files for generation of Word documents
This commit is contained in:
parent
5b1deed224
commit
6a443d549c
4 changed files with 4462 additions and 0 deletions
|
@ -8,3 +8,33 @@ docgen - Document Generation from Result Sets and XML Structures
|
|||
>>> from cybertools.docgen.base import WordDocument
|
||||
>>> doc = WordDocument(None, TestRequest)
|
||||
|
||||
|
||||
Working with MHT Files
|
||||
======================
|
||||
|
||||
>>> import os
|
||||
>>> basePath = os.path.join(os.path.dirname(__file__), 'testing')
|
||||
|
||||
>>> path = os.path.join(basePath, 'test_doc.mht')
|
||||
>>> f = open(path, 'rt')
|
||||
>>> data = f.read()
|
||||
>>> f.close()
|
||||
|
||||
>>> imagePath = os.path.join(basePath, 'test_image.jpg')
|
||||
|
||||
>>> from cybertools.docgen.mht import MHTFile
|
||||
>>> document = MHTFile(data)
|
||||
>>> document.addImage(imagePath)
|
||||
|
||||
>>> body = '''
|
||||
... '''
|
||||
|
||||
>>> document.setBody(body)
|
||||
|
||||
>>> outPath = os.path.join(basePath, 'out_doc.mht')
|
||||
>>> f = open(outPath, 'wt')
|
||||
>>> f.write(document.data)
|
||||
>>> f.close()
|
||||
|
||||
>>> os.unlink(outPath)
|
||||
|
||||
|
|
0
docgen/document.mht
Executable file → Normal file
0
docgen/document.mht
Executable file → Normal file
33
docgen/mht.py
Normal file
33
docgen/mht.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
"""
|
||||
Working with MHT Files.
|
||||
"""
|
||||
|
||||
class MHTFile(object):
|
||||
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
def addImage(self, imagePath):
|
||||
pass
|
||||
|
||||
def setBody(self, body):
|
||||
pass
|
||||
|
4399
docgen/testing/test_doc.mht
Normal file
4399
docgen/testing/test_doc.mht
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue