|
35 | 35 | class Args:
|
36 | 36 | verbose: bool # verbose logging
|
37 | 37 | cbid: bool # force color by id
|
38 |
| - cfg: str | None # config path |
| 38 | + cfg: str # config path |
39 | 39 | frac: float | None # fraction of points to render
|
40 | 40 | voxel_size: float | None # voxel size for downsampling
|
41 | 41 | downsample: bool # downsample based on either voxel size or fraction
|
@@ -278,9 +278,24 @@ def __setup(self) -> None:
|
278 | 278 | 'Failed to parse json config file : '
|
279 | 279 | 'maximum nesting level could be reached, please check your file\n%s', e)
|
280 | 280 | sys.exit(1)
|
281 |
| - default: dict[str, Any] = raw_data['default'] |
282 |
| - configs: list[dict[str, Any]] = raw_data['configs'] |
283 |
| - cfgs = [Config.from_json(json=cfg, **default) for cfg in configs] |
| 281 | + if not raw_data: |
| 282 | + self.log.critical('Failed to parse %s : empty file', self.args.cfg) |
| 283 | + sys.exit(1) |
| 284 | + default: dict[str, Any] = None |
| 285 | + configs: list[dict[str, Any]] = None |
| 286 | + try: |
| 287 | + default = raw_data['default'] |
| 288 | + configs = raw_data['configs'] |
| 289 | + except KeyError as e: |
| 290 | + self.log.critical('Failed to parse %s : %s', self.args.cfg, e) |
| 291 | + sys.exit(1) |
| 292 | + cfgs: list[Config] = [] |
| 293 | + try: |
| 294 | + for cfg in configs: |
| 295 | + cfgs.append(Config.from_json(json=cfg, **default)) |
| 296 | + except ValueError as e: |
| 297 | + self.log.critical('Failed to parse config n°%d : %s', len(cfgs), e) |
| 298 | + sys.exit(1) |
284 | 299 |
|
285 | 300 | fset: list[int] = None
|
286 | 301 | if self.args.only and any(map(lambda x: x > len(cfgs), self.args.only)): # pylint: disable=bad-builtin
|
|
0 commit comments