-from six import PY3, iteritems
-
-from mediagoblin import mg_globals
+from six import PY3
if PY3:
from email.mime.text import MIMEText
- from urllib import parse as urlparse
- # TODO(berker): Rename to gettext and ungettext instead?
- ugettext = mg_globals.thread_scope.translations.gettext
- ungettext = mg_globals.thread_scope.translations.ngettext
else:
from email.MIMEText import MIMEText
- import urlparse
- ugettext = mg_globals.thread_scope.translations.ugettext
- ungettext = mg_globals.thread_scope.translations.ungettext
# taken from
# https://github.com/django/django/blob/master/django/utils/encoding.py
def py2_unicode(klass):
+ # TODO: Add support for __repr__
if not PY3:
if '__str__' not in klass.__dict__:
raise ValueError("@py2_unicode cannot be applied "
from sqlalchemy import create_engine, event
import logging
+import six
+
from mediagoblin.db.base import Base, Session
from mediagoblin import mg_globals
-from mediagoblin._compat import iteritems
_log = logging.getLogger(__name__)
def __init__(self, engine):
self.engine = engine
- for k, v in iteritems(Base._decl_class_registry):
+ for k, v in six.iteritems(Base._decl_class_registry):
setattr(self, k, v)
def commit(self):
import logging
-from urllib import urlencode
+from six.moves.urllib.parse import urlencode
import six
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import os
+import shutil
+
+from six.moves.urllib.parse import urlparse
+
from mediagoblin.storage import (
StorageInterface,
clean_listy_filepath,
NoWebServing)
-import os
-import shutil
-
-from mediagoblin._compat import urlparse
-
class BasicFileStorage(StorageInterface):
"""
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import six
import jinja2
from jinja2.ext import Extension
from mediagoblin.tools.timesince import timesince
from mediagoblin.meddleware.csrf import render_csrf_form_token
-from mediagoblin._compat import ugettext, ungettext
-
SETUP_JINJA_ENVS = {}
'jinja2.ext.i18n', 'jinja2.ext.autoescape',
TemplateHookExtension] + local_exts)
- template_env.install_gettext_callables(ugettext, ungettext)
+ if six.PY2:
+ template_env.install_gettext_callables(mg_globals.thread_scope.translations.ugettext,
+ mg_globals.thread_scope.translations.ungettext)
+ else:
+ template_env.install_gettext_callables(mg_globals.thread_scope.translations.gettext,
+ mg_globals.thread_scope.translations.ngettext)
# All templates will know how to ...
# ... fetch all waiting messages and remove them from the queue
import gettext
import pkg_resources
+import six
from babel import localedata
from babel.support import LazyProxy
from mediagoblin import mg_globals
-from mediagoblin._compat import ugettext, ungettext
###################
# Translation tools
The reason we can't have a global ugettext method is because
mg_globals gets swapped out by the application per-request.
"""
- return ugettext(*args, **kwargs)
+ if six.PY2:
+ return mg_globals.thread_scope.translations.ugettext(*args, **kwargs)
+ return mg_globals.thread_scope.translations.gettext(*args, **kwargs)
def pass_to_ungettext(*args, **kwargs):
"""
The reason we can't have a global ugettext method is because
mg_globals gets swapped out by the application per-request.
"""
- return ungettext(*args, **kwargs)
+ if six.PY2:
+ return mg_globals.thread_scope.translations.ungettext(*args, **kwargs)
+ return mg_globals.thread_scope.translations.ngettext(*args, **kwargs)
def lazy_pass_to_ugettext(*args, **kwargs):