deconflict merge
This commit is contained in:
commit
7a078511fa
1 changed files with 6 additions and 10 deletions
|
@ -9,12 +9,12 @@ except ImportError:
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import urllib.request
|
||||||
import zipfile
|
import zipfile
|
||||||
from distutils.dir_util import copy_tree
|
from distutils.dir_util import copy_tree
|
||||||
|
from io import BytesIO
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
import requests
|
|
||||||
|
|
||||||
# --- Globals ----------------------------------------------
|
# --- Globals ----------------------------------------------
|
||||||
PLUGINS = """
|
PLUGINS = """
|
||||||
auto-pairs https://github.com/jiangmiao/auto-pairs
|
auto-pairs https://github.com/jiangmiao/auto-pairs
|
||||||
|
@ -73,16 +73,12 @@ SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked_cache")
|
||||||
|
|
||||||
|
|
||||||
def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir):
|
def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir):
|
||||||
temp_zip_path = path.join(temp_dir, plugin_name)
|
|
||||||
|
|
||||||
# Download and extract file in temp dir
|
# Download and extract file in temp dir
|
||||||
req = requests.get(zip_path)
|
with urllib.request.urlopen(zip_path) as req:
|
||||||
open(temp_zip_path, "wb").write(req.content)
|
zip_f = zipfile.ZipFile(BytesIO(req.read()))
|
||||||
|
|
||||||
zip_f = zipfile.ZipFile(temp_zip_path)
|
|
||||||
zip_f.extractall(temp_dir)
|
zip_f.extractall(temp_dir)
|
||||||
|
|
||||||
content_disp = req.headers.get("Content-Disposition")
|
content_disp = req.headers.get("Content-Disposition")
|
||||||
|
|
||||||
filename = re.findall("filename=(.+).zip", content_disp)[0]
|
filename = re.findall("filename=(.+).zip", content_disp)[0]
|
||||||
plugin_temp_path = path.join(temp_dir, path.join(temp_dir, filename))
|
plugin_temp_path = path.join(temp_dir, path.join(temp_dir, filename))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue