Commit 3d768b3b authored by Charles Ferguson's avatar Charles Ferguson
Browse files

Fix for categories failing to process if they had spaces in.

Categories with spaces in should use underscores in the category
name in the URL. These have now been fixed.
parent 9a56a0e1
......@@ -76,7 +76,10 @@ def comment(language, block):
if language in ('C', 'C++'):
return "/*%s\n*/\n" % (block,)
prefix = "# "
if language == 'BBC BASIC':
prefix = 'REM '
else:
prefix = "# "
lines = [prefix + line + "\n" for line in block.splitlines()]
return "".join(lines)
......
......@@ -348,8 +348,9 @@ class Category(object):
match_re = re.compile('^/wiki/([A-Za-z0-9_/%]+)$')
def __init__(self, category):
self.category = category
self.url = '%s/wiki/Category:%s' % (base_url, self.category)
self.wikicategory = quote(category.encode('utf-8')).replace('%20', '_')
self.category = unquote(category)
self.url = '%s/wiki/Category:%s' % (base_url, self.wikicategory)
self._page = None
self._links = None
self._tasks = None
......@@ -374,7 +375,7 @@ class Category(object):
@property
def page(self):
if not self._page:
page = cache_page(self.url, 'category-%s' % (self.category,))
page = cache_page(self.url, 'category-%s' % (self.wikicategory,))
self._page = page
return self._page
......@@ -413,6 +414,9 @@ class Category(object):
@property
def tasks(self):
if self._tasks is None:
if self.links is None:
# No links recognised, so we have to give up.
return []
tasks = [Task(name) for _, name in self.links]
# Apply any filters
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment