From 408ffb8fca2c3fd5c16f70ee2a954d9cf3d48585 Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Sun, 4 Nov 2018 19:42:13 -0600 Subject: [PATCH] added ROOT constant for module dir --- ext_open/config.py | 3 ++- ext_open/opener.py | 4 ++-- ext_open/opts.py | 4 +++- ext_open/searcher.py | 1 - 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ext_open/config.py b/ext_open/config.py index d707556..7e3be2b 100644 --- a/ext_open/config.py +++ b/ext_open/config.py @@ -2,7 +2,8 @@ import configparser import re import os.path as osp # https://stackoverflow.com/a/11866695 -CONFIG_PATH = osp.join(osp.dirname(__file__),'config.ini') +ROOT = osp.dirname(__file__) +CONFIG_PATH = osp.join(ROOT,'config.ini') class MyParser(configparser.ConfigParser): def __init__(self): super().__init__(interpolation = configparser.ExtendedInterpolation()) diff --git a/ext_open/opener.py b/ext_open/opener.py index fe55797..02dd97a 100644 --- a/ext_open/opener.py +++ b/ext_open/opener.py @@ -1,5 +1,5 @@ from binaryornot.check import is_binary -from config import config +from config import config,ROOT import os import shlex import subprocess @@ -21,7 +21,7 @@ def standalone(path,params=[],windowless =False,cwd = None): if __name__ == "__main__": path2windowless = 'windowless.vbs' else: - path2windowless = os.path.join(os.path.dirname(__file__),'windowless.vbs') + path2windowless = os.path.join(ROOT,'windowless.vbs') params = list(map(os.path.expandvars,params)) if not cwd: cwd = os.path.dirname(path) diff --git a/ext_open/opts.py b/ext_open/opts.py index d86f39e..490c084 100644 --- a/ext_open/opts.py +++ b/ext_open/opts.py @@ -1,7 +1,9 @@ +from config import ROOT import copy import json import os import shutil + class ArgumentHandler: def __init__(self,args_file): @@ -91,7 +93,7 @@ class ArgumentContainer: def __repr__(self): return str(self) -cur = ArgumentHandler('opts.json') +cur = ArgumentHandler(os.path.join(ROOT,'opts.json')) globals().update((key,cur.data[key]) for key in ['bools', 'exe', 'exts', 'other', 'prefix', 'prefix_char']) common = bools+other exe += bools \ No newline at end of file diff --git a/ext_open/searcher.py b/ext_open/searcher.py index ceb2251..13182ef 100644 --- a/ext_open/searcher.py +++ b/ext_open/searcher.py @@ -7,7 +7,6 @@ import time import update osp = os.path DB_PATH = config.getpath('global','db_path') -PARENT = osp.join(osp.dirname(__file__)) UPDATE_PY = update.__file__ ext_database = sqlite3.connect(DB_PATH)