Returns a dict representation of OneOfConfig. For the nested base_config.Config, a nested dict will be returned.
(self)
| 30 | type: Optional[str] = None |
| 31 | |
| 32 | def as_dict(self): |
| 33 | """Returns a dict representation of OneOfConfig. |
| 34 | |
| 35 | For the nested base_config.Config, a nested dict will be returned. |
| 36 | """ |
| 37 | if self.type is None: |
| 38 | return {'type': None} |
| 39 | elif self.__dict__['type'] not in self.__dict__: |
| 40 | raise ValueError('type: {!r} is not a valid key!'.format( |
| 41 | self.__dict__['type'])) |
| 42 | else: |
| 43 | chosen_type = self.type |
| 44 | chosen_value = self.__dict__[chosen_type] |
| 45 | return {'type': self.type, chosen_type: self._export_config(chosen_value)} |
| 46 | |
| 47 | def get(self): |
| 48 | """Returns selected config based on the value of type. |