1.1 --- a/EventAggregatorSupport.py Sat Feb 27 01:43:30 2010 +0100
1.2 +++ b/EventAggregatorSupport.py Sat Mar 06 22:51:27 2010 +0100
1.3 @@ -21,7 +21,7 @@
1.4 except NameError:
1.5 from sets import Set as set
1.6
1.7 -__version__ = "0.5"
1.8 +__version__ = "0.6"
1.9
1.10 # Date labels.
1.11
1.12 @@ -399,7 +399,7 @@
1.13
1.14 # Text which need not be quoted, but it will be Wiki text.
1.15
1.16 - elif term in ("description",):
1.17 + elif term in ("description", "link"):
1.18 desc = event_details[term]
1.19
1.20 replaced_terms.add(term)
1.21 @@ -879,7 +879,7 @@
1.22
1.23 def getDate(s):
1.24
1.25 - "Parse the string 's', extracting and returning a date string."
1.26 + "Parse the string 's', extracting and returning a date object."
1.27
1.28 m = date_regexp.search(s)
1.29 if m:
1.30 @@ -887,9 +887,21 @@
1.31 else:
1.32 return None
1.33
1.34 +def getDateStrings(s):
1.35 +
1.36 + "Parse the string 's', extracting and returning all date strings."
1.37 +
1.38 + start = 0
1.39 + m = date_regexp.search(s, start)
1.40 + l = []
1.41 + while m:
1.42 + l.append("-".join(m.groups()))
1.43 + m = date_regexp.search(s, m.end())
1.44 + return l
1.45 +
1.46 def getMonth(s):
1.47
1.48 - "Parse the string 's', extracting and returning a month string."
1.49 + "Parse the string 's', extracting and returning a month object."
1.50
1.51 m = month_regexp.search(s)
1.52 if m:
1.53 @@ -1013,4 +1025,35 @@
1.54 else:
1.55 return page.link_to_raw(request, text, query_string)
1.56
1.57 +def getFullPageName(parent, title):
1.58 +
1.59 + """
1.60 + Return a full page name from the given 'parent' page (can be empty or None)
1.61 + and 'title' (a simple page name).
1.62 + """
1.63 +
1.64 + if parent:
1.65 + return "%s/%s" % (parent.rstrip("/"), title)
1.66 + else:
1.67 + return title
1.68 +
1.69 +def fillEventPageFromTemplate(template_page, new_page, event_details, category_pagenames):
1.70 +
1.71 + """
1.72 + Using the given 'template_page', complete the 'new_page' by copying the
1.73 + template and adding the given 'event_details' (a dictionary of event
1.74 + fields), setting also the 'category_pagenames' to define category
1.75 + membership.
1.76 + """
1.77 +
1.78 + event_page = EventPage(template_page)
1.79 + new_event_page = EventPage(new_page)
1.80 + new_event_page.copyPage(event_page)
1.81 +
1.82 + if new_event_page.getFormat() == "wiki":
1.83 + new_event = Event(new_event_page, event_details)
1.84 + new_event_page.setEvents([new_event])
1.85 + new_event_page.setCategoryMembership(category_pagenames)
1.86 + new_event_page.saveChanges()
1.87 +
1.88 # vim: tabstop=4 expandtab shiftwidth=4