Remove six.PY3
The Python 2.7 Support has been dropped since Ussuri. So remove hacking rules for compatibility between python 2 and 3. Change-Id: Ibed92787d66227fec0cf48c78de8a24f9b39cc52
This commit is contained in:
parent
598fb7c4a9
commit
912849fe1a
@ -19,8 +19,6 @@
|
||||
import gettext
|
||||
import os
|
||||
|
||||
import six
|
||||
|
||||
from oslo_i18n import _lazy
|
||||
from oslo_i18n import _locale
|
||||
from oslo_i18n import _message
|
||||
@ -75,7 +73,7 @@ class TranslatorFactory(object):
|
||||
fallback=True)
|
||||
# Use the appropriate method of the translation object based
|
||||
# on the python version.
|
||||
m = t.gettext if six.PY3 else t.ugettext
|
||||
m = t.gettext
|
||||
|
||||
def f(msg):
|
||||
"""oslo_i18n.gettextutils translation function."""
|
||||
@ -103,7 +101,7 @@ class TranslatorFactory(object):
|
||||
fallback=True)
|
||||
# Use the appropriate method of the translation object based
|
||||
# on the python version.
|
||||
m = t.gettext if six.PY3 else t.ugettext
|
||||
m = t.gettext
|
||||
|
||||
def f(ctx, msg):
|
||||
"""oslo.i18n.gettextutils translation with context function."""
|
||||
@ -140,7 +138,7 @@ class TranslatorFactory(object):
|
||||
fallback=True)
|
||||
# Use the appropriate method of the translation object based
|
||||
# on the python version.
|
||||
m = t.ngettext if six.PY3 else t.ungettext
|
||||
m = t.ngettext
|
||||
|
||||
def f(msgsingle, msgplural, msgcount):
|
||||
"""oslo.i18n.gettextutils plural translation function."""
|
||||
|
@ -117,7 +117,7 @@ class Message(six.text_type):
|
||||
|
||||
if not has_contextual_form and not has_plural_form:
|
||||
# This is the most common case, so check it first.
|
||||
translator = lang.gettext if six.PY3 else lang.ugettext
|
||||
translator = lang.gettext
|
||||
translated_message = translator(msgid)
|
||||
|
||||
elif has_contextual_form and has_plural_form:
|
||||
@ -127,7 +127,7 @@ class Message(six.text_type):
|
||||
|
||||
elif has_contextual_form:
|
||||
(msgctx, msgtxt) = msgid
|
||||
translator = lang.gettext if six.PY3 else lang.ugettext
|
||||
translator = lang.gettext
|
||||
|
||||
msg_with_ctx = "%s%s%s" % (msgctx, CONTEXT_SEPARATOR, msgtxt)
|
||||
translated_message = translator(msg_with_ctx)
|
||||
@ -138,7 +138,7 @@ class Message(six.text_type):
|
||||
|
||||
elif has_plural_form:
|
||||
(msgsingle, msgplural, msgcount) = msgid
|
||||
translator = lang.ngettext if six.PY3 else lang.ungettext
|
||||
translator = lang.ngettext
|
||||
translated_message = translator(msgsingle, msgplural, msgcount)
|
||||
|
||||
return translated_message
|
||||
|
@ -168,10 +168,7 @@ class MessageTestCase(test_base.BaseTestCase):
|
||||
# Now set up ugettext to return the translated version of
|
||||
# the original message, with a bad format string.
|
||||
wrong_type = u'Wrong type %(arg1)d'
|
||||
if six.PY3:
|
||||
trans.return_value.gettext.return_value = wrong_type
|
||||
else:
|
||||
trans.return_value.ugettext.return_value = wrong_type
|
||||
trans_result = result.translation()
|
||||
expected = msgid % params
|
||||
self.assertEqual(expected, trans_result)
|
||||
|
@ -12,18 +12,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class SomeObject(object):
|
||||
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.message
|
||||
# alias for Python 3
|
||||
__str__ = __unicode__
|
||||
|
||||
|
||||
class NoDeepCopyObject(object):
|
||||
@ -31,12 +27,8 @@ class NoDeepCopyObject(object):
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
if six.PY3:
|
||||
def __str__(self):
|
||||
return str(self.value)
|
||||
else:
|
||||
def __unicode__(self):
|
||||
return six.text_type(self.value)
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
raise TypeError('Deep Copy not supported')
|
||||
|
Loading…
Reference in New Issue
Block a user