Return an instance of CrawlModel.
172374
def get_instance(page_to_crawl):
    """"""
    global _instances
    if isinstance(page_to_crawl, basestring):
        uri = page_to_crawl
        page_to_crawl = crawlpage.get_instance(uri)
    elif isinstance(page_to_crawl, crawlpage.CrawlPage):
        uri = page_to_crawl.uri
    else:
        raise TypeError(
            "get_instance() expects a parker.CrawlPage "
            "or basestring derivative."
        )

    try:
        instance = _instances[uri]
    except KeyError:
        instance = CrawlModel(page_to_crawl)
        _instances[uri] = instance

    return instance
863017
def to_model(self):
        """"""
        e = ApiPool().current_server_api.model.Error(
            status=self.status,
            error=self.code.upper(),
            error_description=str(self),
        )
        if self.error_id:
            e.error_id = self.error_id
        if self.user_message:
            e.user_message = self.user_message
        if self.error_caught:
            e.error_caught = pformat(self.error_caught)
        return e
862630
def model(self, model, create=True):
        ''''''
        manager = self.manager(model)
        sm = self._models.get(manager)
        if sm is None and create:
            sm = SessionModel(manager)
            self._models[manager] = sm
        return sm
186464
def extract(self, url=None, raw_html=None):
        
        cc = CrawlCandidate(self.config, url, raw_html)
        return self.crawl(cc)
1112305
function(crawler) {
		var dir = gui.Spirit.prototype.oncrawler.call(this, crawler);
		if (dir === gui.Crawler.CONTINUE) {
			switch (crawler.type) {
				case gui.CRAWLER_VISIBLE:
				case gui.CRAWLER_INVISIBLE:
					if (this._waiting) {
						dir = gui.Crawler.STOP;
					}
					break;
			}
		}
		return dir;
	}
814830
def get_instance(page_to_consume):
    """"""
    global _instances
    if isinstance(page_to_consume, basestring):
        uri = page_to_consume
        page_to_consume = consumepage.get_instance(uri)
    elif isinstance(page_to_consume, consumepage.ConsumePage):
        uri = page_to_consume.uri
    else:
        raise TypeError(
            "get_instance() expects a parker.ConsumePage "
            "or basestring derivative."
        )

    try:
        instance = _instances[uri]
    except KeyError:
        instance = ConsumeModel(page_to_consume)
        _instances[uri] = instance

    return instance
184002
def get_instance(model, instance_id):
    
    try:
        model = get_model(model)
    except ImportError:
        return None

    return model.query.get(instance_id)
515030
def get_instance_by_slug(model, slug, **kwargs):
    
    try:
        model = get_model(model)
    except ImportError:
        return None

    query_params = dict(kwargs)
    query_params['slug'] = slug

    return model.query.filter_by(**query_params).first()
1238077
def find_model(self, constructor, constraints=None, *, columns=None, table_name=None,
                 order_by=None):
    """"""
    return self._find_model(constructor, table_name or constructor.table_name, constraints,
                            columns=columns, order_by=order_by)
297382
def get_object(request, pid):
    """"""
    sciobj = d1_gmn.app.models.ScienceObject.objects.get(pid__did=pid)
    content_type_str = d1_gmn.app.object_format_cache.get_content_type(
        sciobj.format.format
    )
    # Return local or proxied SciObj bytes
    response = django.http.StreamingHttpResponse(
        _get_sciobj_iter(sciobj), content_type_str
    )
    d1_gmn.app.views.headers.add_sciobj_properties_headers_to_response(response, sciobj)
    d1_gmn.app.event_log.log_read_event(pid, request)
    return response
163172
def get(cls, id_):
        """"""
        with db.session.no_autoflush:
            query = cls.dbmodel.query.filter_by(id=id_)
            try:
                model = query.one()
            except NoResultFound:
                raise WorkflowsMissingObject("No object for for id {0}".format(
                    id_
                ))
            return cls(model)
1098972
public function getCrawler()
    {
        if (!$this->crawler instanceof Crawler) {
            $this->crawler = new Crawler('', $this->getUri()->toString());
            $this->crawler->addContent(
                $this->getResponse()->getBody()->__toString(),
                $this->getResponse()->getHeaderLine('Content-Type')
            );
        }
        return $this->crawler;
    }
231479
def get_current_item(self):
        """"""
        l = self.selectedIndexes()
        if len(l) > 0:
            return self.model().get_item(l[0])
560622
def query(self, model, **kwargs):
        ''''''
        sm = self.model(model)
        query_class = sm.manager.query_class or Query
        return query_class(sm._meta, self, **kwargs)
1258340
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'url') and self.url is not None:
            _dict['url'] = self.url
        if hasattr(self, 'limit_to_starting_hosts'
                  ) and self.limit_to_starting_hosts is not None:
            _dict['limit_to_starting_hosts'] = self.limit_to_starting_hosts
        if hasattr(self, 'crawl_speed') and self.crawl_speed is not None:
            _dict['crawl_speed'] = self.crawl_speed
        if hasattr(self, 'allow_untrusted_certificate'
                  ) and self.allow_untrusted_certificate is not None:
            _dict[
                'allow_untrusted_certificate'] = self.allow_untrusted_certificate
        if hasattr(self, 'maximum_hops') and self.maximum_hops is not None:
            _dict['maximum_hops'] = self.maximum_hops
        if hasattr(self,
                   'request_timeout') and self.request_timeout is not None:
            _dict['request_timeout'] = self.request_timeout
        if hasattr(
                self,
                'override_robots_txt') and self.override_robots_txt is not None:
            _dict['override_robots_txt'] = self.override_robots_txt
        return _dict
1106781
def from_model(cls, document):
        
        return cls(meta={'id': document.id}, **cls.serialize(document))
971464
def get_model(self, entity_cls):
        """"""
        entity_record = self._get_entity_by_class(entity_cls)

        model_cls = None
        if entity_record.model_cls:
            model_cls = entity_record.model_cls
        else:
            # We should ask the Provider to give a fully baked model the first time
            #   that has been initialized properly for this entity
            provider = self.get_provider(entity_record.provider_name)
            baked_model_cls = provider.get_model(entity_record.entity_cls)

            # Record for future reference
            new_entity_record = entity_record._replace(model_cls=baked_model_cls)
            self._registry[entity_record.qualname] = new_entity_record

            model_cls = baked_model_cls

        return model_cls