Skip to content

Commit 29fe92c

Browse files
committed
improved path handling in cli import script
1 parent 840d83b commit 29fe92c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cli/import/importDataset.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
from uuid import uuid1
55
from jsonschema import validate
66
from json import dumps, load
7-
from os.path import basename, join, dirname, realpath
8-
from os import getcwd
7+
from os.path import basename, join, dirname, abspath
8+
from pathlib import Path
99

1010
DB_NAME = "gnom_db"
1111
HELP_STRING = "Example call: python3 importDataset.py PATH/TO/JSON"
1212
BASE_PATH_TO_IMPORT = "/flask-backend/data/import/"
1313

14-
__location__ = realpath(join(getcwd(), dirname(__file__)))
14+
__location__ = Path(abspath(dirname(__file__)))
15+
__project_dir__ = __location__.parent.absolute().parent.absolute()
1516

1617

1718
def loadDataset(datasets_path):
@@ -44,7 +45,7 @@ def loadDataset(datasets_path):
4445
print("Valid inputs...", flush=True)
4546

4647
try:
47-
with open(join(__location__, "../../local.config")) as config_file:
48+
with open(join(__project_dir__, "local.config")) as config_file:
4849
config_params = config_file.readlines()
4950
config_file.close()
5051

0 commit comments

Comments
 (0)