diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2014-06-02 21:01:48 +0300 |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2014-06-02 21:01:48 +0300 |
commit | 0b2572b9a8f8d1e22e724283cd99152c767208e8 (patch) | |
tree | 0e173b84b58aa70193a641e60a6ddbc5bc6f4e15 | |
parent | e49b7e02b2150413d2e78db709277fae0887be46 (diff) | |
download | mediagoblin-0b2572b9a8f8d1e22e724283cd99152c767208e8.tar.lz mediagoblin-0b2572b9a8f8d1e22e724283cd99152c767208e8.tar.xz mediagoblin-0b2572b9a8f8d1e22e724283cd99152c767208e8.zip |
Add py2_unicode helper to mediagoblin._compat.
-rw-r--r-- | mediagoblin/_compat.py | 7 | ||||
-rw-r--r-- | mediagoblin/tools/workbench.py | 10 |
2 files changed, 13 insertions, 4 deletions
diff --git a/mediagoblin/_compat.py b/mediagoblin/_compat.py index a6b775fc..fd6172fd 100644 --- a/mediagoblin/_compat.py +++ b/mediagoblin/_compat.py @@ -14,3 +14,10 @@ else: import urlparse ugettext = mg_globals.thread_scope.translations.ugettext 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 diff --git a/mediagoblin/tools/workbench.py b/mediagoblin/tools/workbench.py index 0bd4096b..f1ad6414 100644 --- a/mediagoblin/tools/workbench.py +++ b/mediagoblin/tools/workbench.py @@ -18,10 +18,15 @@ import os import shutil import tempfile +import six + +from mediagoblin._compat import py2_unicode # Actual workbench stuff # ---------------------- + +@py2_unicode class Workbench(object): """ Represent the directory for the workbench @@ -36,11 +41,8 @@ class Workbench(object): """ self.dir = dir - def __unicode__(self): - return unicode(self.dir) - def __str__(self): - return str(self.dir) + return six.text_type(self.dir) def __repr__(self): try: |