-
-
Save Yardanico/39598168a204fb8d81aed80f5210defc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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