List of categories of a page.
337328
def categories(self):
    '''
    
    '''

    if not getattr(self, '_categories', False):
      self._categories = [re.sub(r'^Category:', '', x) for x in
        [link['title']
        for link in self.__continued_query({
          'prop': 'categories',
          'cllimit': 'max'
        })
      ]]

    return self._categories
102564
def menu_pages(colors, page=1, print_keys=True, per_page=15):
    """"""

    c = os.system('clear')
    length = len(colors)
    last_page = length / per_page
    if (last_page * per_page) < length:
        last_page += 1

    page_display = "page (%d/%d)" % (page, last_page)
    start = per_page * (page - 1)
    keys = """
(j/k): Next/Previous page, (J/K): Transparency Down/Up

(P/p): set prefix,         (Q/q): Quit

Or simply enter the number of a theme
    """

    print '=' * 30
    print page_display
    print '-' * len(page_display)

    for i,v in enumerate(colors[start : start + per_page]):
        print '%2d) %s' % (i + start + 1, v)

    print '=' * 30
    print 'Current theme is: %s' % get_current()
    print 'Transparency: %%%d' % transparency
    print '=' * 30

    if(print_keys):
        print keys
702802
def load_categories(self, max_pages=30):
        
        logger.info("loading categories")

        # clear them all out so we don't get dupes if requested
        if self.purge_first:
            Category.objects.filter(site_id=self.site_id).delete()

        path = "sites/{}/categories".format(self.site_id)
        params = {"number": 100}
        page = 1

        response = self.get(path, params)

        if not response.ok:
            logger.warning("Response NOT OK! status_code=%s\n%s", response.status_code, response.text)

        while response.ok and response.text and page < max_pages:
            logger.info(" - page: %d", page)

            api_categories = response.json().get("categories")
            if not api_categories:
                # we're done here
                break

            categories = []
            for api_category in api_categories:

                # if it exists locally, update local version if anything has changed
                existing_category = Category.objects.filter(site_id=self.site_id, wp_id=api_category["ID"]).first()
                if existing_category:
                    self.update_existing_category(existing_category, api_category)
                else:
                    categories.append(self.get_new_category(api_category))

            if categories:
                Category.objects.bulk_create(categories)
            elif not self.full:
                # we're done here
                break

            # get next page
            page += 1
            params["page"] = page
            response = self.get(path, params)

            if not response.ok:
                logger.warning("Response NOT OK! status_code=%s\n%s", response.status_code, response.text)
                return
222458
def descriptions(self):
        """"""
        descs = []
        for postag, form in zip(self.postags, self.forms):
            desc = VERB_TYPES.get(form, '')
            if len(desc) == 0:
                toks = form.split(' ')
                if len(toks) == 2:
                    plur_desc = PLURALITY.get(toks[0], None)
                    case_desc = CASES.get(toks[1], None)
                    toks = []
                    if plur_desc is not None:
                        toks.append(plur_desc)
                    if case_desc is not None:
                        toks.append(case_desc)
                    desc = ' '.join(toks)
            descs.append(desc)
        return descs
25015
def nav_categorizer(request):
    

    categories = [(r"^/$", "dashboard"), (r"^/announcements", "dashboard"), (r"^/eighth/admin", "eighth_admin"), (r"^/eighth", "eighth"),
                  (r"^/events", "events"), (r"^/files", "files"), (r"^/printing", "printing"), (r"^/groups", "groups"), (r"^/polls", "polls"),
                  (r"^/board", "board"), (r"/bus", "bus")]

    for pattern, category in categories:
        p = re.compile(pattern)
        if p.match(request.path):
            return {"nav_category": category}

    return {"nav_category": ""}
187441
def get_categories(context, template='zinnia/tags/categories.html'):
    
    return {'template': template,
            'categories': Category.published.all().annotate(
                count_entries_published=Count('entries')),
            'context_category': context.get('category')}
678968
def _categorize(self, category):
		""""""
		self.torrents = [result for result in self.torrents
						 if result.category == category]
892590
def list_names(cls):
        """"""
        ret = dict([(item['id'], item['name'])
                    for item in cls.list({'items_per_page': 500})])
        return ret
49204
def _category_slugs(self, category):
        """"""
        key = self._category_key(category)
        slugs = self.r.smembers(key)
        return slugs
