From dffb461f940405ded03f5f73943421f47eed066b Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 8 Oct 2023 14:36:34 +0100 Subject: [PATCH] Remove dead inmports --- src/nim_lk.nim | 14 +++--- src/private/nix.nim | 120 -------------------------------------------- 2 files changed, 7 insertions(+), 127 deletions(-) delete mode 100644 src/private/nix.nim diff --git a/src/nim_lk.nim b/src/nim_lk.nim index 44602ac..2ab059d 100644 --- a/src/nim_lk.nim +++ b/src/nim_lk.nim @@ -1,13 +1,13 @@ -import private/nix +# SPDX-FileCopyrightText: ☭ Emery Hemingway +# SPDX-License-Identifier: Unlicense import nimblepkg/common, - nimblepkg/packageinfo, - nimblepkg/version, - nimblepkg/packageparser, nimblepkg/options, - nimblepkg/cli + nimblepkg/packageinfo, + nimblepkg/packageparser, + nimblepkg/version -import std/[algorithm, deques, httpclient, json, monotimes, os, osproc, parseutils, random, sequtils, streams, strutils, tables, times, uri] +import std/[algorithm, deques, httpclient, json, os, osproc, parseutils, streams, strutils, uri] const githubPackagesUrl = "https://raw.githubusercontent.com/nim-lang/packages/master/packages.json" @@ -80,7 +80,7 @@ proc collectMetadata(data: JsonNode) = var packageNames = newSeq[string]() for (kind, path) in walkDir(storePath): if kind in {pcFile, pcLinkToFile} and path.endsWith(".nimble"): - var (dir, name, ext) = splitFile(path) + var (_, name, _) = splitFile(path) packageNames.add name if packageNames.len == 0: quit("no .nimble files found in " & storePath) diff --git a/src/private/nix.nim b/src/private/nix.nim deleted file mode 100644 index 03aeae2..0000000 --- a/src/private/nix.nim +++ /dev/null @@ -1,120 +0,0 @@ -import std/sequtils, std/strutils, std/tables - -type - ValueKind* = enum - tInt, - tBool, - tString, - tPath, - tNull, - tAttrs, - tList, - tThunk, - tApp, - tLambda, - tBlackhole, - tPrimOp, - tPrimOpApp, - tExternal, - tFloat - Value* = ref object - case kind: ValueKind - of tInt: - num*: BiggestInt - of tBool: - boolean*: bool - of tString: - str*: string - of tPath: - path*: string - of tNull: - discard - of tAttrs: - attrs*: Table[string, Value] - of tList: - list*: seq[Value] - of tThunk: discard - of tApp: discard - of tLambda: discard - of tBlackhole: discard - of tPrimOp: discard - of tPrimOpApp: discard - of tExternal: discard - of tFloat: - fnum*: float - -func `$`*(v: Value): string = - case v.kind: - of tInt: - result = $v.num - of tBool: - result = if v.boolean: "True" else: "False" - of tString: - result = "\"$1\"" % (v.str.replace("\"", "\\\"")) - of tPath: - result = v.path - of tNull: - result = "null" - of tAttrs: - result = "{" - for key, val in v.attrs.pairs: - let key = if key.validIdentifier: key else: key.escape - result.add("$1=$2;" % [key, $val]) - result.add "}" - of tList: - result = "[ " - for e in v.list: - result.add $e - result.add " " - result.add "]" - of tFloat: - result = $v.fnum - else: - result = $v.kind - -func toNix*(x: Value): Value = x - -func toNix*(x: SomeInteger): Value = - Value(kind: tInt, num: x) - -func toNix*(x: bool): Value = - Value(kind: tBool, boolean: x) - -func toNix*(x: string): Value = - Value(kind: tString, str: x) - -func toPath*(x: string): Value = - Value(kind: tPath, path: x) - -template toNix*(pairs: openArray[(string, Value)]): Value = - Value(kind: tAttrs, attrs: toTable pairs) - -func toNix*(x: seq[Value]): Value = - Value(kind: tList, list: x) - -template toNix*(x: seq[untyped]): Value = - map(x, toNix).toNix - -func toNix*(x: openarray[Value]): Value = - Value(kind: tList, list: x[x.low .. x.high]) - -func toNix*(x: float): Value = - Value(kind: tFloat, fnum: x) - -template `[]=`*(result: Value; key: string; val: untyped) = - result.attrs[key] = val.toNix - -proc `[]`*(attrs: Value; key: string): Value = - attrs.attrs[key] - -proc newNull*(): Value = - Value(kind: tNull) - -proc newAttrs*(): Value = - Value(kind: tAttrs, attrs: initTable[string, Value]()) - -func newList*(): Value = - Value(kind: tList) - -proc add*(x, y: Value) = - x.list.add y