##// END OF EJS Templates
remove python 2.x specific urllib2's functions
Srinivas Reddy Thatiparthy -
Show More
@@ -516,10 +516,8 b' class DisplayObject(object):'
516 516 self.data = f.read()
517 517 elif self.url is not None:
518 518 try:
519 try:
520 from urllib.request import urlopen # Py3
521 except ImportError:
522 from urllib2 import urlopen
519 # Deferred import
520 from urllib.request import urlopen
523 521 response = urlopen(self.url)
524 522 self.data = response.read()
525 523 # extract encoding from header, if there is one:
@@ -155,12 +155,8 b' class ExtensionManager(Configurable):'
155 155 copy = copyfile
156 156 else:
157 157 # Deferred imports
158 try:
159 from urllib.parse import urlparse # Py3
160 from urllib.request import urlretrieve
161 except ImportError:
162 from urlparse import urlparse
163 from urllib import urlretrieve
158 from urllib.parse import urlparse
159 from urllib.request import urlretrieve
164 160 src_filename = urlparse(url).path.split('/')[-1]
165 161 copy = urlretrieve
166 162
@@ -3124,10 +3124,7 b' class InteractiveShell(SingletonConfigurable):'
3124 3124 except UnicodeDecodeError:
3125 3125 if not py_only :
3126 3126 # Deferred import
3127 try:
3128 from urllib.request import urlopen # Py3
3129 except ImportError:
3130 from urllib import urlopen
3127 from urllib.request import urlopen
3131 3128 response = urlopen(target)
3132 3129 return response.read().decode('latin1')
3133 3130 raise ValueError(("'%s' seem to be unreadable.") % target)
@@ -263,10 +263,9 b' class YouTubeVideo(IFrame):'
263 263 super(YouTubeVideo, self).__init__(src, width, height, **kwargs)
264 264
265 265 def _repr_jpeg_(self):
266 try:
267 from urllib.request import urlopen # Py3
268 except ImportError:
269 from urllib2 import urlopen
266 # Deferred import
267 from urllib.request import urlopen
268
270 269 try:
271 270 return urlopen("https://img.youtube.com/vi/{id}/hqdefault.jpg".format(id=self.id)).read()
272 271 except IOError:
General Comments 0
You need to be logged in to leave comments. Login now