Skip to content

Commit

Permalink
fallback on .gentle for get_resourcepath
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert M Ochshorn authored and Robert M Ochshorn committed May 27, 2016
1 parent 5c8340c commit d319c2f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gentle/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ def get_binary(name):
elif os.path.exists(name):
binpath = "./%s" % (name)

logging.info("binpath %s", binpath)
logging.debug("binpath %s", binpath)
return binpath

def get_resource(path):
rpath = path
if hasattr(sys, "frozen"):
rpath = os.path.abspath(os.path.join(sys._MEIPASS, '..', 'Resources', path))
logging.info("resourcepath %s", rpath)
if not os.path.exists(rpath):
# DMG may be read-only; fall-back to datadir (ie. so language models can be added)
rpath = get_datadir(path)
logging.debug("resourcepath %s", rpath)
return rpath

def get_datadir(path):
datadir = path
if hasattr(sys, "frozen"):# and sys.frozen == "macosx_app":
datadir = os.path.join(os.environ['HOME'], '.gentle', path)
logging.info("datadir %s", datadir)
logging.debug("datadir %s", datadir)
return datadir

0 comments on commit d319c2f

Please sign in to comment.