File: PageCount.py

package info (click to toggle)
moin 1.9.8-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 75,060 kB
  • ctags: 43,795
  • sloc: python: 118,348; java: 10,704; php: 2,374; perl: 1,572; xml: 371; makefile: 213; sh: 79; sed: 5
file content (31 lines) | stat: -rw-r--r-- 832 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: iso-8859-1 -*-
"""
    Outputs the page count of the wiki.

    @copyright: 2007 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details
"""

Dependencies = ['namespace']

from MoinMoin import wikiutil

def macro_PageCount(macro, exists=None):
    """ Return number of pages readable by current user

    Return either an exact count (slow!) or fast count including deleted pages.

    TODO: make macro syntax more sane
    """
    request = macro.request
    exists = wikiutil.get_unicode(request, exists, 'exists')
    # Check input
    only_existing = False
    if exists == u'exists':
        only_existing = True
    elif exists:
        raise ValueError("Wrong argument: %r" % exists)

    count = request.rootpage.getPageCount(exists=only_existing)
    return macro.formatter.text("%d" % count)