Revisión | abd49f0145f92d99dbd887aedf04e4ed128b016e (tree) |
---|---|
Tiempo | 2023-01-05 20:10:51 |
Autor | badcoff33 <none@none> |
Commiter | badcoff33 |
merged
@@ -1,36 +1,34 @@ | ||
1 | 1 | @setlocal enableextensions & python -x %~f0 %* & goto :EOF |
2 | 2 | ### Python code: |
3 | -import os | |
4 | 3 | |
5 | -# access Git repos via hg-git and dulwich.io | |
6 | -vcs_cmd_clone = "hg clone -q" | |
7 | -vcs_cmd_pull = "hg pull -q" | |
4 | +import os | |
5 | +import requests | |
6 | +import zipfile | |
8 | 7 | |
9 | -git_dict = { | |
10 | - "pack/nvim-treesitter/start/nvim-treesitter": "git@github.com:nvim-treesitter/nvim-treesitter.git", | |
11 | - "pack/gh/start/signify": "git@github.com:mhinz/vim-signify.git", | |
12 | - "pack/gh/start/easy-align": "git@github.com:junegunn/vim-easy-align.git", | |
13 | - "pack/jusinmk/opt/dervish": "git@github.com:justinmk/vim-dirvish.git", | |
14 | - "pack/gh/opt/fzf.git": "git@github.com:junegunn/fzf.git", | |
15 | - "pack/gh/opt/fzf.vim": "git@github.com:junegunn/fzf.vim.git", | |
16 | - "pack/gh/opt/colorizer": "git@github.com:lilydjwg/colorizer.git", | |
17 | - "pack/gh/opt/vista": "git@github.com:liuchengxu/vista.vim.git" | |
8 | +gh_dict = { | |
9 | + "https://github.com/nvim-treesitter/nvim-treesitter/archive/refs/tags/v0.8.1.zip": "pack/gh/start", | |
10 | + "https://github.com/mhinz/vim-signify/archive/refs/heads/master.zip": "pack/gh/start", | |
11 | + "https://github.com/junegunn/vim-easy-align/archive/refs/heads/master.zip": "pack/gh/start", | |
12 | + "https://github.com/justinmk/vim-dirvish/archive/refs/heads/master.zip": "pack/gh/opt", | |
13 | + "https://github.com/lilydjwg/colorizer/archive/refs/heads/master.zip": "pack/gh/opt", | |
14 | + "https://github.com/liuchengxu/vista.vim/archive/refs/heads/master.zip": "pack/gh/opt", | |
18 | 15 | } |
19 | 16 | |
20 | -for subdir in git_dict: | |
21 | - git_url = git_dict[subdir] | |
17 | +zip_fname = os.getenv("TEMP") + os.sep + "pack_download.zip" | |
18 | +pop_back_dir = os.getcwd() | |
19 | + | |
20 | +for url in gh_dict: | |
21 | + subdir = gh_dict[url] | |
22 | 22 | if not os.path.isdir(subdir): |
23 | - print("clone %s to %s" % (git_url, subdir)) | |
23 | + print("-- creating directory %s" % (subdir)) | |
24 | 24 | os.makedirs(subdir) |
25 | - pop_back_dir = os.getcwd() | |
26 | - os.chdir(subdir) | |
27 | - os.system(" ".join([vcs_cmd_clone,git_url,"."])) | |
28 | - os.chdir(pop_back_dir) | |
29 | - else: | |
30 | - print("update %s in %s" % (git_url, subdir)) | |
31 | - pop_back_dir = os.getcwd() | |
32 | - os.chdir(subdir) | |
33 | - os.system(" ".join([vcs_cmd_pull,git_url,"."])) | |
34 | - os.chdir(pop_back_dir) | |
25 | + print("-- fetching %s" % (url)) | |
26 | + r = requests.get(url) | |
27 | + print("-- extract file in %s" % (subdir)) | |
28 | + if os.path.isfile(zip_fname): | |
29 | + os.remove(zip_fname) | |
30 | + open(zip_fname, 'wb').write(r.content) | |
31 | + with zipfile.ZipFile(zip_fname, 'r') as zip_ref: | |
32 | + zip_ref.extractall(subdir) | |
35 | 33 | |
36 | 34 | # vim:ft=python: |