Remove dead inmports
This commit is contained in:
parent
f978c53a29
commit
dffb461f94
|
@ -1,13 +1,13 @@
|
||||||
import private/nix
|
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
import nimblepkg/common,
|
import nimblepkg/common,
|
||||||
nimblepkg/packageinfo,
|
|
||||||
nimblepkg/version,
|
|
||||||
nimblepkg/packageparser,
|
|
||||||
nimblepkg/options,
|
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 =
|
const githubPackagesUrl =
|
||||||
"https://raw.githubusercontent.com/nim-lang/packages/master/packages.json"
|
"https://raw.githubusercontent.com/nim-lang/packages/master/packages.json"
|
||||||
|
@ -80,7 +80,7 @@ proc collectMetadata(data: JsonNode) =
|
||||||
var packageNames = newSeq[string]()
|
var packageNames = newSeq[string]()
|
||||||
for (kind, path) in walkDir(storePath):
|
for (kind, path) in walkDir(storePath):
|
||||||
if kind in {pcFile, pcLinkToFile} and path.endsWith(".nimble"):
|
if kind in {pcFile, pcLinkToFile} and path.endsWith(".nimble"):
|
||||||
var (dir, name, ext) = splitFile(path)
|
var (_, name, _) = splitFile(path)
|
||||||
packageNames.add name
|
packageNames.add name
|
||||||
if packageNames.len == 0:
|
if packageNames.len == 0:
|
||||||
quit("no .nimble files found in " & storePath)
|
quit("no .nimble files found in " & storePath)
|
||||||
|
|
|
@ -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
|
|
Loading…
Reference in New Issue