Remove usage of six.PY2
Neutron is python 3 only so these can be removed. Another step in removing all of six usage from neutron. Change-Id: Ica0913e689bb5b472053661b30f951477d3ec960
This commit is contained in:
parent
08a60f7483
commit
a2a2301675
|
@ -13,19 +13,15 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import builtins
|
||||||
import gettext
|
import gettext
|
||||||
|
|
||||||
from debtcollector import removals
|
from debtcollector import removals
|
||||||
import six
|
|
||||||
|
|
||||||
|
|
||||||
if six.PY2:
|
gettext.install('neutron')
|
||||||
# pylint: disable=unexpected-keyword-arg
|
|
||||||
gettext.install('neutron', unicode=1)
|
|
||||||
else:
|
|
||||||
gettext.install('neutron')
|
|
||||||
|
|
||||||
|
|
||||||
six.moves.builtins.__dict__['_'] = removals.remove(
|
builtins.__dict__['_'] = removals.remove(
|
||||||
message='Builtin _ translation function is deprecated in OpenStack; '
|
message='Builtin _ translation function is deprecated in OpenStack; '
|
||||||
'use the function from _i18n module for your project.')(_) # noqa
|
'use the function from _i18n module for your project.')(_) # noqa
|
||||||
|
|
|
@ -19,7 +19,6 @@ import decorator
|
||||||
from oslo_concurrency import lockutils
|
from oslo_concurrency import lockutils
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -61,10 +60,6 @@ def synchronized(lock_name):
|
||||||
|
|
||||||
@decorator.decorator
|
@decorator.decorator
|
||||||
def _synchronized(f, *a, **k):
|
def _synchronized(f, *a, **k):
|
||||||
if six.PY2:
|
|
||||||
# pylint: disable=deprecated-method
|
|
||||||
call_args = inspect.getcallargs(f, *a, **k)
|
|
||||||
else:
|
|
||||||
sig = inspect.signature(f).bind(*a, **k)
|
sig = inspect.signature(f).bind(*a, **k)
|
||||||
sig.apply_defaults()
|
sig.apply_defaults()
|
||||||
call_args = sig.arguments
|
call_args = sig.arguments
|
||||||
|
|
|
@ -17,7 +17,6 @@ import signal
|
||||||
import socket
|
import socket
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import six
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from neutron_lib import exceptions
|
from neutron_lib import exceptions
|
||||||
|
@ -154,16 +153,11 @@ class AgentUtilsExecuteTest(base.BaseTestCase):
|
||||||
def test_encode_process_input(self):
|
def test_encode_process_input(self):
|
||||||
str_idata = "%s\n" % self.test_file[:-1]
|
str_idata = "%s\n" % self.test_file[:-1]
|
||||||
str_odata = "%s\n" % self.test_file
|
str_odata = "%s\n" % self.test_file
|
||||||
if six.PY3:
|
|
||||||
bytes_idata = str_idata.encode(encoding='utf-8')
|
bytes_idata = str_idata.encode(encoding='utf-8')
|
||||||
bytes_odata = str_odata.encode(encoding='utf-8')
|
bytes_odata = str_odata.encode(encoding='utf-8')
|
||||||
self.mock_popen.return_value = [bytes_odata, b'']
|
self.mock_popen.return_value = [bytes_odata, b'']
|
||||||
result = utils.execute(['cat'], process_input=str_idata)
|
result = utils.execute(['cat'], process_input=str_idata)
|
||||||
self.mock_popen.assert_called_once_with(bytes_idata)
|
self.mock_popen.assert_called_once_with(bytes_idata)
|
||||||
else:
|
|
||||||
self.mock_popen.return_value = [str_odata, '']
|
|
||||||
result = utils.execute(['cat'], process_input=str_idata)
|
|
||||||
self.mock_popen.assert_called_once_with(str_idata)
|
|
||||||
self.assertEqual(str_odata, result)
|
self.assertEqual(str_odata, result)
|
||||||
|
|
||||||
def test_return_str_data(self):
|
def test_return_str_data(self):
|
||||||
|
|
Loading…
Reference in New Issue