From 972e8fdc98e2c9e0132fcf9d0e81263102c8a36b Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Mon, 12 Jan 2015 23:34:31 +0100 Subject: [PATCH] Fix encoding issue with the progress bar on py3 (fix #137). --- sigal/gallery.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sigal/gallery.py b/sigal/gallery.py index 15506fc..ceb35df 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -40,7 +40,7 @@ from os.path import isfile, join, splitext from PIL import Image as PILImage from . import image, video, signals -from .compat import UnicodeMixin, strxfrm, url_quote, text_type +from .compat import PY2, UnicodeMixin, strxfrm, url_quote, text_type from .image import process_image, get_exif_tags, get_exif_data from .settings import get_thumb from .utils import (Devnull, copy, check_or_create_dir, url_from_path, @@ -554,7 +554,10 @@ class Gallery(object): # 63 is the total length of progressbar, label, percentage, etc available_length = get_terminal_size()[0] - 64 if x and available_length > 10: - return text_type(x.name)[:available_length].encode('utf-8') + text = text_type(x.name)[:available_length] + if PY2: + text = text.encode('utf-8') + return text else: return ""