Skip to content

Commit

Permalink
Fixed urllib python 3 reference
Browse files Browse the repository at this point in the history
  • Loading branch information
MSeal committed Apr 2, 2017
1 parent 816b827 commit 5d88b7e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tar_download.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import os
import sys
import urllib
import tarfile
try:
from urllib import urlretrieve
except ImportError:
from urllib.request import urlretrieve

def file_name_from_url(url, directory=None):
file_name = url.split('/')[-1]
Expand All @@ -16,7 +19,7 @@ def download_tar(url, directory=None):
file_name = file_name_from_url(url, directory)
print("Downloading {} to {}".format(url, file_name))
sys.stdout.flush()
urllib.urlretrieve(url, file_name)
urlretrieve(url, file_name)

def extract_contents(file_name, destination='.'):
if not os.path.exists(destination):
Expand Down

0 comments on commit 5d88b7e

Please sign in to comment.