-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from davidvlaminck/concrete_relations
Concrete relations
- Loading branch information
Showing
16 changed files
with
5,509 additions
and
2,830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 29 additions & 11 deletions
40
UnitTests/TestModel/OtlmowModel/Helpers/generated_lists.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
import json | ||
from pathlib import Path | ||
from typing import Dict | ||
|
||
global_relation_dict: Dict = {} | ||
global_relation_dict: dict = {} | ||
global_class_dict: dict = {} | ||
|
||
ROOT_PATH = Path(__file__).parent | ||
MODEL_ROOT_PATH = Path(__file__).parent.parent.parent | ||
|
||
|
||
def get_hardcoded_relation_dict(relation_dict: Dict = None): | ||
if relation_dict is None: | ||
relation_dict = global_relation_dict | ||
def get_hardcoded_relation_dict(model_directory: Path = None) -> dict: | ||
global global_relation_dict | ||
if global_relation_dict != {}: | ||
return global_relation_dict | ||
|
||
if relation_dict == {}: | ||
# open json file | ||
with open(ROOT_PATH.parent / 'generated_info.json', 'r') as f: | ||
relation_dict = json.load(f) | ||
if model_directory is None: | ||
model_directory = MODEL_ROOT_PATH | ||
|
||
return relation_dict | ||
with open(model_directory / 'OtlmowModel' / 'generated_info.json', 'r') as f: | ||
generated_info_dict = json.load(f) | ||
global_relation_dict = generated_info_dict['relations'] | ||
|
||
return global_relation_dict | ||
|
||
|
||
def get_hardcoded_class_dict(model_directory: Path = None) -> dict: | ||
global global_class_dict | ||
if global_class_dict != {}: | ||
return global_class_dict | ||
|
||
if model_directory is None: | ||
model_directory = MODEL_ROOT_PATH | ||
|
||
with open(model_directory / 'OtlmowModel' / 'generated_info.json', 'r') as f: | ||
generated_info_dict = json.load(f) | ||
global_class_dict = generated_info_dict['classes'] | ||
|
||
return global_class_dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.