Commit 03e2a1f8 authored by Ivan Tyagov's avatar Ivan Tyagov

Merge branch 'erp5-data-notebook' into 'master'

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.

Please review: @Tyagov 

See merge request !53
parents d7392ffb 20b03bf6
......@@ -7,6 +7,7 @@ from OFS.Image import Image as OFSImage
import sys
import ast
import types
import inspect
mime_type = 'text/plain'
# IPython expects 2 status message - 'ok', 'error'
......@@ -222,9 +223,11 @@ def Base_displayImage(self, image_object=None):
if isinstance(image_object, OFSImage):
figdata = base64.b64encode(image_object.getData())
mime_type = image_object.getContentType()
else:
# For matplotlib objects
# XXX: Needs refactoring to handle cases
# Ensure that the object we are taking as `image_object` is basically a
# 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
figfile = StringIO()
......
......@@ -46,12 +46,12 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 54, 2: Using the global statement (global-statement)</string>
<string>W: 94, 8: Use of exec (exec-used)</string>
<string>W:118, 8: Use of exec (exec-used)</string>
<string>W:124, 8: Use of exec (exec-used)</string>
<string>W:219, 4: Using the global statement (global-statement)</string>
<string>W:317, 2: Using the global statement (global-statement)</string>
<string>W: 55, 2: Using the global statement (global-statement)</string>
<string>W: 95, 8: Use of exec (exec-used)</string>
<string>W:119, 8: Use of exec (exec-used)</string>
<string>W:125, 8: Use of exec (exec-used)</string>
<string>W:220, 4: Using the global statement (global-statement)</string>
<string>W:320, 2: Using the global statement (global-statement)</string>
</tuple>
</value>
</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