Update to reflect stdlib changes in Nim 1.4.
This commit is contained in:
parent
a58c7923cb
commit
15a893d99f
@ -2,7 +2,7 @@
|
|||||||
## ===================================
|
## ===================================
|
||||||
|
|
||||||
import asyncdispatch, base64, bcrypt, cliutils, docopt, jester, json, logging,
|
import asyncdispatch, base64, bcrypt, cliutils, docopt, jester, json, logging,
|
||||||
ospaths, sequtils, strutils, os, tables, times, uuids
|
sequtils, strutils, os, tables, times, uuids
|
||||||
|
|
||||||
import nre except toSeq
|
import nre except toSeq
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ proc loadApiConfig*(json: JsonNode): PtkApiCfg =
|
|||||||
|
|
||||||
template halt(code: HttpCode,
|
template halt(code: HttpCode,
|
||||||
headers: RawHeaders,
|
headers: RawHeaders,
|
||||||
content: string): typed =
|
content: string) =
|
||||||
## Immediately replies with the specified request. This means any further
|
## Immediately replies with the specified request. This means any further
|
||||||
## code will not be executed after calling this template in the current
|
## code will not be executed after calling this template in the current
|
||||||
## route.
|
## route.
|
||||||
@ -55,7 +55,7 @@ template halt(code: HttpCode,
|
|||||||
template checkAuth(cfg: PtkApiCfg) =
|
template checkAuth(cfg: PtkApiCfg) =
|
||||||
## Check this request for authentication and authorization information.
|
## Check this request for authentication and authorization information.
|
||||||
## If the request is not authorized, this template immediately returns a
|
## If the request is not authorized, this template immediately returns a
|
||||||
## 401 Unauthotized response
|
## 401 Unauthotized response
|
||||||
|
|
||||||
var authed {.inject.} = false
|
var authed {.inject.} = false
|
||||||
var user {.inject.}: PtkUser = PtkUser()
|
var user {.inject.}: PtkUser = PtkUser()
|
||||||
|
@ -1 +1 @@
|
|||||||
const PTK_VERSION* = "1.0.6"
|
const PTK_VERSION* = "1.0.7"
|
20
ptk.nim
20
ptk.nim
@ -6,7 +6,7 @@
|
|||||||
import algorithm, docopt, json, langutils, logging, os, nre, std/wordwrap,
|
import algorithm, docopt, json, langutils, logging, os, nre, std/wordwrap,
|
||||||
sequtils, sets, strutils, tempfile, terminal, times, uuids
|
sequtils, sets, strutils, tempfile, terminal, times, uuids
|
||||||
|
|
||||||
import timeutils except `-`;
|
import timeutils except `-`
|
||||||
|
|
||||||
import private/util
|
import private/util
|
||||||
import private/api
|
import private/api
|
||||||
@ -172,15 +172,15 @@ proc filterMarkIndices(timeline: Timeline, args: Table[string, Value]): seq[int]
|
|||||||
|
|
||||||
let marks = timeline.marks
|
let marks = timeline.marks
|
||||||
let now = getTime().local
|
let now = getTime().local
|
||||||
let allIndices = sequtils.toSeq(0..<marks.len).filterIt(marks[it].summary != STOP_MSG).toSet
|
let allIndices = sequtils.toSeq(0..<marks.len).filterIt(marks[it].summary != STOP_MSG).toHashSet
|
||||||
let union = args["--or"]
|
let union = args["--or"]
|
||||||
|
|
||||||
var selected =
|
var selected =
|
||||||
if union: initSet[int]()
|
if union: initHashSet[int]()
|
||||||
else: allIndices
|
else: allIndices
|
||||||
|
|
||||||
template filterMarks(curSet: HashSet[int], pred: untyped): untyped =
|
template filterMarks(curSet: HashSet[int], pred: untyped): untyped =
|
||||||
var res: HashSet[int] = initSet[int]()
|
var res: HashSet[int] = initHashSet[int]()
|
||||||
if union:
|
if union:
|
||||||
for mIdx {.inject.} in allIndices:
|
for mIdx {.inject.} in allIndices:
|
||||||
if pred: res.incl(mIdx)
|
if pred: res.incl(mIdx)
|
||||||
@ -311,11 +311,11 @@ Options:
|
|||||||
".ptkrc", $getEnv("PTKRC"), $getEnv("HOME") & "/.ptkrc"]
|
".ptkrc", $getEnv("PTKRC"), $getEnv("HOME") & "/.ptkrc"]
|
||||||
|
|
||||||
var ptkrcFilename: string =
|
var ptkrcFilename: string =
|
||||||
foldl(ptkrcLocations, if len(a) > 0: a elif existsFile(b): b else: "")
|
foldl(ptkrcLocations, if len(a) > 0: a elif fileExists(b): b else: "")
|
||||||
|
|
||||||
var cfg: JsonNode
|
var cfg: JsonNode
|
||||||
var cfgFile: File
|
var cfgFile: File
|
||||||
if not existsFile(ptkrcFilename):
|
if not fileExists(ptkrcFilename):
|
||||||
warn "ptk: could not find .ptkrc file."
|
warn "ptk: could not find .ptkrc file."
|
||||||
ptkrcFilename = $getEnv("HOME") & "/.ptkrc"
|
ptkrcFilename = $getEnv("HOME") & "/.ptkrc"
|
||||||
try:
|
try:
|
||||||
@ -337,7 +337,7 @@ Options:
|
|||||||
"ptk.log.json"]
|
"ptk.log.json"]
|
||||||
|
|
||||||
var timelineLocation =
|
var timelineLocation =
|
||||||
foldl(timelineLocations, if len(a) > 0: a elif existsFile(b): b else: "")
|
foldl(timelineLocations, if len(a) > 0: a elif fileExists(b): b else: "")
|
||||||
|
|
||||||
# Execute commands
|
# Execute commands
|
||||||
if args["init"]:
|
if args["init"]:
|
||||||
@ -348,7 +348,7 @@ Options:
|
|||||||
let filesToMerge = args["<timeline>"]
|
let filesToMerge = args["<timeline>"]
|
||||||
let timelines = filesToMerge.mapIt(loadTimeline(it))
|
let timelines = filesToMerge.mapIt(loadTimeline(it))
|
||||||
|
|
||||||
let names = timelines.mapIt(it.name).toSet
|
let names = timelines.mapIt(it.name).toHashSet
|
||||||
let mergedName = sequtils.toSeq(names.items).foldl(a & " + " & b)
|
let mergedName = sequtils.toSeq(names.items).foldl(a & " + " & b)
|
||||||
var merged: Timeline = (
|
var merged: Timeline = (
|
||||||
name: mergedName,
|
name: mergedName,
|
||||||
@ -386,7 +386,7 @@ Options:
|
|||||||
time: if args["--time"]: parseTime($args["--time"]) else: now,
|
time: if args["--time"]: parseTime($args["--time"]) else: now,
|
||||||
summary: STOP_MSG,
|
summary: STOP_MSG,
|
||||||
notes: args["--notes"] ?: "",
|
notes: args["--notes"] ?: "",
|
||||||
tags: (args["--tags"] ?: "").split({',', ';'}).filterIt(not it.isNilOrWhitespace))
|
tags: (args["--tags"] ?: "").split({',', ';'}).filterIt(not it.isEmptyOrWhitespace))
|
||||||
|
|
||||||
timeline.marks.add(newMark)
|
timeline.marks.add(newMark)
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ Options:
|
|||||||
time: if args["--time"]: parseTime($args["--time"]) else: now,
|
time: if args["--time"]: parseTime($args["--time"]) else: now,
|
||||||
summary: args["<summary>"] ?: "",
|
summary: args["<summary>"] ?: "",
|
||||||
notes: args["--notes"] ?: "",
|
notes: args["--notes"] ?: "",
|
||||||
tags: (args["--tags"] ?: "").split({',', ';'}).filterIt(not it.isNilOrWhitespace))
|
tags: (args["--tags"] ?: "").split({',', ';'}).filterIt(not it.isEmptyOrWhitespace))
|
||||||
|
|
||||||
if args["--edit"]: newMark = edit(newMark)
|
if args["--edit"]: newMark = edit(newMark)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "1.0.6"
|
version = "1.0.7"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Personal Time Keeper"
|
description = "Personal Time Keeper"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@ -15,9 +15,9 @@ requires @[
|
|||||||
"tempfile",
|
"tempfile",
|
||||||
"isaac >= 0.1.3",
|
"isaac >= 0.1.3",
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"jester 0.4.1",
|
"jester 0.5.0",
|
||||||
"https://git.jdb-labs.com/jdb/nim-lang-utils.git",
|
"https://git.jdb-labs.com/jdb/nim-lang-utils.git",
|
||||||
"https://git.jdb-labs.com/jdb/nim-cli-utils.git",
|
"https://git.jdb-labs.com/jdb/nim-cli-utils.git >= 0.6.5",
|
||||||
"https://git.jdb-labs.com/jdb/nim-time-utils.git >= 0.5.2",
|
"https://git.jdb-labs.com/jdb/nim-time-utils.git >= 0.5.2",
|
||||||
"https://git.jdb-labs.com/jdb/update-nim-package-version"
|
"https://git.jdb-labs.com/jdb/update-nim-package-version"
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user