32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from ScEpTIC.config.base_config import ScEpTICBaseConfig
|
|
from ScEpTIC.AST.transformations import CONFIG_FUNCTION_NAME
|
|
|
|
class ASTTransformationsConfig(ScEpTICBaseConfig):
|
|
"""
|
|
Configuration for AST Transformations
|
|
"""
|
|
_config_domain = {
|
|
'transformations': {'class': str, 'mode': 'add'},
|
|
}
|
|
|
|
|
|
def __init__(self, main_config):
|
|
super().__init__(main_config)
|
|
self.transformations = []
|
|
|
|
self._register_config_callback("transformations", self._transformation_callback)
|
|
|
|
self.add_config('transformations', 'base')
|
|
|
|
|
|
def _transformation_callback(self, config_name, config_value):
|
|
"""
|
|
Callback to add transformation configuration
|
|
:param config_name: the configuration name
|
|
:param config_value: the configuration value
|
|
"""
|
|
module_name = 'ScEpTIC.AST.transformations.{}.config'.format(config_value)
|
|
module = __import__(module_name, fromlist=[CONFIG_FUNCTION_NAME])
|
|
config = getattr(module, CONFIG_FUNCTION_NAME)
|
|
setattr(self, config_value, config(self._main_config))
|