diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/aur.nim | 16 | ||||
-rw-r--r-- | src/common.nim | 5 | ||||
-rw-r--r-- | src/feature/syncinfo.nim | 9 | ||||
-rw-r--r-- | src/feature/syncinstall.nim | 65 | ||||
-rw-r--r-- | src/main.nim | 5 | ||||
-rw-r--r-- | src/package.nim | 46 | ||||
-rw-r--r-- | src/pacman.nim | 8 |
7 files changed, 64 insertions, 90 deletions
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 |