##// END OF EJS Templates
Adding transient and update, change to dict for outputs
Henry Fredrick Schreiner -
Show More
@@ -129,10 +129,11 b' class CapturingDisplayPublisher(DisplayPublisher):'
129 transient = kwargs.pop('transient', None)
129 transient = kwargs.pop('transient', None)
130 update = kwargs.pop('update', False)
130 update = kwargs.pop('update', False)
131
131
132 self.outputs.append((data, metadata))
132 self.outputs.append({'data':data, 'metadata':metadata,
133 'transient':transient, 'update':update})
133
134
134 def clear_output(self, wait=False):
135 def clear_output(self, wait=False):
135 super(CapturingDisplayPublisher, self).clear_output(wait)
136 super(CapturingDisplayPublisher, self).clear_output(wait)
136
137
137 # empty the list, *do not* reassign a new list
138 # empty the list, *do not* reassign a new list
138 del self.outputs[:]
139 self.outputs.clear()
@@ -21,13 +21,16 b' else:'
21
21
22
22
23 class RichOutput(object):
23 class RichOutput(object):
24 def __init__(self, data=None, metadata=None):
24 def __init__(self, data=None, metadata=None, transient=None, update=False):
25 self.data = data or {}
25 self.data = data or {}
26 self.metadata = metadata or {}
26 self.metadata = metadata or {}
27 self.transient = transient or {}
28 self.update = update
27
29
28 def display(self):
30 def display(self):
29 from IPython.display import publish_display_data
31 from IPython.display import publish_display_data
30 publish_display_data(data=self.data, metadata=self.metadata)
32 publish_display_data(data=self.data, metadata=self.metadata,
33 transient=self.transient, update=self.update)
31
34
32 def _repr_mime_(self, mime):
35 def _repr_mime_(self, mime):
33 if mime not in self.data:
36 if mime not in self.data:
@@ -108,7 +111,7 b' class CapturedIO(object):'
108 for o in c.outputs:
111 for o in c.outputs:
109 display(o)
112 display(o)
110 """
113 """
111 return [ RichOutput(d, md) for d, md in self._outputs ]
114 return [ RichOutput(**kargs) for kargs in self._outputs ]
112
115
113 def show(self):
116 def show(self):
114 """write my output to sys.stdout/err as appropriate"""
117 """write my output to sys.stdout/err as appropriate"""
@@ -116,8 +119,8 b' class CapturedIO(object):'
116 sys.stderr.write(self.stderr)
119 sys.stderr.write(self.stderr)
117 sys.stdout.flush()
120 sys.stdout.flush()
118 sys.stderr.flush()
121 sys.stderr.flush()
119 for data, metadata in self._outputs:
122 for kargs in self._outputs:
120 RichOutput(data, metadata).display()
123 RichOutput(**kargs).display()
121
124
122 __call__ = show
125 __call__ = show
123
126
General Comments 0
You need to be logged in to leave comments. Login now