Skip to content

Commit

Permalink
Improving warnings about missing language for slugify* variants.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Mar 7, 2016
1 parent f5816a8 commit 0b98214
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion nikola/plugins/task/authors.py
Expand Up @@ -251,8 +251,11 @@ def author_rss(self, author, lang, posts, kw):
}
return utils.apply_filters(task, kw['filters'])

def slugify_author_name(self, name, lang):
def slugify_author_name(self, name, lang=None):
"""Slugify an author name."""
if lang is None: # TODO: remove in v8
utils.LOGGER.warn("RenderAuthors.slugify_author_name() called without language!")
lang = ''
if self.site.config['SLUG_AUTHOR_PATH']:
name = utils.slugify(name, lang)
return name
Expand Down
6 changes: 6 additions & 0 deletions nikola/plugins/task/tags.py
Expand Up @@ -390,6 +390,9 @@ def tag_rss(self, tag, lang, posts, kw, is_category):

def slugify_tag_name(self, name, lang):
"""Slugify a tag name."""
if lang is None: # TODO: remove in v8
utils.LOGGER.warn("RenderTags.slugify_tag_name() called without language!")
lang = ''
if self.site.config['SLUG_TAG_PATH']:
name = utils.slugify(name, lang)
return name
Expand Down Expand Up @@ -464,6 +467,9 @@ def tag_rss_path(self, name, lang):

def slugify_category_name(self, name, lang):
"""Slugify a category name."""
if lang is None: # TODO: remove in v8
utils.LOGGER.warn("RenderTags.slugify_category_name() called without language!")
lang = ''
path = self.site.parse_category_name(name)
if self.site.config['CATEGORY_OUTPUT_FLAT_HIERARCHY']:
path = path[-1:] # only the leaf
Expand Down
4 changes: 2 additions & 2 deletions nikola/utils.py
Expand Up @@ -757,7 +757,7 @@ def slugify(value, lang=None, force=False):
>>> print(slugify('foo bar', lang='en'))
foo-bar
"""
if lang is None:
if lang is None: # TODO: remove in v8
LOGGER.warn("slugify() called without language!")
if not isinstance(value, unicode_str):
raise ValueError("Not a unicode object: {0}".format(value))
Expand Down Expand Up @@ -789,7 +789,7 @@ def unslugify(value, lang=None, discard_numbers=True):
If discard_numbers is True, numbers right at the beginning of input
will be removed.
"""
if lang is None:
if lang is None: # TODO: remove in v8
LOGGER.warn("unslugify() called without language!")
if discard_numbers:
value = re.sub('^[0-9]+', '', value)
Expand Down

0 comments on commit 0b98214

Please sign in to comment.