test-fullautomation / python-jsonpreprocessor

A preprocessor for json files
Apache License 2.0
2 stars 2 forks source link

Master file path computation incomplete #152

Closed HolQue closed 8 months ago

HolQue commented 9 months ago

A batch file calls a Python script. Within this Python script a JSON file is loaded in the following way:

json_preprocessor.jsonLoad("./file.jsonp")

Expected is that the path of the executed Python script is the reference for the relative path to the loaded JSON file.

In opposite to this expectation the JsonPreprocessor uses the current working directory. The current working directory depends on the position of the batch file. Therefore this solution only works if batch file and Python script are placed in the same folder. This cannot be assumed in every case and this also should not be a requirement.

CRQ: It has to be coded explicitely, that the path to the executed Python script is the reference for all relative paths, used inside this script.

Proposal:

The line

jFile = CString.NormalizePath(jFile)

has to be replaced by

jFile = CString.NormalizePath(jFile, sReferencePathAbs=os.path.dirname(sys.argv[0]))

This solves the problem.

namsonx commented 9 months ago

Hello Thomas, Hello Holger,

I created new commit 8e1eb4c29 on stabi branch for this ticket.

Thank you, Son

test-fullautomation commented 8 months ago

@HolQue : did you retest?

HolQue commented 8 months ago

Retest successful.

Reference: JPP_1200-(PATH_FORMATS)-[GOODCASE]

Issue can be closed.