def _resolve_urlspec(self, site_name, url_spec):
        if isinstance(url_spec, (list, tuple)):
            url_spec = dict(zip(['pattern', 'handler', 'kwargs', 'name'], url_spec))

        if not 'pattern' in url_spec or not 'handler' in url_spec:
            msg = 'Missing attributes in handler configuration in site [{0}]: [{1}]'.format(site_name, url_spec)
            hint = 'Both "pattern" and "handler" must be defined.'
            raise InvalidHandlerError(msg, hint)

        # string -> class specification
        if isinstance(url_spec['handler'], basestring):
            url_spec['handler'] = {'class':url_spec['handler']}

        if 'provider' in url_spec['handler']:
            handler = url_spec.pop('handler')
            provider = handler['provider']
            dependency = self.dependency_manager.add_dependency(self, handler)
            url_spec.setdefault('kwargs', dict()).update(dependency=dependency)

            if provider.startswith('pipeline.'):
                url_spec['handler_class'] = handlers.PipelineRequestHandler
                return web.url(**url_spec)

            url_spec['handler_class'] = handlers.PipedRequestHandlerProxy(dependency)
            return web.url(**url_spec)

        if 'class' in url_spec['handler']:
            handler = url_spec.pop('handler')

            cls = reflect.namedAny(handler['class'])
            if id(cls) not in self._configured_handler_factory_ids:
                self._configured_handler_factory_ids.add(id(cls))

                try:
                    cls.configure(self.runtime_environment)
                except __HOLE__ as ae:
                    if "has no attribute 'configure'" not in ae.args[0]:
                        raise

            url_spec['handler_class'] = cls
            return web.url(**url_spec)

        msg = 'Invalid handler configuration in site [{0}]: [{1}]'.format(site_name, url_spec)
        raise InvalidHandlerError(msg)
dataset/ETHPy150Open foundit/Piped/contrib/cyclone/piped_cyclone/providers.py/CycloneProvider._resolve_urlspec