Skip to content

Instantly share code, notes, and snippets.

@Yardanico
Created May 18, 2020 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yardanico/39598168a204fb8d81aed80f5210defc to your computer and use it in GitHub Desktop.
Save Yardanico/39598168a204fb8d81aed80f5210defc to your computer and use it in GitHub Desktop.
import json, tables, strscans
let a = parseFile("packages.json")
var data = initCountTable[string]()
for pkg in a:
if "alias" in pkg: continue
let url = pkg["url"].getStr()
var temp, name: string
if scanf(url, "$+.$+/$+/", temp, temp, name):
if name[0] == '~': name = name[1..^1]
data.inc(name)
# SSH
elif scanf(url, "$+.$+:$+/", temp, temp, name):
if name[0] == '~': name = name[1..^1]
data.inc(name)
else:
raise newException(ValueError, "Didn't parse name from URL " & url)
data.sort()
for name, cnt in data.pairs:
if cnt > 10:
echo name, " - ", cnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment