From 0afaa2a8cd7e56f4eabcf6b54e83bcab6be39f42 Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 21:36:19 +0100 Subject: compiles now on current devel (1.3.5) --- src/aur.nim | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 8 deletions(-) (limited to 'src/aur.nim') diff --git a/src/aur.nim b/src/aur.nim index 399183c..a8be70b 100644 --- a/src/aur.nim +++ b/src/aur.nim @@ -70,9 +70,22 @@ 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)) + 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: + let tmp = collect(newSeq): + for p in pkgs: + for x in table.opt(p): + x + (tmp,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)) except CurlError: (@[], some(getCurrentException().msg)) except JsonParsingError: @@ -95,7 +108,14 @@ proc getAurPackageInfos*(pkgs: seq[string], repo: string, arch: string, useTimeo error: Option[string] ] - let deduplicated = lc[x.base | (x <- rpcInfos), string].deduplicate + when NimVersion >= "1.2": + let deduplicated = block: + let tmp = collect(newSeq): + for x in rpcInfos: + x.base + tmp.deduplicate + else: + let deduplicated = lc[x.base | (x <- rpcInfos), string].deduplicate proc obtainAndParse(base: string, index: int): ParseResult = let (srcInfo, operror) = obtainPkgBaseSrcInfo(base, useTimeout) @@ -108,11 +128,27 @@ 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] + 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 table = infos.map(i => (i.rpc.name, i)).toTable - let pkgInfos = lc[x | (p <- pkgs, x <- table.opt(p)), PackageInfo] + 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 names = rpcInfos.map(i => i.name).toHashSet let additionalPkgInfos = infos.filter(i => not (i.rpc.name in names)) @@ -132,7 +168,13 @@ 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] + 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 filteredRpcInfos = if query.len > 1: (block: let queryLow = query[1 .. ^1].map(q => q.toLowerAscii) -- cgit v1.2.3-70-g09d2