Add py2_unicode helper to mediagoblin._compat.
This commit is contained in:
parent
e49b7e02b2
commit
0b2572b9a8
@ -14,3 +14,10 @@ else:
|
|||||||
import urlparse
|
import urlparse
|
||||||
ugettext = mg_globals.thread_scope.translations.ugettext
|
ugettext = mg_globals.thread_scope.translations.ugettext
|
||||||
ungettext = mg_globals.thread_scope.translations.ungettext
|
ungettext = mg_globals.thread_scope.translations.ungettext
|
||||||
|
|
||||||
|
|
||||||
|
def py2_unicode(klass):
|
||||||
|
if not PY3:
|
||||||
|
klass.__unicode__ = klass.__str__
|
||||||
|
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
|
||||||
|
return klass
|
||||||
|
@ -18,10 +18,15 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
|
from mediagoblin._compat import py2_unicode
|
||||||
|
|
||||||
# Actual workbench stuff
|
# Actual workbench stuff
|
||||||
# ----------------------
|
# ----------------------
|
||||||
|
|
||||||
|
|
||||||
|
@py2_unicode
|
||||||
class Workbench(object):
|
class Workbench(object):
|
||||||
"""
|
"""
|
||||||
Represent the directory for the workbench
|
Represent the directory for the workbench
|
||||||
@ -36,11 +41,8 @@ class Workbench(object):
|
|||||||
"""
|
"""
|
||||||
self.dir = dir
|
self.dir = dir
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return unicode(self.dir)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.dir)
|
return six.text_type(self.dir)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user