lpschedule-generator

libreplanet schedule generator - ricketyspace.net/lpschedule-generator
git clone git://git.ricketyspace.net/lpschedule-generator.git
Log | Files | Refs

commit 4995372feb36fdffb791c8b4e4491bce61982357
parent aac9e52d138fef142b67a85921bff643060cf277
Author: rsiddharth <rsd@gnu.org>
Date:   Wed, 16 Dec 2015 22:19:46 -0500

came up with a clean fix for the utf8 issue.

Diffstat:
lps_gen.py | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/lps_gen.py b/lps_gen.py @@ -19,6 +19,7 @@ # <http://www.gnu.org/licenses/>. import json +import sys from argparse import ArgumentParser from collections import OrderedDict @@ -28,6 +29,11 @@ from jinja2 import Environment, PackageLoader from mistune import Renderer, Markdown +# unicode magic +reload(sys) +sys.setdefaultencoding('utf-8') + + # Python dictionary that will contain the lp schedule. lps_dict = OrderedDict() @@ -63,10 +69,6 @@ class LPSRenderer(Renderer): def header(self, text, level, raw=None): global lps_dict - utf8_text = text - - # jinja2 will encode text back to utf8. - text = text.decode('utf8') if level == 2: # Add new day. @@ -84,7 +86,7 @@ class LPSRenderer(Renderer): # to 0. self.no_paragraph = 0 - return super(LPSRenderer, self).header(utf8_text, level, raw) + return super(LPSRenderer, self).header(text, level, raw) def paragraph(self, text): @@ -92,9 +94,6 @@ class LPSRenderer(Renderer): p = super(LPSRenderer, self).paragraph(text) - # jinja2 will encode text back to utf8. - text = text.decode('utf8') - if self.no_paragraph == 0: # Speaker if len(text.split(', ')) == 1: