annotate MoinMoin/macro/OrphanedPages.py @ 3229:09657fbd4aa2

converted to arg parser
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 09 Mar 2008 19:51:01 +0100
parents 7ae581d79352
children
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - OrphanedPages Macro
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1384
diff changeset
5 @copyright: 2001 Juergen Hermann <jh@web.de>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9 Dependencies = ["pages"]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10
3229
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2207
diff changeset
11 def macro_OrphanedPages(macro):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12 _ = macro.request.getText
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14 if macro.request.mode_getpagelinks: # prevent recursion
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 return ''
2207
7ae581d79352 updated bot useragents list, reduce bot cpu usage of some macros (ported from 1.5 repo)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
16 if macro.request.isSpiderAgent: # reduce bot cpu usage
7ae581d79352 updated bot useragents list, reduce bot cpu usage of some macros (ported from 1.5 repo)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
17 return ''
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 551
diff changeset
18
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19 # delete all linked pages from a dict of all pages
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
20 pages = macro.request.rootpage.getPageDict()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21 orphaned = {}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 orphaned.update(pages)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 for page in pages.values():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 links = page.getPageLinks(macro.request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 for link in links:
551
17ab8fe4a94b refactored some d.has_key(k) to k in d (faster)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
26 if link in orphaned:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27 del orphaned[link]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 result = []
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
30 f = macro.formatter
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
31 if not orphaned:
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
32 result.append(f.paragraph(1))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
33 result.append(f.text(_("No orphaned pages in this wiki.")))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
34 result.append(f.paragraph(0))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
35 else:
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
36 # return a list of page links
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
37 orphanednames = orphaned.keys()
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
38 orphanednames.sort()
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
39 result.append(f.number_list(1))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
40 for name in orphanednames:
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
41 if not name:
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
42 continue
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
43 result.append(f.listitem(1))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
44 result.append(f.pagelink(1, name, generated=1))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
45 result.append(f.text(name))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
46 result.append(f.pagelink(0, name))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
47 result.append(f.listitem(0))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
48 result.append(f.number_list(0))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50 return ''.join(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51