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/common.nim | 79 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 15 deletions(-) (limited to 'src/common.nim') diff --git a/src/common.nim b/src/common.nim index 8db3a79..58d4d08 100644 --- a/src/common.nim +++ b/src/common.nim @@ -153,8 +153,17 @@ proc findSyncTargets*(handle: ptr AlpmHandle, dbs: seq[ptr AlpmDatabase], return @[] else: if allowGroups and target.reference.constraint.isNone: - let groupRepo = lc[d | (d <- dbs, g <- d.groups, - $g.name == target.reference.name), ptr AlpmDatabase].optFirst + when NimVersion >= "1.2": + let groupRepo = block: + let tmp = collect(newSeq): + for d in dbs: + for g in d.groups: + if $g.name == target.reference.name: + d + tmp.optFirst + else: + let groupRepo = lc[d | (d <- dbs, g <- d.groups, + $g.name == target.reference.name), ptr AlpmDatabase].optFirst if groupRepo.isSome: return @[($groupRepo.unsafeGet.name, none(SyncFoundPackageInfo))] @@ -240,18 +249,36 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona (installed, explicit.toHashSet + assumeExplicit, dependsTable, alternatives) - let providedBy = lc[(y, x.key) | (x <- alternatives.namedPairs, y <- x.value), - tuple[reference: PackageReference, name: string]] + when NimVersion >= "1.2": + let providedBy = collect(newSeq): + for x in alternatives.namedPairs: + for y in x.value: + (reference:y,name:x.key) + else: + let providedBy = lc[(y, x.key) | (x <- alternatives.namedPairs, y <- x.value), + tuple[reference: PackageReference, name: string]] proc findRequired(withOptional: bool, results: HashSet[string], check: HashSet[string]): HashSet[string] = let full = results + check - let direct = lc[x.reference | (y <- dependsTable.namedPairs, y.key in check, - x <- y.value, withOptional or not x.optional), PackageReference] - - let indirect = lc[x.name | (y <- direct, x <- providedBy, - y.isProvidedBy(x.reference, true)), string].toHashSet + when NimVersion >= "1.2": + let direct = collect(newSeq): + for y in dependsTable.namedPairs: + if y.key in check: + for x in y.value: + if withOptional or not x.optional: + x.reference + let indirect = collect(initHashSet): + for y in direct: + for x in providedBy: + if y.isProvidedBy(x.reference, true): + {x.name} + else: + let direct = lc[x.reference | (y <- dependsTable.namedPairs, y.key in check, + x <- y.value, withOptional or not x.optional), PackageReference] + let indirect = lc[x.name | (y <- direct, x <- providedBy, + y.isProvidedBy(x.reference, true)), string].toHashSet let checkNext = (direct.map(p => p.name).toHashSet + indirect) - full if checkNext.len > 0: findRequired(withOptional, full, checkNext) else: full @@ -622,13 +649,29 @@ proc obtainBuildPkgInfosInternal(config: Config, bases: seq[LookupBaseGroup], (list[tuple[pkgInfos: seq[PackageInfo], path: Option[string]]](), 0)) let pkgInfosWithPaths = pkgInfosWithPathsReversed.reversed - let pkgInfos = lc[x | (y <- pkgInfosWithPaths, x <- y.pkgInfos), PackageInfo] - let paths = lc[x | (y <- pkgInfosWithPaths, x <- y.path), string] + when NimVersion >= "1.2": + let pkgInfos = collect(newSeq): + for y in pkgInfosWithPaths: + for x in y.pkgInfos: + x + let paths = collect(newSeq): + for y in pkgInfosWithPaths: + for x in y.path: + x + else: + let pkgInfos = lc[x | (y <- pkgInfosWithPaths, x <- y.pkgInfos), PackageInfo] + let paths = lc[x | (y <- pkgInfosWithPaths, x <- y.path), string] let pkgInfosTable = pkgInfos.map(i => (i.rpc.name, i)).toTable - - let foundPkgInfos = lc[x | (y <- pacmanTargetNames, - x <- pkgInfosTable.opt(y)), PackageInfo] + + when NimVersion >= "1.2": + let foundPkgInfos = collect(newSeq): + for y in pacmanTargetNames: + for x in pkgInfosTable.opt(y): + x + else: + let foundPkgInfos = lc[x | (y <- pacmanTargetNames, + x <- pkgInfosTable.opt(y)), PackageInfo] let errorMessages = pacmanTargetNames .filter(n => not pkgInfosTable.hasKey(n)) .map(n => tr"$#: failed to get package info" % [n]) @@ -738,7 +781,13 @@ proc cloneAurReposWithPackageInfos*(config: Config, rpcInfos: seq[RpcPackageInfo let (fullPkgInfos, paths, errors) = cloneNext(0, nil, nil, nil) let pkgInfosTable = fullPkgInfos.map(i => (i.rpc.name, i)).toTable - let resultPkgInfos = lc[x | (y <- rpcInfos, x <- pkgInfosTable.opt(y.name)), PackageInfo] + when NimVersion >= "1.2": + let resultPkgInfos = collect(newSeq): + for y in rpcInfos: + for x in pkgInfosTable.opt(y.name): + x + else: + let resultPkgInfos = lc[x | (y <- rpcInfos, x <- pkgInfosTable.opt(y.name)), PackageInfo] let names = rpcInfos.map(i => i.name).toHashSet let additionalPkgInfos = fullPkgInfos.filter(i => not (i.rpc.name in names)) -- cgit v1.2.3-70-g09d2 From b47df19c354e6b1c3c438b57eb463bbfaa8fd08d Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 22:15:13 +0100 Subject: compiles on 1.2.6 --- src/common.nim | 18 +++++++++++++++++- src/pacman.nim | 28 +++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 6 deletions(-) (limited to 'src/common.nim') diff --git a/src/common.nim b/src/common.nim index 58d4d08..a7d59c4 100644 --- a/src/common.nim +++ b/src/common.nim @@ -262,7 +262,7 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona check: HashSet[string]): HashSet[string] = let full = results + check - when NimVersion >= "1.2": + when NimVersion >= "1.3.5": let direct = collect(newSeq): for y in dependsTable.namedPairs: if y.key in check: @@ -274,6 +274,22 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona for x in providedBy: if y.isProvidedBy(x.reference, true): {x.name} + elif NimVersion >= "1.2": + let direct = block: + var tmp = newSeq[PackageReference]() + for y in dependsTable.namedPairs: + if y.key in check: + for x in y.value: + if withOptional or not x.optional: + tmp.add(x.reference) + tmp + let indirect = block: + var tmp = initHashSet[string]() + for y in direct: + for x in providedBy: + if y.isProvidedBy(x.reference, true): + tmp.incl(x.name) + tmp else: let direct = lc[x.reference | (y <- dependsTable.namedPairs, y.key in check, x <- y.value, withOptional or not x.optional), PackageReference] diff --git a/src/pacman.nim b/src/pacman.nim index d1fadb0..1b9d2f9 100644 --- a/src/pacman.nim +++ b/src/pacman.nim @@ -300,15 +300,25 @@ proc checkConflicts*(args: seq[Argument], let table = conflicts.obtainConflictsPairs template full(s: string): OptionPair = table[s][0] - when NimVersion >= "1.2": - block: - let tmp = collect(newSeq): + when NimVersion >= "1.3.5": + (block:collect(newSeq): for c in conflicts: if args.check(c.left.full): for w in c.right: if args.check(w.full): (c.left,w) - tmp.optFirst + ).optFirst + elif NimVersion >= "1.2": + (block: + var tmp = newSeq[(string,string)]() + for c in conflicts: + if args.check(c.left.full): + for w in c.right: + if args.check(w.full): + tmp.add((c.left,w)) + tmp + ).optFirst + else: lc[(c.left, w) | (c <- conflicts, args.check(c.left.full), w <- c.right, args.check(w.full)), (string, string)].optFirst @@ -340,12 +350,20 @@ proc pacmanRun*(root: bool, color: bool, args: varargs[Argument]): int = proc pacmanValidateAndThrow(args: varargs[tuple[arg: Argument, pass: bool]]): void = let argsSeq = @args - when NimVersion >= "1.2": + when NimVersion >= "1.3.5": let collectedArgs = collect(newSeq): for y in argsSeq: if y.pass: for x in y.arg.collectArg: x + elif NimVersion >= "1.2": + let collectedArgs = block: + var tmp = newSeq[string]() + for y in argsSeq: + if y.pass: + for x in y.arg.collectArg: + tmp.add(x) + tmp else: let collectedArgs = lc[x | (y <- argsSeq, y.pass, x <- y.arg.collectArg), string] let code = forkWait(() => pacmanExecInternal(false, "-T" & collectedArgs)) -- cgit v1.2.3-70-g09d2 From 8ca6a6ae081fa6381e79b43d1363e5e5ce00c9ba Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 22:52:42 +0100 Subject: removed deprecated []= warnings --- src/common.nim | 6 +++--- src/config.nim | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/common.nim') diff --git a/src/common.nim b/src/common.nim index a7d59c4..6b15b4c 100644 --- a/src/common.nim +++ b/src/common.nim @@ -242,10 +242,10 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona installed.add(pkg.toPackageReference) if pkg.reason == AlpmReason.explicit: explicit &= $pkg.name - dependsTable.add($pkg.name, - depends.map(x => (x, false)) + optional.map(x => (x, true))) + dependsTable[$pkg.name]= + depends.map(x => (x, false)) + optional.map(x => (x, true)) if provides.len > 0: - alternatives.add($pkg.name, provides) + alternatives[$pkg.name]= provides (installed, explicit.toHashSet + assumeExplicit, dependsTable, alternatives) diff --git a/src/config.nim b/src/config.nim index e8be1fc..1afa89a 100644 --- a/src/config.nim +++ b/src/config.nim @@ -81,9 +81,9 @@ proc readConfigFile*(configFile: string): table[currentCategory] = category elif currentCategory.len > 0: if line.match(re"(\w+)\ *=\ *(.*)", matches): - category[].add(matches[0], matches[1]) + category[matches[0]]= matches[1] else: - category[].add(line, "") + category[line]="" false except EOFError: -- cgit v1.2.3-70-g09d2 From b8d35dea8fb61ec177ab898b70404338f2ed477b Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 22:55:59 +0100 Subject: dirExists -> existsDir --- src/common.nim | 6 +++--- src/feature/syncclean.nim | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/common.nim') diff --git a/src/common.nim b/src/common.nim index 6b15b4c..8dc41c8 100644 --- a/src/common.nim +++ b/src/common.nim @@ -527,7 +527,7 @@ proc cloneBareRepo(config: Config, bareKind: BareKind, bareName: string, if forkWait(() => (block: if not dropPrivileges or dropPrivileges(): - if existsDir(repoPath): + if dirExists(repoPath): let branch = branchOption.get("master") execResult(gitCmd, "-C", repoPath, "fetch", "-q", "--no-tags", "origin", branch & ":" & branch) @@ -724,7 +724,7 @@ proc cloneAurRepo*(config: Config, base: string, gitUrl: string, if message.isSome: (1, message) - elif repoPath.existsDir(): + elif repoPath.dirExists(): (0, none(string)) else: let fullName = bareFullName(BareKind.pkg, base) @@ -733,7 +733,7 @@ proc cloneAurRepo*(config: Config, base: string, gitUrl: string, let cloneBareCode = forkWait(() => (block: if not dropPrivileges or dropPrivileges(): - if existsDir(bareRepoPath): + if dirExists(bareRepoPath): execResult(gitCmd, "-C", bareRepoPath, "fetch", "-q", "--no-tags", "origin", "master:master") else: diff --git a/src/feature/syncclean.nim b/src/feature/syncclean.nim index 6b1f853..ad0c255 100644 --- a/src/feature/syncclean.nim +++ b/src/feature/syncclean.nim @@ -31,7 +31,7 @@ proc handleSyncClean*(args: seq[Argument], config: Config): int = else: echo(tr"removing all package repositories...") - if existsDir(reposCacheDir): + if dirExists(reposCacheDir): withAlpmConfig(config, false, handle, dbs, errors): for e in errors: printError(config.color, e) -- cgit v1.2.3-70-g09d2 From c54e6d24b70f21293612449c7a960e64077c5f89 Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 23:45:21 +0100 Subject: refactored collect blocks --- src/aur.nim | 16 +++++------ src/common.nim | 5 ++-- src/feature/syncinfo.nim | 9 +++---- src/feature/syncinstall.nim | 65 ++++++++++++++++++++------------------------- src/main.nim | 5 ++-- src/package.nim | 46 ++++++++++++-------------------- src/pacman.nim | 8 +++--- 7 files changed, 64 insertions(+), 90 deletions(-) (limited to 'src/common.nim') diff --git a/src/aur.nim b/src/aur.nim index a8be70b..542a21c 100644 --- a/src/aur.nim +++ b/src/aur.nim @@ -76,12 +76,11 @@ proc getRpcPackageInfos*(pkgs: seq[string], repo: string, useTimeout: bool): 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)) + ((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 @@ -109,11 +108,10 @@ proc getAurPackageInfos*(pkgs: seq[string], repo: string, arch: string, useTimeo ] when NimVersion >= "1.2": - let deduplicated = block: - let tmp = collect(newSeq): + let deduplicated = deduplicate: + collect(newSeq): for x in rpcInfos: x.base - tmp.deduplicate else: let deduplicated = lc[x.base | (x <- rpcInfos), string].deduplicate diff --git a/src/common.nim b/src/common.nim index 8dc41c8..0f2804b 100644 --- a/src/common.nim +++ b/src/common.nim @@ -154,13 +154,12 @@ proc findSyncTargets*(handle: ptr AlpmHandle, dbs: seq[ptr AlpmDatabase], else: if allowGroups and target.reference.constraint.isNone: when NimVersion >= "1.2": - let groupRepo = block: - let tmp = collect(newSeq): + let groupRepo = optFirst: + collect(newSeq): for d in dbs: for g in d.groups: if $g.name == target.reference.name: d - tmp.optFirst else: let groupRepo = lc[d | (d <- dbs, g <- d.groups, $g.name == target.reference.name), ptr AlpmDatabase].optFirst diff --git a/src/feature/syncinfo.nim b/src/feature/syncinfo.nim index 9dd1331..6b2278d 100644 --- a/src/feature/syncinfo.nim +++ b/src/feature/syncinfo.nim @@ -132,11 +132,10 @@ proc handleSyncInfo*(args: seq[Argument], config: Config): int = let pkgInfosTable = pkgInfos.map(i => (i.rpc.toPackageReference, i)).toTable when NimVersion >= "1.2": - let codes = block: - let tmp = collect(newSeq): - for x in fullTargets: - handleTarget(config, padding, finalArgs, x, x.rpcInfo.map(i => pkgInfosTable.opt(i.toPackageReference)).flatten) - code & tmp + let codes = code & (block:collect(newSeq): + for x in fullTargets: + handleTarget(config, padding, finalArgs, x, x.rpcInfo.map(i => pkgInfosTable.opt(i.toPackageReference)).flatten) + ) else: let codes = code & lc[handleTarget(config, padding, finalArgs, x, x.rpcInfo.map(i => pkgInfosTable.opt(i.toPackageReference)).flatten) | diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 36115cc..b6347f9 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -249,14 +249,13 @@ proc findDependencies(config: Config, handle: ptr AlpmHandle, dbs: seq[ptr AlpmD aurSuccess.map(r => (r.reference, r.result.unsafeGet))).toTable when NimVersion >= "1.2": - let newUnsatisfied = block: - let tmp = collect(newSeq): + let newUnsatisfied = deduplicate: + collect(newSeq): for y in aurSuccess: for r in y.result: for i in r.buildPkgInfo: for x in i.allDepends: x - tmp.deduplicate else: let newUnsatisfied = lc[x | (y <- aurSuccess, r <- y.result, i <- r.buildPkgInfo, x <- i.allDepends), PackageReference].deduplicate @@ -279,12 +278,11 @@ proc findDependencies(config: Config, handle: ptr AlpmHandle, let satisfied = pkgInfos.map(p => ((p.rpc.name, none(string), none(VersionConstraint)), (false, p.rpc.name, some(p)))).toTable when NimVersion >= "1.2": - let unsatisfied = block: - let tmp = collect(newSeq): + let unsatisfied = deduplicate: + collect(newSeq): for i in pkgInfos: for x in i.allDepends: x - tmp.deduplicate else: let unsatisfied = lc[x | (i <- pkgInfos, x <- i.allDepends), PackageReference].deduplicate findDependencies(config, handle, dbs, satisfied, unsatisfied, @[], @@ -673,17 +671,15 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], commonArgs.keepOnlyOptions(commonOptions) & ("D", none(string), ArgumentType.short)) when NimVersion >= "1.2": - - let installParams = block: - let tmp = collect(newSeq): - for i in installWithReason: - for x in [i.name,i.file,i.mode]: - x - sudoPrefix & (pkgLibDir & "/install") & + let installParams = sudoPrefix & (pkgLibDir & "/install") & cacheDir & $cacheUser & $cacheGroup & $pacmanUpgradeParams.len & pacmanUpgradeParams & $pacmanDatabaseParams.len & pacmanDatabaseParams & - tmp + (block:collect(newSeq): + for i in installWithReason: + for x in [i.name,i.file,i.mode]: + x + ) else: let installParams = sudoPrefix & (pkgLibDir & "/install") & cacheDir & $cacheUser & $cacheGroup & @@ -760,13 +756,12 @@ proc resolveDependencies(config: Config, pkgInfos: seq[PackageInfo], else: let buildAndAurNamesSet = pkgInfos.map(i => i.rpc.name).toHashSet when NimVersion >= "1.2": - let fullPkgInfos = block: - let tmp = collect(newSeq): - for s in satisfied.values: - for i in s.buildPkgInfo: - if not (i.rpc.name in buildAndAurNamesSet): - i - (pkgInfos & tmp).deduplicatePkgInfos(config,false) + let fullPkgInfos = (pkgInfos & (block:collect(newSeq): + for s in satisfied.values: + for i in s.buildPkgInfo: + if not (i.rpc.name in buildAndAurNamesSet): + i + )).deduplicatePkgInfos(config,false) let additionalPacmanTargets = collect(newSeq): for x in satisfied.values: if not x.installed and x.buildPkgInfo.isNone: @@ -787,14 +782,12 @@ proc confirmViewAndImportKeys(config: Config, basePackages: seq[seq[seq[PackageI if basePackages.len > 0: (block: let installedVersions = installed.map(i => (i.name, i.version)).toTable when NimVersion >= "1.2": - block: - let tmp = collect(newSeq): - for g in basePackages: - for b in g: - for i in b: - (i.rpc.name,i.rpc.repo,installedVersions.opt(i.rpc.name),i.rpc.version).PackageInstallFormat - printPackages(config.color, config.common.verbosePkgLists, - tmp.sorted((a,b) => cmp(a.name, b.name))) + printPackages(config.color, config.common.verbosePkgLists,(block:collect(newSeq): + for g in basePackages: + for b in g: + for i in b: + (i.rpc.name,i.rpc.repo,installedVersions.opt(i.rpc.name),i.rpc.version).PackageInstallFormat + ).sorted((a,b) => cmp(a.name, b.name))) else: printPackages(config.color, config.common.verbosePkgLists, lc[(i.rpc.name, i.rpc.repo, installedVersions.opt(i.rpc.name), i.rpc.version) | @@ -842,12 +835,11 @@ proc confirmViewAndImportKeys(config: Config, basePackages: seq[seq[seq[PackageI let resultPkgInfos = reloadPkgInfos(config, repoPath & "/" & pkgInfos[0].rpc.gitSubdir.get("."), pkgInfos) when NimVersion >= "1.2": - let pgpKeys = block: - let tmp = collect(newSeq): + let pgpKeys = deduplicate: + collect(newSeq): for p in resultPkgInfos: for x in p.pgpKeys: x - tmp.deduplicate else: let pgpKeys = lc[x | (p <- resultPkgInfos, x <- p.pgpKeys), string].deduplicate @@ -1017,16 +1009,17 @@ proc filterIgnoresAndConflicts(config: Config, pkgInfos: seq[PackageInfo], when NimVersion >= "1.2": let conflictsWith = collect(newSeq): for p in a: - if (p.rpc.name != b.rpc.name and (block:collect(newSeq): + if p.rpc.name != b.rpc.name and + (block:collect(newSeq): for c in b.conflicts: if c.isProvidedBy(p.rpc.toPackageReference, true): 0 - ).len>0 or (block:collect(newSeq): + ).len>0 or + (block:collect(newSeq): for c in p.conflicts: if c.isProvidedBy(p.rpc.toPackageReference, true): 0 - ).len>0 - ): + ).len>0: p else: let conflictsWith = lc[p | (p <- a, p.rpc.name != b.rpc.name and diff --git a/src/main.nim b/src/main.nim index af22bc0..458ba72 100644 --- a/src/main.nim +++ b/src/main.nim @@ -12,12 +12,11 @@ import proc execSudo*(args: seq[Argument]): int = when NimVersion >= "1.2": - execResult(sudoPrefix & getAppFilename() & - (block:collect(newSeq): + execResult(sudoPrefix & getAppFilename() & (block:collect(newSeq): for y in args: for x in y.collectArg: x - )) + )) else: execResult(sudoPrefix & getAppFilename() & lc[x | (y <- args, x <- y.collectArg), string]) diff --git a/src/package.nim b/src/package.nim index 5e42b0c..340f359 100644 --- a/src/package.nim +++ b/src/package.nim @@ -92,11 +92,14 @@ const static: # test only single match available when NimVersion >= "1.2": - var osSet = initHashSet[string]() - var repoSet = initHashSet[string]() - for r in packageRepos: - osSet.incl(r.os) - repoSet.incl(r.repo) + let osSet = collect(initHashSet): + for r in packageRepos: + for x in r.os: + {x} + let repoSet = collect(initHashSet): + for r in packageRepos: + for x in r.repo: + {x} else: let osSet = lc[x | (r <- packageRepos, x <- r.os), string].toHashSet let repoSet = lc[x | (r <- packageRepos, x <- r.repo), string].toHashSet @@ -304,19 +307,11 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int references.filter(r => filterWith.filter(w => r.isProvidedBy(w, true)).len == 0) when NimVersion >= "1.2": -#[ let base = block: - let tmp = newSeq[string]() - for x in baseSeq[]: - if x.key == "pkgbase": - tmp.add(x.value) - tmp.optLast -]# - let base = block: - let tmp = collect(newSeq): + let base = optLast: + collect(newSeq): for x in baseSeq[]: if x.key == "pkgbase": x.value - tmp.optLast else: let base = lc[x.value | (x <- baseSeq[], x.key == "pkgbase"), string].optLast @@ -324,17 +319,11 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int let release = kcollect(true, "pkgrel").optLast let epoch = kcollect(true, "epoch").optLast when NimVersion >= "1.2": - #tmp = newSeq[string]() - #for v in version: - #for r in release: - #tmp.add(v & "-" & r) - #let versionFull = tmp.optLast.map(v => epoch.map(e => e & ":" & v).get(v)) - let versionFull = block: - let tmp = collect(newSeq): - for v in version: - for r in release: - (v & "-" & r) - tmp.optLast.map(v => epoch.map(e => e & ":" & v).get(v)) + let versionFull = (block:collect(newSeq): + for v in version: + for r in release: + (v & "-" & r) + ).optLast.map(v => epoch.map(e => e & ":" & v).get(v)) else: let versionFull = lc[(v & "-" & r) | (v <- version, r <- release), string].optLast .map(v => epoch.map(e => e & ":" & v).get(v)) @@ -360,8 +349,8 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int let info = rpcInfos.filter(i => i.name == name).optLast when NimVersion >= "1.2": - block: - let tmp = collect(newSeq): + optLast: + collect(newSeq): for b in base: for v in versionFull: ((repo, b, name, v, description, info.map(i => i.maintainer).flatten, @@ -370,7 +359,6 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int info.map(i => i.popularity).get(0), gitUrl, gitSubdir), baseIndex, baseCount, archs, url, licenses, groups, pgpKeys, depends, makeDepends, checkDepends, optional, provides, conflicts, replaces) - tmp.optLast else: lc[((repo, b, name, v, description, info.map(i => i.maintainer).flatten, info.map(i => i.firstSubmitted).flatten, info.map(i => i.lastModified).flatten, diff --git a/src/pacman.nim b/src/pacman.nim index 1b9d2f9..f9fc978 100644 --- a/src/pacman.nim +++ b/src/pacman.nim @@ -301,15 +301,15 @@ proc checkConflicts*(args: seq[Argument], template full(s: string): OptionPair = table[s][0] when NimVersion >= "1.3.5": - (block:collect(newSeq): + optFirst: + collect(newSeq): for c in conflicts: if args.check(c.left.full): for w in c.right: if args.check(w.full): (c.left,w) - ).optFirst elif NimVersion >= "1.2": - (block: + optFirst: var tmp = newSeq[(string,string)]() for c in conflicts: if args.check(c.left.full): @@ -317,8 +317,6 @@ proc checkConflicts*(args: seq[Argument], if args.check(w.full): tmp.add((c.left,w)) tmp - ).optFirst - else: lc[(c.left, w) | (c <- conflicts, args.check(c.left.full), w <- c.right, args.check(w.full)), (string, string)].optFirst -- cgit v1.2.3-70-g09d2