922270
def statuscategories(self):
        
        r_json = self._get_json('statuscategory')
        statuscategories = [StatusCategory(self._options, self._session, raw_stat_json)
                            for raw_stat_json in r_json]
        return statuscategories
395185
def sub_menu(request, page_id):
    """"""
    page = Page.objects.get(id=page_id)
    pages = page.children.all()
    page_languages = settings.PAGE_LANGUAGES
    return render(request, "admin/pages/page/sub_menu.html", {
        'can_publish': request.user.has_perm('pages.can_publish'),
        'page': page,
        'pages': pages,
        'page_languages': page_languages,
    })
568644
def list_links(self, *args, **kwargs):
        
        print("Links in the current page:")
        for l in self.links(*args, **kwargs):
            print("    ", l)
278360
protected function render_category_list(): string
    {
        if (!\has_category('', $this->post->get())) {
            return '';
        }

        return '<span class="category-links"><span class="meta-title">'.
            \esc_html__('Categories:', 'grotto-wp-posts').
        '</span> <span itemprop="articleSection">'.
            \get_the_category_list(', ', '', $this->post->get()->ID).
        '</span></span>';
    }
851101
def paginate(self, page=1, perpage=10, category=None):
        """"""
        q = db.select(self.table).fields('title', 'slug', 'description', 'html', 'css', 'js',
                                         'category', 'status', 'comments', 'author', 'created', 'pid')
        if category:
            q.condition('category', category)
        results = (q.limit(perpage).offset((page - 1) * perpage)
                    .order_by('created', 'DESC').execute())
        return [self.load(data, self.model) for data in results]
