def _convert_val(self, param_type, val): if param_type["type"] == "native": switch = { "str" : lambda x: str(x), "list" : lambda x: list(x), "tuple" : lambda x: tuple(x), "dict" : lambda x: dict(x), "int" : lambda x: int(x), "float" : lambda x: float(x), "unicode" : lambda x: unicode(x) } return switch[param_type["name"]](val) elif param_type["type"] == "fileset": val = FileSet(val) return val elif param_type["type"] == "component": # val should be like this: # { "class": "SpecificComponent", "params": {} } # # allow for inheritance by letting the json specify the # specific class that will be used component_cls = self._get_component_cls(val["class"]) component_args = self._convert_params(val["params"], component_cls) val = component_cls(parent_log = self._log, job = self) val.init(**component_args) return val
def __init__(self, id, idx, params, tool, fileset_id, progress_callback, results_callback): """TODO: to be defined1. :idx: TODO :params: TODO :tool: TODO :fileset_id: The id of the default fileset that files should be added to """ self._id = id self._idx = idx self._params = params self._tool = tool self._fileset_id = fileset_id self._fileset = FileSet(self._fileset_id) self._progress_callback = progress_callback self._results_callback = results_callback self._log = logging.getLogger("JOB:{}".format(self._id))
def _convert_val(self, param_type, val): if param_type["type"] == "native": switch = { "str": lambda x: str(x), "list": lambda x: list(x), "tuple": lambda x: tuple(x), "dict": lambda x: dict(x), "int": lambda x: int(x), "float": lambda x: float(x), "unicode": lambda x: unicode(x) "bool" : self._to_bool, } return switch[param_type["name"]](val) elif param_type["type"] == "fileset": val = FileSet(val) return val elif param_type["type"] == "component": # val should be like this: # { "class": "SpecificComponent", "params": {} } # # allow for inheritance by letting the json specify the # specific class that will be used component_cls = self._get_component_cls(val["class"]) component_args = self._convert_params(val["params"], component_cls) val = component_cls(parent_log=self._log, job=self) val.init(**component_args) return val