Self hosted FLOSS fitness/workout, nutrition and weight tracker
Use six to wrap differences between python 2 and 3
Roland Geideraafa081ea918
diff --git a/requirements.txt b/requirements.txtindex 05c4f0a55..25bef9abc 100644--- a/requirements.txt+++ b/requirements.txt@@ -9,11 +9,16 @@ reportlabdjango_mobilebleachsouth < 2.0-django-tastypie==0.9.16python-mimeparsepilloweasy-thumbnailsdjango_compressoricalendar++# REST APIdjangorestframework==2.3.13-django-filter\ No newline at end of file+django-filter+django-tastypie==0.9.16++# Python3 compatibility+sixdiff --git a/wger/main.py b/wger/main.pyindex afa9e60a2..7e983db5c 100755--- a/wger/main.py+++ b/wger/main.py@@ -10,9 +10,7 @@:license: GNU GPL, see LICENSE for more details."""-# for python 2.5 support-from __future__ import with_statement-+import siximport base64import ctypesimport optparse@@ -477,7 +475,7 @@ def start_browser(url):def fs2unicode(s):- if isinstance(s, unicode):+ if isinstance(s, six.text_type):return sfs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()return s.decode(fs_encoding)diff --git a/wger/utils/widgets.py b/wger/utils/widgets.pyindex cbd10f6d6..74fa77a03 100644--- a/wger/utils/widgets.py+++ b/wger/utils/widgets.py@@ -25,7 +25,7 @@ from django.forms.widgets import TextInputfrom django.forms import fieldsfrom django.utils.translation import ugettext as _-from django.utils.encoding import force_unicode+from django.utils.encoding import force_textfrom django.utils.html import escapefrom django.utils.html import conditional_escapefrom django.utils.safestring import mark_safe@@ -113,14 +113,14 @@ class ExerciseAjaxSelect(SelectMultiple):def render_options(self, choices, selected_choices):# Normalize to strings.- selected_choices = set(force_unicode(v) for v in selected_choices)+ selected_choices = set(force_text(v) for v in selected_choices)output = []for option_value, option_label in chain(self.choices, choices):output.append(self.render_option(selected_choices, option_value, option_label))return u'\n'.join(output)def render_option(self, selected_choices, option_value, option_label):- option_value = force_unicode(option_value)+ option_value = force_text(option_value)if option_value in selected_choices:return u'''@@ -133,7 +133,7 @@ class ExerciseAjaxSelect(SelectMultiple):</a> %(value)s<input type="hidden" name="exercises" value="%(id)s"></div>- ''' % {'value': conditional_escape(force_unicode(option_label)),+ ''' % {'value': conditional_escape(force_text(option_label)),'id': escape(option_value),'div_id': uuid.uuid4()}diff --git a/wger/weight/helpers.py b/wger/weight/helpers.pyindex b52634c4e..45cfa4d8f 100644--- a/wger/weight/helpers.py+++ b/wger/weight/helpers.py@@ -15,7 +15,7 @@# You should have received a copy of the GNU Affero General Public Licenseimport logging-import StringIO+import siximport datetimeimport decimalimport csv@@ -36,7 +36,7 @@ def parse_weight_csv(request, cleaned_data):dialect = 'excel'# csv.reader expects a file-like object, so use StringIO- parsed_csv = csv.reader(StringIO.StringIO(cleaned_data['csv_input']),+ parsed_csv = csv.reader(six.StringIO.StringIO(cleaned_data['csv_input']),dialect)weight_list = []