Coverage for yaptide/converter/converter/topas/parser.py: 43%
14 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-07-01 12:55 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-07-01 12:55 +0000
1from converter.common import Parser
2from converter.topas.config import Config
5class TopasParser(Parser):
6 """A simple placeholder parser that parses energy and number of particles."""
8 def __init__(self) -> None:
9 super().__init__()
10 self.info['simulator'] = 'topas'
11 self.config = Config()
13 def parse_configs(self, json: dict) -> None:
14 """Basicaly do nothing since we work on defaults in this parser."""
15 self.config.energy = json["beam"]["energy"]
16 self.config.num_histories = json["beam"].get("numberOfParticles", self.config.num_histories)
18 def get_configs_json(self) -> dict:
19 """
20 Return a dict representation of the config files. Each element has
21 the config files name as key and its content as value.
22 """
23 configs_json = super().get_configs_json()
24 configs_json["topas_config.txt"] = str(self.config)
26 return configs_json