Skip to content

Instantly share code, notes, and snippets.

@isgursoy
Created September 12, 2019 01:54
Show Gist options
  • Select an option

  • Save isgursoy/262973630a2a3437d1d92db6e0f7633e to your computer and use it in GitHub Desktop.

Select an option

Save isgursoy/262973630a2a3437d1d92db6e0f7633e to your computer and use it in GitHub Desktop.
TabNine Bin Path Query
import os
import sys
def parse_semver(s):
try:
return [int(x) for x in s.split('.')]
except ValueError:
return []
def main():
translation = {
("linux", "x32"): "i686-unknown-linux-gnu/TabNine",
("linux", "x64"): "x86_64-unknown-linux-gnu/TabNine",
("osx", "x32"): "i686-apple-darwin/TabNine",
("osx", "x64"): "x86_64-apple-darwin/TabNine",
("windows", "x32"): "i686-pc-windows-gnu/TabNine.exe",
("windows", "x64"): "x86_64-pc-windows-gnu/TabNine.exe",
}
binary_dir=str(sys.argv[1])
versions = os.listdir(binary_dir)
versions.sort(key=parse_semver, reverse=True)
for version in versions:
key = "linux", "x64"
path = os.path.join(binary_dir, version, translation[key])
if os.path.isfile(path):
os.chmod(path, 0o777)
sys.stdout.write(path)
sys.stdout.flush()
sys.exit(0)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment