Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_objs(self):
# Basic type conversion
if self.timeout is not None:
self.objs["timeout"] = datetime.timedelta(seconds=int(self.timeout))
self.objs["format"] = {
key: pydoc.locate(value) for key, value in self.format.items()
}
# Checkers do not depend on anything
self.objs["checker"] = self(_fwd.registry.get_named(self.checker, Checker))
# Searchers only depend on checkers
self.objs["searcher"] = self(_fwd.registry.get_named(self.searcher, Searcher))
def get_resource(self, res_name: str, t: Optional[Type] = None) -> Any:
logger.trace(f"Loading resource {res_name} of type {t}")
# FIXME: Actually returns obj of type `t`, but python is bad
loader, name = split_resource_name(res_name)
if t is None:
return self(_fwd.registry.get_named(loader, ResourceLoader))(name)
else:
return self(_fwd.registry.get_named(loader, ResourceLoader[t]))(name)