def resolve_source(self, source, resolve_context): resolver = resolverlib.for_resdef_source(source, self) if not resolver: raise DependencyError("unsupported source '%s' in %s resource" % (source, self.resdef.name)) try: source_paths = resolver.resolve(resolve_context) except resolverlib.ResolutionError as e: msg = "could not resolve '%s' in %s resource: %s" % ( source, self.resdef.name, e, ) if source.help: msg += "\n%s" % source.help raise DependencyError(msg) except Exception as e: log.exception( "resolving required source '%s' in %s resource", source, self.resdef.name, ) raise DependencyError( "unexpected error resolving '%s' in %s resource: %r" % (source, self.resdef.name, e)) else: for path in source_paths: self._link_to_source(path, source) return source_paths
def _resolve_source_for_location(source, dep, location, resolve_context): res_proxy = ResourceProxy(location, dep.config) resolver = resolverlib.for_resdef_source(source, res_proxy) if not resolver: raise OpDependencyError("unsupported source '%s' in %s resource" % (source, dep.resdef.name)) return resolver.resolve(resolve_context)
def _iter_op_resolvers(resource_deps, opdef): ctx = deps.ResolutionContext(None, opdef, {}) for name, dep in resource_deps.items(): res = deps.resources([dep], ctx)[0] for source in res.resdef.sources: source_resolver = resolver.for_resdef_source(source, res) if isinstance(source_resolver, resolver.OperationOutputResolver): yield name, source_resolver
def resolver_for_source(source, dep): res_proxy = ResourceProxy(dep.res_location, dep.config) return resolverlib.for_resdef_source(source, res_proxy)