148630
private function _show_pages() {

        $output = '';

        // if the total number of pages is lesser than the number of selectable pages
        if ($this->_properties['total_pages'] <= $this->_properties['selectable_pages'])

            // iterate ascendingly or descendingly, depending on whether we're showing links in reverse order or not
            for (

                $i = ($this->_properties['reverse'] ? $this->_properties['total_pages'] : 1);
                ($this->_properties['reverse'] ? $i >= 1 : $i <= $this->_properties['total_pages']);
                ($this->_properties['reverse'] ? $i-- : $i++)

            ) {

                // CSS classes to be applied to the list item, if any
                $css_classes = isset($this->_properties['css_classes']['list_item']) && $this->_properties['css_classes']['list_item'] != '' ? array(trim($this->_properties['css_classes']['list_item'])) : array();

                // if this the currently selected page, highlight it
                if ($this->_properties['page'] == $i) $css_classes[] = 'active';

                // generate markup
                $output .= '<li' .

                    // add CSS classes to the list item, if necessary
                    (!empty($css_classes) ? ' class="' . implode(' ', $css_classes) . '"' : '') . '><a href="' . $this->_build_uri($i) . '"' .

                    // add CSS classes to the anchor, if necessary
                    (isset($this->_properties['css_classes']['anchor']) && $this->_properties['css_classes']['anchor'] != '' ? ' class="' . trim($this->_properties['css_classes']['anchor']) . '"' : '') . '>' .

                    // apply padding if required
                    ($this->_properties['padding'] ? str_pad($i, strlen($this->_properties['total_pages']), '0', STR_PAD_LEFT) : $i) .

                    '</a></li>';

            }

        // if the total number of pages is greater than the number of selectable pages
        else {

            // CSS classes to be applied to the list item, if any
            $css_classes = isset($this->_properties['css_classes']['list_item']) && $this->_properties['css_classes']['list_item'] != '' ? array(trim($this->_properties['css_classes']['list_item'])) : array();

            // highlight if the page is currently selected
            if ($this->_properties['page'] == ($this->_properties['reverse'] ? $this->_properties['total_pages'] : 1)) $css_classes[] = 'active';

            // start with a link to the first or last page, depending if we're displaying links in reverse order or not

            // generate markup
            $output .= '<li' .

                // add CSS classes to the list item, if necessary
                (!empty($css_classes) ? ' class="' . implode(' ', $css_classes) . '"' : '') . '><a href="' . $this->_build_uri($this->_properties['reverse'] ? $this->_properties['total_pages'] : 1) . '"' .

                // add CSS classes to the anchor, if necessary
                (isset($this->_properties['css_classes']['anchor']) && $this->_properties['css_classes']['anchor'] != '' ? ' class="' . trim($this->_properties['css_classes']['anchor']) . '"' : '') . '>' .

                // if padding is required
                ($this->_properties['padding'] ?

                    // apply padding
                    str_pad(($this->_properties['reverse'] ? $this->_properties['total_pages'] : 1), strlen($this->_properties['total_pages']), '0', STR_PAD_LEFT) :

                    // show the page number
                    ($this->_properties['reverse'] ? $this->_properties['total_pages'] : 1)) .

                '</a></li>';

            // compute the number of adjacent pages to display to the left and right of the currently selected page so
            // that the currently selected page is always centered
            $adjacent = floor(($this->_properties['selectable_pages'] - 3) / 2);

            // this number must be at least 1
            if ($adjacent == 0) $adjacent = 1;

            // find the page number after we need to show the first "..."
            // (depending on whether we're showing links in reverse order or not)
            $scroll_from = ($this->_properties['reverse'] ?

                $this->_properties['total_pages'] - ($this->_properties['selectable_pages'] - $adjacent) + 1 :

                $this->_properties['selectable_pages'] - $adjacent);

            // get the page number from where we should start rendering
            // if displaying links in natural order, then it's "2" because we have already rendered the first page
            // if we're displaying links in reverse order, then it's total_pages - 1 because we have already rendered the last page
            $starting_page = ($this->_properties['reverse'] ? $this->_properties['total_pages'] - 1 : 2);

            // if the currently selected page is past the point from where we need to scroll,
            if (

                ($this->_properties['reverse'] && $this->_properties['page'] <= $scroll_from) ||
                (!$this->_properties['reverse'] && $this->_properties['page'] >= $scroll_from)

            ) {

                // by default, the starting_page should be whatever the current page plus/minus $adjacent
                // depending on whether we're showing links in reverse order or not
                $starting_page = $this->_properties['page'] + ($this->_properties['reverse'] ? $adjacent : -$adjacent);

                // but if that would mean displaying less navigation links than specified in $this->_properties['selectable_pages']
                if (

                    ($this->_properties['reverse'] && $starting_page < ($this->_properties['selectable_pages'] - 1)) ||
                    (!$this->_properties['reverse'] && $this->_properties['total_pages'] - $starting_page < ($this->_properties['selectable_pages'] - 2))

                )

                    // adjust the value of $starting_page again
                    if ($this->_properties['reverse']) $starting_page = $this->_properties['selectable_pages'] - 1;
                    else $starting_page -= ($this->_properties['selectable_pages'] - 2) - ($this->_properties['total_pages'] - $starting_page);

                // put the "..." after the link to the first/last page, depending on whether we're showing links in reverse order or not
                $output .= '<li' .

                    // add CSS classes to the list item, if necessary
                    (isset($this->_properties['css_classes']['list_item']) && $this->_properties['css_classes']['list_item'] != '' ? ' class="' . $this->_properties['css_classes']['list_item'] . '"' : '') . '>' .

                    // add CSS classes to the span element, if necessary
                    '<span' . (isset($this->_properties['css_classes']['anchor']) && $this->_properties['css_classes']['anchor'] != '' ? ' class="' . trim($this->_properties['css_classes']['anchor']) . '"' : '') . '>' .

                    '&hellip;</span></li>';

            }

            // get the page number where we should stop rendering
            // by default, this value is the sum of the starting page plus/minus (depending on whether we're showing links
            // in reverse order or not) whatever the number of $this->_properties['selectable_pages'] minus 3 (first page,
            // last page and current page)
            $ending_page = $starting_page + (($this->_properties['reverse'] ? -1 : 1) * ($this->_properties['selectable_pages'] - 3));

            // if we're showing links in natural order and ending page would be greater than the total number of pages minus 1
            // (minus one because we don't take into account the very last page which we output automatically)
            // adjust the ending page
            if ($this->_properties['reverse'] && $ending_page < 2) $ending_page = 2;

            // or, if we're showing links in reverse order, and ending page would be smaller than 2
            // (2 because we don't take into account the very first page which we output automatically)
            // adjust the ending page
            elseif (!$this->_properties['reverse'] && $ending_page > $this->_properties['total_pages'] - 1) $ending_page = $this->_properties['total_pages'] - 1;

            // render pagination links
            for ($i = $starting_page; $this->_properties['reverse'] ? $i >= $ending_page : $i <= $ending_page; $this->_properties['reverse'] ? $i-- : $i++) {

                // CSS classes to be applied to the list item, if any
                $css_classes = isset($this->_properties['css_classes']['list_item']) && $this->_properties['css_classes']['list_item'] != '' ? array(trim($this->_properties['css_classes']['list_item'])) : array();

                // highlight the currently selected page
                if ($this->_properties['page'] == $i) $css_classes[] = 'active';

                // generate markup
                $output .= '<li' .

                    // add CSS classes to the list item, if necessary
                    (!empty($css_classes) ? ' class="' . implode(' ', $css_classes) . '"' : '') . '><a href="' . $this->_build_uri($i) . '"' .

                    // add CSS classes to the anchor, if necessary
                    (isset($this->_properties['css_classes']['anchor']) && $this->_properties['css_classes']['anchor'] != '' ? ' class="' . trim($this->_properties['css_classes']['anchor']) . '"' : '') . '>' .

                    // apply padding if required
                    ($this->_properties['padding'] ? str_pad($i, strlen($this->_properties['total_pages']), '0', STR_PAD_LEFT) : $i) .

                    '</a></li>';

            }

            // if we have to, place another "..." at the end, before the link to the last/first page (depending on whether we're showing links in reverse order or not)
            if (

                ($this->_properties['reverse'] && $ending_page > 2) ||
                (!$this->_properties['reverse'] && $this->_properties['total_pages'] - $ending_page > 1)

            )

                // generate markup
                $output .= '<li' .

                    // add CSS classes to the list item, if necessary
                    (isset($this->_properties['css_classes']['list_item']) && $this->_properties['css_classes']['list_item'] != '' ? ' class="' . $this->_properties['css_classes']['list_item'] . '"' : '') . '>' .

                    // add CSS classes to the span element, if necessary
                    '<span' . (isset($this->_properties['css_classes']['anchor']) && $this->_properties['css_classes']['anchor'] != '' ? ' class="' . trim($this->_properties['css_classes']['anchor']) . '"' : '') . '>' .

                    '&hellip;</span></li>';

            // now we put a link to the last/first page (depending on whether we're showing links in reverse order or not)

            // CSS classes to be applied to the list item, if any
            $css_classes = isset($this->_properties['css_classes']['list_item']) && $this->_properties['css_classes']['list_item'] != '' ? array(trim($this->_properties['css_classes']['list_item'])) : array();

            // highlight if the page is currently selected
            if ($this->_properties['page'] == $i) $css_classes[] = 'active';

            // generate markup
            $output .= '<li' .

                // add CSS classes to the list item, if necessary
                (!empty($css_classes) ? ' class="' . implode(' ', $css_classes) . '"' : '') . '><a href="' . $this->_build_uri($this->_properties['reverse'] ? 1 : $this->_properties['total_pages']) . '"' .

                // add CSS classes to the anchor, if necessary
                (isset($this->_properties['css_classes']['anchor']) && $this->_properties['css_classes']['anchor'] != '' ? ' class="' . trim($this->_properties['css_classes']['anchor']) . '"' : '') . '>' .

                // also, apply padding if necessary
                ($this->_properties['padding'] ? str_pad(($this->_properties['reverse'] ? 1 : $this->_properties['total_pages']), strlen($this->_properties['total_pages']), '0', STR_PAD_LEFT) : ($this->_properties['reverse'] ? 1 : $this->_properties['total_pages'])) .

                '</a></li>';

        }

        // return the resulting string
        return $output;

    }
783222
public function listCategory()
    {
        $this->setTitleListCategory();
        $this->setBreadcrumbListCategory();

        $this->setData('categories', $this->data_categories);
        $this->outputListCategory();
    }
61179
def get_pages_for_display(self):
        """"""
        parent_page = self.parent_page_for_menu_items
        pages = self.get_base_page_queryset().filter(
            depth__gt=parent_page.depth,
            depth__lte=parent_page.depth + self.max_levels,
            path__startswith=parent_page.path,
        )
        # Return 'specific' page instances if required
        if(self.use_specific == constants.USE_SPECIFIC_ALWAYS):
            return pages.specific()
        return pages