Commit 20b03bf6 authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_data_notebook : Check for matplotlib.pyplot module object in Base_displayImage

The external method Base_displayImage displays images of two kind: plot and OFS image
saved in erp5. We had earlier checks for erp5 images but no check to for matplotlib
plot images.
parent 145b45c6
...@@ -7,6 +7,7 @@ from OFS.Image import Image as OFSImage ...@@ -7,6 +7,7 @@ from OFS.Image import Image as OFSImage
import sys import sys
import ast import ast
import types import types
import inspect
mime_type = 'text/plain' mime_type = 'text/plain'
# IPython expects 2 status message - 'ok', 'error' # IPython expects 2 status message - 'ok', 'error'
...@@ -222,9 +223,11 @@ def Base_displayImage(self, image_object=None): ...@@ -222,9 +223,11 @@ def Base_displayImage(self, image_object=None):
if isinstance(image_object, OFSImage): if isinstance(image_object, OFSImage):
figdata = base64.b64encode(image_object.getData()) figdata = base64.b64encode(image_object.getData())
mime_type = image_object.getContentType() mime_type = image_object.getContentType()
else:
# For matplotlib objects # Ensure that the object we are taking as `image_object` is basically a
# XXX: Needs refactoring to handle cases # Matplotlib.pyplot module object from which we are seekign the data of the
# plot .
elif inspect.ismodule(image_object) and image_object.__name__=="matplotlib.pyplot":
# Create a ByteFile on the server which would be used to save the plot # Create a ByteFile on the server which would be used to save the plot
figfile = StringIO() figfile = StringIO()
......
...@@ -46,12 +46,12 @@ ...@@ -46,12 +46,12 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W: 54, 2: Using the global statement (global-statement)</string> <string>W: 55, 2: Using the global statement (global-statement)</string>
<string>W: 94, 8: Use of exec (exec-used)</string> <string>W: 95, 8: Use of exec (exec-used)</string>
<string>W:118, 8: Use of exec (exec-used)</string> <string>W:119, 8: Use of exec (exec-used)</string>
<string>W:124, 8: Use of exec (exec-used)</string> <string>W:125, 8: Use of exec (exec-used)</string>
<string>W:219, 4: Using the global statement (global-statement)</string> <string>W:220, 4: Using the global statement (global-statement)</string>
<string>W:317, 2: Using the global statement (global-statement)</string> <string>W:320, 2: Using the global statement (global-statement)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment