From a7d42c139764801fdd86fd2dda8b2cc74c519b03 Mon Sep 17 00:00:00 2001 From: mas2hc Date: Tue, 10 Jan 2023 10:47:17 +0700 Subject: [PATCH] Fix issue34 - absolute paths in sample --- sample/001_sample_comments.py | 5 +++-- sample/003_sample_import.py | 5 +++-- sample/005_sample_python_syntax.py | 5 +++-- sample/007_sample_use_of_variables.py | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sample/001_sample_comments.py b/sample/001_sample_comments.py index 93018399..c38a31e2 100644 --- a/sample/001_sample_comments.py +++ b/sample/001_sample_comments.py @@ -17,8 +17,9 @@ ## in json files. import sys +import os -sys.path.append('D:\B\python-jsonpreprocessor') +sys.path.append(os.path.abspath(os.path.dirname(__file__) + "/../")) from JsonPreprocessor import CJsonPreprocessor @@ -31,7 +32,7 @@ # - absolute path # - paths containting environment variables by means of # %envvariable% syntax -data=prepro.jsonLoad(".\json\json_with_comment.json") +data=prepro.jsonLoad(os.path.dirname(__file__) + "/json/json_with_comment.json") pprint(data) diff --git a/sample/003_sample_import.py b/sample/003_sample_import.py index 71aa1c94..003e6ae5 100644 --- a/sample/003_sample_import.py +++ b/sample/003_sample_import.py @@ -17,8 +17,9 @@ ## into json files. import sys +import os -sys.path.append('D:\B\python-jsonpreprocessor') +sys.path.append(os.path.abspath(os.path.dirname(__file__) + "/../")) from JsonPreprocessor import CJsonPreprocessor @@ -31,7 +32,7 @@ # - absolute path # - paths containting environment variables by means of # %envvariable% syntax -data=prepro.jsonLoad(".\json\json_with_import.json") +data=prepro.jsonLoad(os.path.dirname(__file__) + "/json/json_with_import.json") pprint(data) diff --git a/sample/005_sample_python_syntax.py b/sample/005_sample_python_syntax.py index 48459831..6d635db3 100644 --- a/sample/005_sample_python_syntax.py +++ b/sample/005_sample_python_syntax.py @@ -17,8 +17,9 @@ ## as part of json files. import sys +import os -sys.path.append('D:\B\python-jsonpreprocessor') +sys.path.append(os.path.abspath(os.path.dirname(__file__) + "/../")) from JsonPreprocessor import CJsonPreprocessor from JsonPreprocessor import CSyntaxType @@ -34,7 +35,7 @@ # - absolute path # - paths containting environment variables by means of # %envvariable% syntax -data=prepro.jsonLoad(".\json\json_with_python_syntax.json") +data=prepro.jsonLoad(os.path.dirname(__file__) + "/json/json_with_python_syntax.json") pprint(data) diff --git a/sample/007_sample_use_of_variables.py b/sample/007_sample_use_of_variables.py index e7b4023a..9b2e1bda 100644 --- a/sample/007_sample_use_of_variables.py +++ b/sample/007_sample_use_of_variables.py @@ -17,8 +17,9 @@ ## in json files. import sys +import os -sys.path.append('D:\B\python-jsonpreprocessor') +sys.path.append(os.path.abspath(os.path.dirname(__file__) + "/../")) from JsonPreprocessor import CJsonPreprocessor @@ -31,7 +32,7 @@ # - absolute path # - paths containting environment variables by means of # %envvariable% syntax -data=prepro.jsonLoad(".\json\json_with_variables.json") +data=prepro.jsonLoad(os.path.dirname(__file__) + "/json/json_with_variables.json") pprint(data)