Skip to content

Commit

Permalink
move "util" into gentle and adjust paths
Browse files Browse the repository at this point in the history
  • Loading branch information
strob committed Feb 12, 2017
1 parent 2fdc4bf commit 6eabcc0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions util/paths.py → gentle/util/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class SourceResolver:
def __init__(self):
self.project_root = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
self.project_root = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir))

def get_binary(self, name):
path_in_project = os.path.join(self.project_root, name)
Expand All @@ -32,17 +32,18 @@ def get_binary(self, name):
return os.path.join(self.root, name)

def get_resource(self, name):
rpath = os.path.join(self.root, path)
rpath = os.path.join(self.root, name)
if os.path.exists(rpath):
return rpath
else:
return get_datadir(path) # DMG may be read-only; fall-back to datadir (ie. so language models can be added)
return get_datadir(name) # DMG may be read-only; fall-back to datadir (ie. so language models can be added)

def get_datadir(self, path):
return os.path.join(os.environ['HOME'], '.gentle')
return os.path.join(os.environ['HOME'], '.gentle', path)

RESOLVER = PyinstallResolver() if hasattr(sys, "frozen") else SourceResolver()


def get_binary(name):
return RESOLVER.get_binary(name)

Expand Down
4 changes: 2 additions & 2 deletions serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import uuid
import wave

from util.paths import get_resource, get_datadir
from util.cyst import Insist
from gentle.util.paths import get_resource, get_datadir
from gentle.util.cyst import Insist

import gentle

Expand Down

0 comments on commit 6eabcc0

Please sign in to comment.