Skip to content

Commit

Permalink
Report version number of native module for debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
raghur committed Oct 7, 2018
1 parent aa1727a commit af27fa6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rplugin/python3/denite/filter/matcher/fruzzymatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ def __init__(self, vim):
import fruzzy_mod
self.nativeMethod = fruzzy_mod.scoreMatchesStr
self.useNative = True
if 'version' not in dir(fruzzy_mod):
self.debug("You have an old version of the native module")
self.debug("please execute :call fruzzy#install()")
else:
self.debug("fruzzy_mod ver: %s" %
fruzzy_mod.version())
except ImportError:
self.debug("Native module requested but unable to load native module")
self.debug("Native module requested but module was not found")
self.debug("falling back to python implementation")
self.debug("Check if you have nim_fuzzy.so or nim_fuzzy.pyd at %s" %
self.debug("execute :call fruzzy#install() to install the native module")
self.debug("and then check if you have fruzzy_mod.so or fruzzy_mod.pyd at %s" %
pkgPath)
self.useNative = False
self.debug("usenative: %s" % self.useNative)
Expand Down
11 changes: 11 additions & 0 deletions rplugin/python3/fruzzy_mod.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import strformat
import sequtils
import tables
import os
import system

proc getVersion(): string {.compileTime.}=
let ver = staticExec("git describe --tags --always --dirty")
# let cTime = format(times.now(), "yyyy-MM-dd hh:mm:ss")
let branch = staticExec("git rev-parse --abbrev-ref HEAD")
return &"rev: {ver} on branch: {branch}"

let L = newConsoleLogger(levelThreshold = logging.Level.lvlDebug)
addHandler(L)
const MAXCHARCOUNT = 30

const sep:string = "-/\\_. "
const VERSION = getVersion()

template info(args: varargs[string, `$`]) =
when not defined(removelogger):
Expand Down Expand Up @@ -315,3 +323,6 @@ proc baseline(candidates: openarray[string] ): seq[tuple[i:int, r:int]] {.export
idx.inc
result.setlen(idx)
return

proc version():string {.exportpy.} =
return VERSION

0 comments on commit af27fa6

Please sign in to comment.