diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-09-11 08:17:46 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-09-11 08:17:46 +0200 |
| commit | 75c2ce0991dabccfaad5b6f1d72175566ce75467 (patch) | |
| tree | bf50c54fac012bc7da0bfa6f53a2d18585aff7f0 | |
| parent | be1966b40fba00e374433d4b7d93598b0ca35223 (diff) | |
Improve platform parsing
| -rw-r--r-- | esds/helpers/platform.py | 17 | ||||
| -rw-r--r-- | example/platform.yaml | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/esds/helpers/platform.py b/esds/helpers/platform.py index 7d16756..7112ebc 100644 --- a/esds/helpers/platform.py +++ b/esds/helpers/platform.py @@ -47,6 +47,8 @@ class YAMLPlatformFile: self.default={ "breakpoints": [], "breakpoints_every": None, + "breakpoints_file": None, + "breakpoints_callback": None, "debug": False, "interferences": True, "node_count": 0, @@ -71,7 +73,9 @@ class YAMLPlatformFile: else: self.parsing_error("platform file has no interfaces section") - print(self.default) + ##### Sanity checks + if None in self.default["implementations"]: + self.parsing_error("Some nodes do not have assigned implementation") def parsing_error(self,msg): raise Exception("Fail to parse platform file \""+self.file_path+"\": "+msg) @@ -162,6 +166,17 @@ class YAMLPlatformFile: if not str(general["breakpoints_every"]).isnumeric(): self.parsing_error("breakpoints_every should be a number") self.default["breakpoints_every"]=general["breakpoints_every"] + if "breakpoints_callback" in general: + cb=general["breakpoints_callback"] + file=cb["file"] + path, ext=os.path.splitext(file) + if not os.path.exists(file): + self.parsing_error("File "+file+ " not found") + path, extension = os.path.splitext(file) + if extension != ".py": + self.parsing_error("File "+file+" must be a python file") + self.default["breakpoints_file"]=cb["file"] + self.default["breakpoints_callback"]=cb["callback"] if "debug" in general: if type(general["debug"]) != bool: self.parsing_error("debug should be on or off") diff --git a/example/platform.yaml b/example/platform.yaml index 0f6134e..5aa65e3 100644 --- a/example/platform.yaml +++ b/example/platform.yaml @@ -1,9 +1,13 @@ general: breakpoints: [] breakpoints_every: 0 + breakpoints_callback: + file: "platform_test.py" + callback: "callback" debug: off interferences: on + nodes: count: 5 implementations: |
