1.1 --- a/ApproveChangesSupport.py Thu Oct 13 22:48:25 2011 +0200
1.2 +++ b/ApproveChangesSupport.py Thu Oct 13 23:31:45 2011 +0200
1.3 @@ -18,14 +18,12 @@
1.4 from MoinMoin import user
1.5 from MoinMoin.Page import Page
1.6 from MoinMoin.wikiutil import escape
1.7 -
1.8 -try:
1.9 - set
1.10 -except NameError:
1.11 - from sets import Set as set
1.12 +import re
1.13
1.14 __version__ = "0.1"
1.15
1.16 +space_pattern = re.compile("(\s+)")
1.17 +
1.18 def get_queued_changes_page(request):
1.19 return getattr(request.cfg, "queued_changes_page", "ApprovalQueue")
1.20
1.21 @@ -112,13 +110,14 @@
1.22 def remove_directives(body, names):
1.23
1.24 """
1.25 - Remove from the page 'body' the first of each directive using the given
1.26 - 'names'.
1.27 + Return a new page body, copying the page 'body' provided but removing the
1.28 + first of each directive having one of the given 'names', along with a
1.29 + dictionary mapping directive names to values.
1.30 """
1.31
1.32 new_body = []
1.33 header = 1
1.34 - found = set()
1.35 + found = {}
1.36
1.37 for line in body.split("\n"):
1.38 if header:
1.39 @@ -127,20 +126,23 @@
1.40
1.41 if not line.startswith("#"):
1.42 header = 0
1.43 +
1.44 + # Process the comment or directive.
1.45 +
1.46 else:
1.47 - parts = line[1:].split()
1.48 + parts = space_pattern.split(line[1:])
1.49
1.50 # Identify any directive.
1.51
1.52 directive = parts[0]
1.53
1.54 - if directive in names and directive not in found:
1.55 - found.add(directive)
1.56 + if directive in names and not found.has_key(directive):
1.57 + found[directive] = "".join(parts[1:])
1.58 continue
1.59
1.60 new_body.append(line)
1.61
1.62 - return "\n".join(new_body)
1.63 + return "\n".join(new_body), found
1.64
1.65 # Utility classes and associated functions.
1.66 # NOTE: These are a subset of EventAggregatorSupport.