Created
December 12, 2019 10:36
-
-
Save JohnDowson/cee03864642f4b151b6caddea698bd7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConfigParam(): | |
def __init__(self, param_name, param_type, default): | |
self.param_name = param_name | |
# get parameter from config | |
_param = param_from_config() | |
if param_type: | |
# cast it to required type | |
self.value = asWhateverType(_param) | |
def __hash__(self): | |
self.param_name.__hash__ | |
class ModuleParams(): | |
def add(self, config_param): | |
self.__setattr__(config_param.param_name, config_param.value) | |
class Module(): | |
def __init__(self): | |
super() | |
self.params.add(ConfigParam('show_stuff', bool, True)) | |
def update(self): | |
if self.params.show_stuff: | |
showStuff() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment