diff options
Diffstat (limited to 'src/aur.nim')
-rw-r--r-- | src/aur.nim | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/aur.nim b/src/aur.nim index 9b0628f..8f555cb 100644 --- a/src/aur.nim +++ b/src/aur.nim @@ -1,7 +1,7 @@ import json, lists, options, re, sequtils, sets, strutils, sugar, tables, package, utils, - "wrapper/curl", "listcomp" + "wrapper/curl" type AurComment* = tuple[ @@ -70,9 +70,16 @@ proc getRpcPackageInfos*(pkgs: seq[string], repo: string, useTimeout: bool): .foldl(a & "&arg[]=" & b) performString(url, useTimeout))) - let table = lc[(x.name, x) | (z <- responses, y <- parseJson(z)["results"], - x <- parseRpcPackageInfo(y, repo)), (string, RpcPackageInfo)].toTable - (lc[x | (p <- pkgs, x <- table.opt(p)), RpcPackageInfo], none(string)) + let table = collect(initTable): + for z in responses: + for y in parseJson(z)["results"]: + for x in parseRpcPackageInfo(y,repo): + {x.name:x} + ((block:collect(newSeq): + for p in pkgs: + for x in table.opt(p): + x + ),none(string)) except CurlError: (@[], some(getCurrentException().msg)) except JsonParsingError: @@ -95,8 +102,11 @@ proc getAurPackageInfos*(pkgs: seq[string], repo: string, arch: string, useTimeo error: Option[string] ] - let deduplicated = lc[x.base | (x <- rpcInfos), string].deduplicate - + let deduplicated = deduplicate: + collect(newSeq): + for x in rpcInfos: + x.base + proc obtainAndParse(base: string, index: int): ParseResult = let (srcInfo, operror) = obtainPkgBaseSrcInfo(base, useTimeout) @@ -108,11 +118,20 @@ proc getAurPackageInfos*(pkgs: seq[string], repo: string, arch: string, useTimeo (pkgInfos, none(string)) let parsed = deduplicated.foldl(a & obtainAndParse(b, a.len), newSeq[ParseResult]()) - let infos = lc[x | (y <- parsed, x <- y.infos), PackageInfo] - let errors = lc[x | (y <- parsed, x <- y.error), string] + let infos = collect(newSeq): + for y in parsed: + for x in y.infos: + x + let errors = collect(newSeq): + for y in parsed: + for x in y.error: + x let table = infos.map(i => (i.rpc.name, i)).toTable - let pkgInfos = lc[x | (p <- pkgs, x <- table.opt(p)), PackageInfo] + let pkgInfos = collect(newSeq): + for p in pkgs: + for x in table.opt(p): + x let names = rpcInfos.map(i => i.name).toHashSet let additionalPkgInfos = infos.filter(i => not (i.rpc.name in names)) @@ -132,7 +151,10 @@ proc findAurPackages*(query: seq[string], repo: string, useTimeout: bool): let response = performString(url, useTimeout) let results = parseJson(response)["results"] - let rpcInfos = lc[x | (y <- results, x <- parseRpcPackageInfo(y, repo)), RpcPackageInfo] + let rpcInfos = collect(newSeq): + for y in results: + for x in parseRpcPackageInfo(y,repo): + x let filteredRpcInfos = if query.len > 1: (block: let queryLow = query[1 .. ^1].map(q => q.toLowerAscii) |