-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminiconda.lua
115 lines (96 loc) · 2.56 KB
/
miniconda.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
--[[
Miniconda.
Latest verisons only.
--]]
-- global variables
sdk_name = "miniconda"
plugin_name = "miniconda"
plugin_version = "0.1"
prequisite = ""
homepage = "https://docs.anaconda.com/miniconda/"
-- installer config
ic = newInstallerConfig()
ic = addBinaryDirs(ic, "", {"bin"})
ic = addBinaryDirs(ic, "", {"condabin"})
-- spider
function parseArch(archStr)
if contains(archStr, "x86_64") then
return "amd64"
end
if contains(archStr, "arm64") then
return "arm64"
end
if contains(archStr, "aarch64") then
return "arm64"
end
return ""
end
function parseOs(osStr)
if contains(osStr, "MacOSX") then
return "darwin"
elseif contains(osStr, "Windows") then
return "windows"
elseif contains(osStr, "Linux") then
return "linux"
end
return ""
end
function filterByFileName(fileName)
if contains(fileName, "Miniconda3-latest-") then
if not contains(fileName, ".pkg") then
return true
end
end
return false
end
-- called by vmr
function crawl()
local url = "https://repo.anaconda.com/miniconda/"
local timeout = 600
local headers = {}
headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
local resp = getResponse(url, timeout, headers)
local t = initSelection(resp, "table")
local tr = find(t, "tr")
local versionList = newVersionList()
function parseItem(i, s)
if not s then
return
end
local td = find(s, "td")
local eqs = eq(td, 0)
local a = find(eqs, "a")
local href = attr(a, "href")
if href == "" then
return
end
local fileName = text(a)
if not filterByFileName(fileName) then
return
end
local item = {}
item["arch"] = parseArch(fileName)
item["os"] = parseOs(fileName)
if item["arch"] == "" or item["os"] == "" then
return
end
if not hasPrefix(href, "http") then
href = urlJoin(url, href)
end
item["url"] = href
eqs = eq(td, 3)
item["sum"] = text(eqs)
if item["sum"] ~= "" then
item["sum_type"] = "sha256"
else
item["sum_type"] = ""
end
item["extra"] = ""
item["lts"] = ""
item["size"] = 0
item["installer"] = "executable"
addItem(versionList, "latest", item)
end
each(tr, parseItem)
return versionList
end