1.1 --- a/EventAggregatorSupport.py Mon Apr 18 01:06:30 2011 +0200
1.2 +++ b/EventAggregatorSupport.py Mon Apr 18 23:43:22 2011 +0200
1.3 @@ -50,6 +50,7 @@
1.4 # Value parsing.
1.5
1.6 country_code_regexp = re.compile(ur'(?:^|\W)(?P<code>[A-Z]{2})(?:$|\W+$)', re.UNICODE)
1.7 +location_normalised_regexp = re.compile(ur"([\w-]+(?:,(?:\s*[\w-]+)+)?)$", re.UNICODE)
1.8
1.9 month_regexp_str = ur'(?P<year>[0-9]{4})-(?P<month>[0-9]{2})'
1.10 date_regexp_str = ur'(?P<year>[0-9]{4})-(?P<month>[0-9]{2})-(?P<day>[0-9]{2})'
1.11 @@ -308,6 +309,19 @@
1.12
1.13 return weekday_labels[weekday]
1.14
1.15 +def getNormalisedLocation(location):
1.16 +
1.17 + """
1.18 + Attempt to return a normalised 'location' of the form "<town>, <country>" or
1.19 + "<town>".
1.20 + """
1.21 +
1.22 + match = location_normalised_regexp.search(location)
1.23 + if match:
1.24 + return match.group()
1.25 + else:
1.26 + return None
1.27 +
1.28 # Action support functions.
1.29
1.30 def getPageRevision(page):