Skip to content
Permalink
Browse files
Improving warnings about missing language for slugify* variants.
  • Loading branch information
felixfontein committed Mar 7, 2016
1 parent f5816a8 commit 0b98214ab26445a54310ba78bc2c2c4ef3478a0f
Showing 3 changed files with 12 additions and 3 deletions.
@@ -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
@@ -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
@@ -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
@@ -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))
@@ -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)

0 comments on commit 0b98214

Please sign in to comment.