Show More
@@ -14,6 +14,7 b' import sys' | |||||
14 | import warnings |
|
14 | import warnings | |
15 | from copy import deepcopy |
|
15 | from copy import deepcopy | |
16 | from os.path import splitext |
|
16 | from os.path import splitext | |
|
17 | from pathlib import Path, PurePath | |||
17 |
|
18 | |||
18 | from IPython.utils.py3compat import cast_unicode |
|
19 | from IPython.utils.py3compat import cast_unicode | |
19 | from IPython.testing.skipdoctest import skip_doctest |
|
20 | from IPython.testing.skipdoctest import skip_doctest | |
@@ -594,6 +595,9 b' class DisplayObject(object):' | |||||
594 | metadata : dict |
|
595 | metadata : dict | |
595 | Dict of metadata associated to be the object when displayed |
|
596 | Dict of metadata associated to be the object when displayed | |
596 | """ |
|
597 | """ | |
|
598 | if isinstance(data, (Path, PurePath)): | |||
|
599 | data = str(data) | |||
|
600 | ||||
597 | if data is not None and isinstance(data, str): |
|
601 | if data is not None and isinstance(data, str): | |
598 | if data.startswith('http') and url is None: |
|
602 | if data.startswith('http') and url is None: | |
599 | url = data |
|
603 | url = data | |
@@ -864,6 +868,9 b' class JSON(DisplayObject):' | |||||
864 |
|
868 | |||
865 | @data.setter |
|
869 | @data.setter | |
866 | def data(self, data): |
|
870 | def data(self, data): | |
|
871 | if isinstance(data, (Path, PurePath)): | |||
|
872 | data = str(data) | |||
|
873 | ||||
867 | if isinstance(data, str): |
|
874 | if isinstance(data, str): | |
868 | if getattr(self, 'filename', None) is None: |
|
875 | if getattr(self, 'filename', None) is None: | |
869 | warnings.warn("JSON expects JSONable dict or list, not JSON strings") |
|
876 | warnings.warn("JSON expects JSONable dict or list, not JSON strings") | |
@@ -1134,6 +1141,9 b' class Image(DisplayObject):' | |||||
1134 | Image(url='http://www.google.fr/images/srpr/logo3w.png') |
|
1141 | Image(url='http://www.google.fr/images/srpr/logo3w.png') | |
1135 |
|
1142 | |||
1136 | """ |
|
1143 | """ | |
|
1144 | if isinstance(data, (Path, PurePath)): | |||
|
1145 | data = str(data) | |||
|
1146 | ||||
1137 | if filename is not None: |
|
1147 | if filename is not None: | |
1138 | ext = self._find_ext(filename) |
|
1148 | ext = self._find_ext(filename) | |
1139 | elif url is not None: |
|
1149 | elif url is not None: | |
@@ -1338,6 +1348,9 b' class Video(DisplayObject):' | |||||
1338 | Video('path/to/video.mp4', embed=True) |
|
1348 | Video('path/to/video.mp4', embed=True) | |
1339 | Video(b'raw-videodata', embed=True) |
|
1349 | Video(b'raw-videodata', embed=True) | |
1340 | """ |
|
1350 | """ | |
|
1351 | if isinstance(data, (Path, PurePath)): | |||
|
1352 | data = str(data) | |||
|
1353 | ||||
1341 | if url is None and isinstance(data, str) and data.startswith(('http:', 'https:')): |
|
1354 | if url is None and isinstance(data, str) and data.startswith(('http:', 'https:')): | |
1342 | url = data |
|
1355 | url = data | |
1343 | data = None |
|
1356 | data = None |
General Comments 0
You need to be logged in to leave comments.
Login now