Skip to content
Permalink
Browse files
Replace ugly lambdas with functools.partial
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Dec 6, 2016
1 parent 2ae6dd1 commit c8d8cbe3f62d1146e821200e7e86fbe8fd0eec30
Showing with 6 additions and 5 deletions.
  1. +6 −5 nikola/plugins/misc/taxonomies_classifier.py
@@ -28,6 +28,7 @@

from __future__ import unicode_literals
import blinker
import functools
import natsort
import os
import sys
@@ -262,7 +263,7 @@ def _parse_path_result(result):
page_info = result[2] if len(result) > 2 else None
return path, append_index, page_info

def _taxonomy_index_path(self, lang, taxonomy):
def _taxonomy_index_path(self, name, lang, taxonomy):
"""Return path to the classification overview."""
result = taxonomy.get_overview_path(lang)
path, append_index, _ = self._parse_path_result(result)
@@ -293,10 +294,10 @@ def _taxonomy_rss_path(self, name, lang, taxonomy):
return self._taxonomy_path(name, lang, taxonomy, dest_type='rss')

def _register_path_handlers(self, taxonomy):
self.site.register_path_handler('{0}_index'.format(taxonomy.classification_name), lambda name, lang: self._taxonomy_index_path(lang, taxonomy))
self.site.register_path_handler('{0}'.format(taxonomy.classification_name), lambda name, lang: self._taxonomy_path(name, lang, taxonomy))
self.site.register_path_handler('{0}_atom'.format(taxonomy.classification_name), lambda name, lang: self._taxonomy_atom_path(name, lang, taxonomy))
self.site.register_path_handler('{0}_rss'.format(taxonomy.classification_name), lambda name, lang: self._taxonomy_rss_path(name, lang, taxonomy))
self.site.register_path_handler('{0}_index'.format(taxonomy.classification_name), functools.partial(self._taxonomy_index_path, taxonomy=taxonomy))
self.site.register_path_handler('{0}'.format(taxonomy.classification_name), functools.partial(self._taxonomy_path, taxonomy=taxonomy))
self.site.register_path_handler('{0}_atom'.format(taxonomy.classification_name), functools.partial(self._taxonomy_atom_path, taxonomy=taxonomy))
self.site.register_path_handler('{0}_rss'.format(taxonomy.classification_name), functools.partial(self._taxonomy_rss_path, taxonomy=taxonomy))

def set_site(self, site):
"""Set site, which is a Nikola instance."""

0 comments on commit c8d8cbe

Please sign in to comment.