Skip to content

Commit

Permalink
ensure utf8 encoding all-around
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Jul 18, 2015
1 parent 143bb82 commit 6d96d77
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions mpcontribs/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals, print_function
import os

indent_symbol = '>'
Expand Down
4 changes: 1 addition & 3 deletions mpcontribs/io/mpfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import unicode_literals, print_function
import os, json, six, codecs, locale
from abc import ABCMeta
from utils import make_pair, get_indentor, RecursiveDict, nest_dict, \
pandas_to_dict, force_encoded_string_output
from utils import make_pair, get_indentor, RecursiveDict, nest_dict, pandas_to_dict
from ..config import mp_level01_titles
from recparse import RecursiveParser
from pandas import DataFrame
Expand Down Expand Up @@ -128,7 +127,6 @@ def set_test_mode(self, mp_cat_id, idx=0):
self.document[mp_cat_id].insert_before(
first_sub_key, ('test_index', idx+733773))

@force_encoded_string_output
def get_string(self, with_comments=False):
"""Returns a string to be written as a file"""
lines = []
Expand Down
2 changes: 1 addition & 1 deletion mpcontribs/io/recparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def read_csv(self, title, body):
return is_data_section, pd.read_csv(
StringIO(body), comment=csv_comment_char,
skipinitialspace=True, squeeze=True,
converters = converters,
converters=converters, encoding='utf8',
**options
).dropna(how='all')

Expand Down
2 changes: 1 addition & 1 deletion mpcontribs/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _func(*args, **kwargs):
def make_pair(key, value, sep=':'):
"""make a mp-specific key-value pair"""
if not isinstance(value, string_types): value = str(value)
return '{} '.format(sep).join([key, value.decode('utf-8')])
return '{} '.format(sep).join([key, value])

def get_indentor(n=0):
"""get level-n indentor"""
Expand Down

0 comments on commit 6d96d77

Please sign in to comment.