Search for a particular slug
967990
def get_search_for_slugs(self, slug):
    
    return _get_request(_SLUG_SEARCH.format(c_api=_C_API_BEGINNING,
                                            api=_API_VERSION,
                                            slug=_format_query(slug),
                                            at=self.access_token))
1086680
protected function getContentBySlug($slug) {
        $this->CmsContent = TableRegistry::get('CmsContent');
        $query = $this->CmsContent->find('all');
        $query->where(['name' => $slug]);
        $data = $query->first();
        return $data;
    }
402236
def slug_from_dict(d, max_len=128, delim='-'):
    
    return slug_from_iter(list(d.values()), max_len=max_len, delim=delim)
507987
public static function findBySlug($slug, $postTypeSlug = '')
    {
        $postTypeSlug = ($postTypeSlug ? $postTypeSlug : PostType::getSlug());

        $postObj = (new Post())->setTable($postTypeSlug);
        $post = $postObj
            ->where('slug_'.App::getLocale(), $slug)
            ->with($postObj->getDefaultRelations(getPostType($postTypeSlug)))
            ->first();

        return $post;
    }
430909
def _query_filter(search, urlkwargs, definitions):
    """"""
    filters, urlkwargs = _create_filter_dsl(urlkwargs, definitions)

    for filter_ in filters:
        search = search.filter(filter_)

    return (search, urlkwargs)
742713
public static function findBySlugOrFail($slug, array $columns = ['*'])
    {
        // Model not found, throw exception
        if (!$item = static::findBySlug($slug)) {
            throw (new ModelNotFoundException)->setModel(get_called_class());
        }

        // Return the model if visible
        $item->enforceVisibility();

        return $item;
    }
410212
def find(self, query):
        ''''''
        if self.upstream:
            return self.upstream.find(query)
        else:
            return False
1316156
def auto_slug(self):
        
        slug = self.name
        if slug is not None:
            slug = slugify(slug, separator=self.SLUG_SEPARATOR)
            session = sa.orm.object_session(self)
            if not session:
                return None
            query = session.query(Entity.slug).filter(
                Entity._entity_type == self.object_type
            )
            if self.id is not None:
                query = query.filter(Entity.id != self.id)
            slug_re = re.compile(re.escape(slug) + r"-?(-\d+)?")
            results = [
                int(m.group(1) or 0)  # 0: for the unnumbered slug
                for m in (slug_re.match(s.slug) for s in query.all() if s.slug)
                if m
            ]

            max_id = max(-1, -1, *results) + 1
            if max_id:
                slug = f"{slug}-{max_id}"
        return slug
285829
def clean_slug_dir(root):
    
    if not root.endswith('/'):
        root += '/'
    for pattern in get_slugignores(root):
        print("pattern", pattern)
        remove_pattern(root, pattern)
60453
def get_complete_slug(self, language=None, hideroot=True):
        """"""
        if not language:
            language = settings.PAGE_DEFAULT_LANGUAGE

        if self._complete_slug and language in self._complete_slug:
            return self._complete_slug[language]

        self._complete_slug = cache.get(self.PAGE_URL_KEY % (self.pk))
        if self._complete_slug is None:
            self._complete_slug = {}
        elif language in self._complete_slug:
            return self._complete_slug[language]

        if hideroot and settings.PAGE_HIDE_ROOT_SLUG and self.is_first_root():
            url = ''
        else:
            url = '%s' % self.slug(language)

        key = self.ANCESTORS_KEY % self.pk
        ancestors = cache.get(key, None)
        if ancestors is None:
            ancestors = self.get_ancestors(ascending=True)
            cache.set(key, ancestors)

        for ancestor in ancestors:
            url = ancestor.slug(language) + '/' + url

        self._complete_slug[language] = url
        cache.set(self.PAGE_URL_KEY % (self.pk), self._complete_slug)
        return url
428893
def generate_slug(name):
        
        slug = slugify(name)

        i = KnwKB.query.filter(db.or_(
            KnwKB.slug.like(slug),
            KnwKB.slug.like(slug + '-%'),
        )).count()

        return slug + ('-{0}'.format(i) if i > 0 else '')
1018577
def clean_slug(self):
        
        slug = self.cleaned_data.get('slug', None)
        if slug is None or len(slug) == 0 and 'title' in self.cleaned_data:
            slug = slugify(self.cleaned_data['title'])
        return slug
703245
def get_data_id_by_slug(self, slug):
        
        resolwe_host = os.environ.get('RESOLWE_HOST_URL')
        url = urllib.parse.urljoin(resolwe_host, '/api/data?slug={}&fields=id'.format(slug))

        with urllib.request.urlopen(url, timeout=60) as f:
            data = json.loads(f.read().decode('utf-8'))

        if len(data) == 1:
            return data[0]['id']
        elif not data:
            raise ValueError('Data not found for slug {}'.format(slug))
        else:
            raise ValueError('More than one data object returned for slug {}'.format(slug))
787573
def slug(self):
        
        return '{:s}@{:s}[{:d}, {:d}]'.format(self.type, self.seqid,
                                              self.start + 1, self.end)
192113
def getSearch(self):
        """"""
        return Search(self.getColumns(), Sitools2Abstract.getBaseUrl(self) + self.getUri())
1062684
def slug(cls):
        
        slug = cls.__name__.lower()
        if slug.endswith('view'):
            slug = slug[:-4]
        return slug
1098413
public static function queryBySlug( $slug, $config = [] ) {

		$ignoreSite	= isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;

		if( static::isMultiSite() && !$ignoreSite ) {

			$siteId	= isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;

			return static::find()->where( 'slug=:slug AND siteId=:siteId', [ ':slug' => $slug, ':siteId' => $siteId ] );
		}
		else {

			return static::find()->where( 'slug=:slug', [ ':slug' => $slug ] );
		}
	}