2020-02-13 17:29:40 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from lintlib import log
|
|
|
|
|
|
|
|
|
|
|
|
def key(v):
|
|
|
|
if v == 'master':
|
|
|
|
return float('inf')
|
2020-02-14 12:03:48 +01:00
|
|
|
if v == 'stable':
|
2020-02-13 17:29:40 +01:00
|
|
|
return sys.maxsize
|
2020-03-25 20:01:11 +01:00
|
|
|
if v == 'beta':
|
|
|
|
return sys.maxsize - 1
|
2020-02-13 17:29:40 +01:00
|
|
|
|
|
|
|
v = v.replace('v', '').replace('rust-', '')
|
|
|
|
|
|
|
|
s = 0
|
|
|
|
for i, val in enumerate(v.split('.')[::-1]):
|
|
|
|
s += int(val) * 100**i
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
if len(sys.argv) < 2:
|
|
|
|
print("Error: specify output directory")
|
|
|
|
return
|
|
|
|
|
|
|
|
outdir = sys.argv[1]
|
|
|
|
versions = [
|
|
|
|
dir for dir in os.listdir(outdir) if not dir.startswith(".") and os.path.isdir(os.path.join(outdir, dir))
|
|
|
|
]
|
|
|
|
versions.sort(key=key)
|
|
|
|
|
|
|
|
with open(os.path.join(outdir, "versions.json"), "w") as fp:
|
|
|
|
json.dump(versions, fp, indent=2)
|
|
|
|
log.info("wrote JSON for great justice")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|