-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Document.add_picture Fails on Subsequent Pictures #4
Copy link
Copy link
Closed
Description
When inserting pictures into a document, the first picture works just fine, as shown by the example, etc. This problem arises when you go to add a second picture. The second picture addition triggers the sha1 function in the ImagePart class in docx/parts/image.py. This function is currently:
@property
def sha1(self):
"""
SHA1 hash digest of the blob of this image part.
"""
raise NotImplementedErrorWhich is clearly not very helpful. The fix is quite simple, just add the same sha1 functionality from the Image class in the same file. The resulting routine is:
@property
def sha1(self):
"""
SHA1 hash digest of the blob of this image part.
"""
return hashlib.sha1(self.blob).hexdigest()Note that this should also probably be a lazyproperty instead of property, but either will work.
I experienced this error under Python 3.3.0 and 3.3.3, but it seems it will happen under any version.
Regards,
Steve
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels