diff options
author | Benjamin Shirley-Quirk | 2020-08-04 20:36:19 +0000 |
---|---|---|
committer | Benjamin Shirley-Quirk | 2020-08-04 20:36:19 +0000 |
commit | 0afaa2a8cd7e56f4eabcf6b54e83bcab6be39f42 (patch) | |
tree | f474af5f8864f191eb006f3cf69e9c65490fb2cb /src/aur.nim | |
parent | 8c75dc9df518579cab48a6ded803bf8d493a3cab (diff) |
compiles now on current devel (1.3.5)
Diffstat (limited to 'src/aur.nim')
-rw-r--r-- | src/aur.nim | 58 |
1 files changed, 50 insertions, 8 deletions
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) |