aboutsummaryrefslogtreecommitdiff
path: root/src/aur.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/aur.nim')
-rw-r--r--src/aur.nim80
1 files changed, 31 insertions, 49 deletions
diff --git a/src/aur.nim b/src/aur.nim
index 542a21c..8f555cb 100644
--- a/src/aur.nim
+++ b/src/aur.nim
@@ -70,21 +70,16 @@ proc getRpcPackageInfos*(pkgs: seq[string], repo: string, useTimeout: bool):
.foldl(a & "&arg[]=" & b)
performString(url, useTimeout)))
- when NimVersion >= "1.2":
- 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))
- else:
- 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:
@@ -107,14 +102,11 @@ proc getAurPackageInfos*(pkgs: seq[string], repo: string, arch: string, useTimeo
error: Option[string]
]
- when NimVersion >= "1.2":
- let deduplicated = deduplicate:
- collect(newSeq):
- for x in rpcInfos:
- x.base
- else:
- 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)
@@ -126,27 +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]())
- when NimVersion >= "1.2":
- 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
- else:
- 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
- when NimVersion >= "1.2":
- let pkgInfos = collect(newSeq):
- for p in pkgs:
- for x in table.opt(p):
- x
- else:
- 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))
@@ -166,13 +151,10 @@ proc findAurPackages*(query: seq[string], repo: string, useTimeout: bool):
let response = performString(url, useTimeout)
let results = parseJson(response)["results"]
- when NimVersion >= "1.2":
- let rpcInfos = collect(newSeq):
- for y in results:
- for x in parseRpcPackageInfo(y,repo):
- x
- else:
- 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)