shortcut for returning metadata with shape information, if defined
(self, always_both=False)
| 1288 | return {'text/html': self._repr_html_()} |
| 1289 | |
| 1290 | def _data_and_metadata(self, always_both=False): |
| 1291 | """shortcut for returning metadata with shape information, if defined""" |
| 1292 | try: |
| 1293 | b64_data = b2a_base64(self.data).decode('ascii') |
| 1294 | except TypeError: |
| 1295 | raise FileNotFoundError( |
| 1296 | "No such file or directory: '%s'" % (self.data)) |
| 1297 | md = {} |
| 1298 | if self.metadata: |
| 1299 | md.update(self.metadata) |
| 1300 | if self.width: |
| 1301 | md['width'] = self.width |
| 1302 | if self.height: |
| 1303 | md['height'] = self.height |
| 1304 | if self.unconfined: |
| 1305 | md['unconfined'] = self.unconfined |
| 1306 | if md or always_both: |
| 1307 | return b64_data, md |
| 1308 | else: |
| 1309 | return b64_data |
| 1310 | |
| 1311 | def _repr_png_(self): |
| 1312 | if self.embed and self.format == self._FMT_PNG: |
no test coverage detected