2015-06-06 15:12:17 +00:00
|
|
|
try:
|
|
|
|
import concurrent.futures as futures
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
import futures
|
|
|
|
except ImportError:
|
|
|
|
futures = None
|
|
|
|
|
2013-04-13 17:45:21 +00:00
|
|
|
import zipfile
|
|
|
|
import shutil
|
|
|
|
import tempfile
|
|
|
|
import requests
|
|
|
|
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
|
|
|
|
#--- Globals ----------------------------------------------
|
|
|
|
PLUGINS = """
|
2017-04-01 12:29:02 +00:00
|
|
|
ack.vim https://github.com/mileszs/ack.vim
|
2013-04-13 17:45:21 +00:00
|
|
|
bufexplorer https://github.com/corntrace/bufexplorer
|
2016-04-29 15:52:07 +00:00
|
|
|
ctrlp.vim https://github.com/ctrlpvim/ctrlp.vim
|
2013-04-13 17:45:21 +00:00
|
|
|
mayansmoke https://github.com/vim-scripts/mayansmoke
|
|
|
|
nerdtree https://github.com/scrooloose/nerdtree
|
2016-02-20 13:51:59 +00:00
|
|
|
nginx-vim-syntax https://github.com/evanmiller/nginx-vim-syntax
|
2013-04-13 17:45:21 +00:00
|
|
|
open_file_under_cursor.vim https://github.com/amix/open_file_under_cursor.vim
|
|
|
|
snipmate-snippets https://github.com/scrooloose/snipmate-snippets
|
|
|
|
tlib https://github.com/vim-scripts/tlib
|
|
|
|
vim-addon-mw-utils https://github.com/MarcWeber/vim-addon-mw-utils
|
|
|
|
vim-bundle-mako https://github.com/sophacles/vim-bundle-mako
|
|
|
|
vim-coffee-script https://github.com/kchmck/vim-coffee-script
|
|
|
|
vim-colors-solarized https://github.com/altercation/vim-colors-solarized
|
|
|
|
vim-indent-object https://github.com/michaeljsmith/vim-indent-object
|
|
|
|
vim-less https://github.com/groenewege/vim-less
|
|
|
|
vim-markdown https://github.com/tpope/vim-markdown
|
|
|
|
vim-pyte https://github.com/therubymug/vim-pyte
|
|
|
|
vim-snipmate https://github.com/garbas/vim-snipmate
|
|
|
|
vim-snippets https://github.com/honza/vim-snippets
|
|
|
|
vim-surround https://github.com/tpope/vim-surround
|
2013-04-14 15:48:31 +00:00
|
|
|
vim-expand-region https://github.com/terryma/vim-expand-region
|
2013-04-14 15:55:47 +00:00
|
|
|
vim-multiple-cursors https://github.com/terryma/vim-multiple-cursors
|
2013-11-16 19:45:48 +00:00
|
|
|
vim-fugitive https://github.com/tpope/vim-fugitive
|
2013-12-29 11:36:43 +00:00
|
|
|
goyo.vim https://github.com/junegunn/goyo.vim
|
2013-12-29 10:37:14 +00:00
|
|
|
vim-zenroom2 https://github.com/amix/vim-zenroom2
|
2014-02-08 10:05:16 +00:00
|
|
|
syntastic https://github.com/scrooloose/syntastic
|
2014-03-02 14:35:00 +00:00
|
|
|
vim-repeat https://github.com/tpope/vim-repeat
|
|
|
|
vim-commentary https://github.com/tpope/vim-commentary
|
2014-10-31 21:30:24 +00:00
|
|
|
vim-go https://github.com/fatih/vim-go
|
2015-07-13 10:22:46 +00:00
|
|
|
vim-gitgutter https://github.com/airblade/vim-gitgutter
|
|
|
|
gruvbox https://github.com/morhetz/gruvbox
|
2015-12-08 13:20:04 +00:00
|
|
|
vim-flake8 https://github.com/nvie/vim-flake8
|
2016-02-20 13:13:10 +00:00
|
|
|
vim-pug https://github.com/digitaltoad/vim-pug
|
2016-05-14 11:57:54 +00:00
|
|
|
vim-yankstack https://github.com/maxbrunsfeld/vim-yankstack
|
2016-05-14 12:22:57 +00:00
|
|
|
lightline.vim https://github.com/itchyny/lightline.vim
|
2013-04-13 17:45:21 +00:00
|
|
|
""".strip()
|
|
|
|
|
|
|
|
GITHUB_ZIP = '%s/archive/master.zip'
|
|
|
|
|
2014-02-08 10:05:16 +00:00
|
|
|
SOURCE_DIR = path.join(path.dirname(__file__), 'sources_non_forked')
|
2013-04-13 17:45:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
req = requests.get(zip_path)
|
|
|
|
open(temp_zip_path, 'wb').write(req.content)
|
|
|
|
|
|
|
|
zip_f = zipfile.ZipFile(temp_zip_path)
|
|
|
|
zip_f.extractall(temp_dir)
|
|
|
|
|
|
|
|
plugin_temp_path = path.join(temp_dir,
|
|
|
|
path.join(temp_dir, '%s-master' % plugin_name))
|
|
|
|
|
|
|
|
# Remove the current plugin and replace it with the extracted
|
|
|
|
plugin_dest_path = path.join(source_dir, plugin_name)
|
|
|
|
|
|
|
|
try:
|
|
|
|
shutil.rmtree(plugin_dest_path)
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
shutil.move(plugin_temp_path, plugin_dest_path)
|
|
|
|
|
2014-05-15 09:46:51 +00:00
|
|
|
print('Updated {0}'.format(plugin_name))
|
2013-04-13 17:45:21 +00:00
|
|
|
|
|
|
|
|
2015-06-06 15:12:17 +00:00
|
|
|
def update(plugin):
|
|
|
|
name, github_url = plugin.split(' ')
|
|
|
|
zip_path = GITHUB_ZIP % github_url
|
|
|
|
download_extract_replace(name, zip_path,
|
|
|
|
temp_directory, SOURCE_DIR)
|
|
|
|
|
|
|
|
|
2013-04-13 17:45:21 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
temp_directory = tempfile.mkdtemp()
|
|
|
|
|
|
|
|
try:
|
2015-06-06 15:12:17 +00:00
|
|
|
if futures:
|
|
|
|
with futures.ThreadPoolExecutor(16) as executor:
|
|
|
|
executor.map(update, PLUGINS.splitlines())
|
|
|
|
else:
|
|
|
|
[update(x) for x in PLUGINS.splitlines()]
|
2013-04-13 17:45:21 +00:00
|
|
|
finally:
|
|
|
|
shutil.rmtree(temp_directory)
|