fix boundary (add -- prefix) for MHT documents
This commit is contained in:
parent
9b09d91f16
commit
da946ff560
1 changed files with 3 additions and 4 deletions
|
@ -37,7 +37,7 @@ class MHTFile(object):
|
||||||
encoding = 'Windows-1252'
|
encoding = 'Windows-1252'
|
||||||
bodyMarker = 'lxdoc_body'
|
bodyMarker = 'lxdoc_body'
|
||||||
foldernameSuffix = 'Dateien'
|
foldernameSuffix = 'Dateien'
|
||||||
indexes = dict(body=2, filelist=-2)
|
indexes = dict(body=1, filelist=-2)
|
||||||
|
|
||||||
path = documentName = None
|
path = documentName = None
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class MHTFile(object):
|
||||||
def __init__(self, data, body):
|
def __init__(self, data, body):
|
||||||
self.data = data
|
self.data = data
|
||||||
self.msg = email.message_from_string(data)
|
self.msg = email.message_from_string(data)
|
||||||
self.boundary = self.msg.get_boundary()
|
self.boundary = '--' + self.msg.get_boundary()
|
||||||
self.parts = data.split(self.boundary)
|
self.parts = data.split(self.boundary)
|
||||||
self.body = body
|
self.body = body
|
||||||
self.htmlDoc = HTMLDoc(body)
|
self.htmlDoc = HTMLDoc(body)
|
||||||
|
@ -61,8 +61,7 @@ class MHTFile(object):
|
||||||
for idx, part in enumerate(self.msg.walk()):
|
for idx, part in enumerate(self.msg.walk()):
|
||||||
docPath = part['Content-Location']
|
docPath = part['Content-Location']
|
||||||
contentType = part.get_content_type()
|
contentType = part.get_content_type()
|
||||||
#print '***', idx, docPath, contentType
|
if idx == self.indexes['body']:
|
||||||
if idx == self.indexes['body'] - 1:
|
|
||||||
self.path, docname = os.path.split(docPath)
|
self.path, docname = os.path.split(docPath)
|
||||||
self.documentName, ext = os.path.splitext(docname)
|
self.documentName, ext = os.path.splitext(docname)
|
||||||
if contentType.startswith('image/'):
|
if contentType.startswith('image/'):
|
||||||
|
|
Loading…
Add table
Reference in a new issue