From 6eabcc07dbf40b4ef8db6d7a42814016ad1bc954 Mon Sep 17 00:00:00 2001 From: Robert M Ochshorn Date: Sun, 12 Feb 2017 16:18:16 -0500 Subject: [PATCH] move "util" into gentle and adjust paths --- {util => gentle/util}/__init__.py | 0 {util => gentle/util}/cyst.py | 0 {util => gentle/util}/paths.py | 9 +++++---- serve.py | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) rename {util => gentle/util}/__init__.py (100%) rename {util => gentle/util}/cyst.py (100%) rename {util => gentle/util}/paths.py (84%) diff --git a/util/__init__.py b/gentle/util/__init__.py similarity index 100% rename from util/__init__.py rename to gentle/util/__init__.py diff --git a/util/cyst.py b/gentle/util/cyst.py similarity index 100% rename from util/cyst.py rename to gentle/util/cyst.py diff --git a/util/paths.py b/gentle/util/paths.py similarity index 84% rename from util/paths.py rename to gentle/util/paths.py index c2770555..8205dc2c 100644 --- a/util/paths.py +++ b/gentle/util/paths.py @@ -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) @@ -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) diff --git a/serve.py b/serve.py index 505e75a8..b8631c6f 100644 --- a/serve.py +++ b/serve.py @@ -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