Skip to content

[ 2492540 ] File import does not work any more with jsonLoads #439

@HolQue

Description

@HolQue

Hi Son,

the latest change in stabi branch has a side effect:

jsonLoads is not able any more to handle file imports (previously this worked fine).

This is the JSONP snippet:

jsonpStr = """{
    "import_folder" : "dynamic_imports",
    "file_name"     : "imported.AA.jsonp",
    "[import]"      : "./${import_folder}/AA/${file_name}"
}
"""

Because of the import path is relative we need to define referenceDir.

The full path of the file to be imported is:

C:\workplace\ROBFW\TestTestcases\JsonPreprocessor\dynamic_imports\AA\imported.AA.jsonp

Therefore, referenceDir has to be: C:\workplace\ROBFW\TestTestcases\JsonPreprocessor

Full python code:

json_preprocessor = CJsonPreprocessor()
try:
    retValues = json_preprocessor.jsonLoads(jsonpStr, referenceDir=r"C:\workplace\ROBFW\TestTestcases\JsonPreprocessor")
except Exception as reason:
    sException = f"'{reason}'"
    print()
    printerror(sException)

Result:

Error: ''NoneType' object has no attribute 'getPathToRoot''!

But file should be imported and the content should be returned.

Metadata

Metadata

Assignees

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions