Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #2019 -- use unicode_str for WP comment headers
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Sep 4, 2015
1 parent adb33a9 commit 1d0ee4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
@@ -1,9 +1,13 @@
New in master
=============

Features
--------

Bugfixes
--------

* Use Unicode strings for WordPress comment headers (Issue #2019)
* Don't add stories to author pages (Issue #2007)

New in v7.7.0
Expand Down
8 changes: 4 additions & 4 deletions nikola/plugins/command/import_wordpress.py
Expand Up @@ -50,7 +50,7 @@

from nikola.plugin_categories import Command
from nikola import utils
from nikola.utils import req_missing
from nikola.utils import req_missing, unicode_str
from nikola.plugins.basic_import import ImportMixin, links
from nikola.nikola import DEFAULT_TRANSLATIONS_PATTERN
from nikola.plugins.command.init import SAMPLE_CONF, prepare_config, format_default_translations_config
Expand Down Expand Up @@ -689,7 +689,7 @@ def _extract_comment(self, comment, wordpress_namespace):
elif approved == 'spam' or approved == 'trash':
pass
else:
LOGGER.warn("Unknown comment approved status: " + str(approved))
LOGGER.warn("Unknown comment approved status: {0}".format(approved))
parent = int(get_text_tag(comment, "{{{0}}}comment_parent".format(wordpress_namespace), 0))
if parent == 0:
parent = None
Expand All @@ -710,7 +710,7 @@ def write_header_line(fd, header_field, header_content):
"""Write comment header line."""
if header_content is None:
return
header_content = str(header_content).replace('\n', ' ')
header_content = unicode_str(header_content).replace('\n', ' ')
line = '.. ' + header_field + ': ' + header_content + '\n'
fd.write(line.encode('utf8'))

Expand Down Expand Up @@ -911,7 +911,7 @@ def import_postpage_item(self, item, wordpress_namespace, out_folder=None, attac
comments.append(comment)

for comment in comments:
comment_filename = slug + "." + str(comment['id']) + ".wpcomment"
comment_filename = "{0}.{1}.wpcomment".format(slug, comment['id'])
self._write_comment(os.path.join(self.output_folder, out_folder, comment_filename), comment)

return (out_folder, slug)
Expand Down

0 comments on commit 1d0ee4d

Please sign in to comment.