/usr/bin/odf2mht is in python-odf 0.9.6-2.
This file is owned by root:root, with mode 0o755.
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 | #! /usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2006 Søren Roug, European Environment Agency
#
# This is free software. You may redistribute it under the terms
# of the Apache license and the GNU General Public License Version
# 2 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Contributor(s):
#
from odf.odf2xhtml import ODF2XHTML
import zipfile
import sys
#from time import gmtime, strftime
from email.MIMEMultipart import MIMEMultipart
from email.MIMENonMultipart import MIMENonMultipart
from email.MIMEText import MIMEText
from email import Encoders
if len(sys.argv) != 2:
sys.stderr.write("Usage: %s inputfile\n" % sys.argv[0])
sys.exit(1)
suffices = {
'wmf':('image','x-wmf'),
'png':('image','png'),
'gif':('image','gif'),
'jpg':('image','jpeg'),
'jpeg':('image','jpeg')
}
msg = MIMEMultipart('related',type="text/html")
# msg['Subject'] = 'Subject here'
# msg['From'] = '<Saved by ODT2MHT>'
# msg['Date'] = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
msg.preamble = 'This is a multi-part message in MIME format.'
msg.epilogue = ''
odhandler = ODF2XHTML()
result = odhandler.odf2xhtml(sys.argv[1]).encode('us-ascii','xmlcharrefreplace')
htmlpart = MIMEText(result,'html','us-ascii')
htmlpart['Content-Location'] = 'index.html'
msg.attach(htmlpart)
z = zipfile.ZipFile(sys.argv[1])
for file in z.namelist():
if file[0:9] == 'Pictures/':
suffix = file[file.rfind(".")+1:]
main,sub = suffices.get(suffix,('application','octet-stream'))
img = MIMENonMultipart(main,sub)
img.set_payload(z.read(file))
img['Content-Location'] = "" + file
Encoders.encode_base64(img)
msg.attach(img)
z.close()
print msg.as_string()
|