mirror of
https://github.com/amix/vimrc
synced 2025-02-28 14:12:51 +08:00
fix python 2 urllib/urllib2 compatibility
This commit is contained in:
parent
4a43316b67
commit
cc8744d6ca
@ -2,15 +2,20 @@ try:
|
||||
import concurrent.futures as futures
|
||||
except ImportError:
|
||||
try:
|
||||
import futures
|
||||
import futures # type: ignore
|
||||
except ImportError:
|
||||
futures = None
|
||||
futures = None # type: ignore
|
||||
|
||||
try:
|
||||
from urllib.request import urlopen
|
||||
except ImportError:
|
||||
from urllib2 import urlopen # type: ignore
|
||||
|
||||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
import urllib.request
|
||||
import zipfile
|
||||
from contextlib import closing
|
||||
from io import BytesIO
|
||||
from os import listdir, path
|
||||
|
||||
@ -73,7 +78,7 @@ SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked_cache")
|
||||
|
||||
def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir):
|
||||
# Download and extract file in temp dir
|
||||
with urllib.request.urlopen(zip_path) as req:
|
||||
with closing(urlopen(zip_path)) as req:
|
||||
zip_f = zipfile.ZipFile(BytesIO(req.read()))
|
||||
zip_f.extractall(temp_dir)
|
||||
content_disp = req.headers.get("Content-Disposition")
|
||||
|
Loading…
Reference in New Issue
Block a user