Switch from oslo.utils to oslo_utils
oslo_utils moved out of the oslo namespace. bp drop-namespace-packages Change-Id: I72e67dc1f649ba137dd06f5ab7133858c6abd67d
This commit is contained in:
parent
bf99f4c1ef
commit
ab09d3eb5f
@ -17,7 +17,7 @@
|
||||
|
||||
import datetime
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystoneclient.i18n import _
|
||||
from keystoneclient import service_catalog
|
||||
|
@ -10,7 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
# The set of attributes common between the RevokeEvent
|
||||
# and the dictionaries created from the token Data.
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
import datetime
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystoneclient import utils
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystoneclient.fixture import exception
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystoneclient.fixture import exception
|
||||
|
||||
|
0
keystoneclient/hacking/__init__.py
Normal file
0
keystoneclient/hacking/__init__.py
Normal file
38
keystoneclient/hacking/checks.py
Normal file
38
keystoneclient/hacking/checks.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""python-keystoneclient's pep8 extensions.
|
||||
|
||||
In order to make the review process faster and easier for core devs we are
|
||||
adding some python-keystoneclient specific pep8 checks. This will catch common
|
||||
errors so that core devs don't have to.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import re
|
||||
|
||||
|
||||
def check_oslo_namespace_imports(logical_line, blank_before, filename):
|
||||
oslo_namespace_imports = re.compile(
|
||||
r"(((from)|(import))\s+oslo\.utils)|"
|
||||
"(from\s+oslo\s+import\s+utils)")
|
||||
|
||||
if re.match(oslo_namespace_imports, logical_line):
|
||||
msg = ("K333: '%s' must be used instead of '%s'.") % (
|
||||
logical_line.replace('oslo.', 'oslo_'),
|
||||
logical_line)
|
||||
yield(0, msg)
|
||||
|
||||
|
||||
def factory(register):
|
||||
register(check_oslo_namespace_imports)
|
@ -159,7 +159,7 @@ import time
|
||||
import netaddr
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import requests
|
||||
import six
|
||||
from six.moves import urllib
|
||||
|
@ -19,7 +19,7 @@ import time
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import importutils
|
||||
from oslo_utils import importutils
|
||||
import requests
|
||||
import six
|
||||
from six.moves import urllib
|
||||
|
@ -30,7 +30,7 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from oslo.utils import encodeutils
|
||||
from oslo_utils import encodeutils
|
||||
import six
|
||||
|
||||
import keystoneclient
|
||||
|
@ -14,7 +14,7 @@ import abc
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystoneclient import access
|
||||
|
@ -16,7 +16,7 @@ import os
|
||||
|
||||
import fixtures
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
import testresources
|
||||
|
||||
@ -535,3 +535,27 @@ class Examples(fixtures.Fixture):
|
||||
|
||||
|
||||
EXAMPLES_RESOURCE = testresources.FixtureResource(Examples())
|
||||
|
||||
|
||||
class HackingCode(fixtures.Fixture):
|
||||
"""A fixture to house the various code examples for the keystoneclient
|
||||
hacking style checks.
|
||||
"""
|
||||
|
||||
oslo_namespace_imports = {
|
||||
'code': """
|
||||
import oslo.utils
|
||||
import oslo_utils
|
||||
import oslo.utils.encodeutils
|
||||
import oslo_utils.encodeutils
|
||||
from oslo import utils
|
||||
from oslo.utils import encodeutils
|
||||
from oslo_utils import encodeutils
|
||||
""",
|
||||
'expected_errors': [
|
||||
(1, 0, 'K333'),
|
||||
(3, 0, 'K333'),
|
||||
(5, 0, 'K333'),
|
||||
(6, 0, 'K333'),
|
||||
],
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import fixtures
|
||||
import iso8601
|
||||
import mock
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
from requests_mock.contrib import fixture as mock_fixture
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
47
keystoneclient/tests/test_hacking_checks.py
Normal file
47
keystoneclient/tests/test_hacking_checks.py
Normal file
@ -0,0 +1,47 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import textwrap
|
||||
|
||||
import mock
|
||||
import pep8
|
||||
import testtools
|
||||
|
||||
from keystoneclient.hacking import checks
|
||||
from keystoneclient.tests import client_fixtures
|
||||
|
||||
|
||||
class TestCheckOsloNamespaceImports(testtools.TestCase):
|
||||
|
||||
# We are patching pep8 so that only the check under test is actually
|
||||
# installed.
|
||||
@mock.patch('pep8._checks',
|
||||
{'physical_line': {}, 'logical_line': {}, 'tree': {}})
|
||||
def run_check(self, code):
|
||||
pep8.register_check(checks.check_oslo_namespace_imports)
|
||||
|
||||
lines = textwrap.dedent(code).strip().splitlines(True)
|
||||
|
||||
checker = pep8.Checker(lines=lines)
|
||||
checker.check_all()
|
||||
checker.report._deferred_print.sort()
|
||||
return checker.report._deferred_print
|
||||
|
||||
def assert_has_errors(self, code, expected_errors=None):
|
||||
actual_errors = [e[:3] for e in self.run_check(code)]
|
||||
self.assertEqual(expected_errors or [], actual_errors)
|
||||
|
||||
def test(self):
|
||||
code_ex = self.useFixture(client_fixtures.HackingCode())
|
||||
code = code_ex.oslo_namespace_imports['code']
|
||||
errors = code_ex.oslo_namespace_imports['expected_errors']
|
||||
self.assert_has_errors(code, expected_errors=errors)
|
@ -13,7 +13,7 @@
|
||||
import datetime
|
||||
|
||||
import mock
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystoneclient import access
|
||||
from keystoneclient import httpclient
|
||||
|
@ -13,7 +13,7 @@
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import testresources
|
||||
|
||||
from keystoneclient import access
|
||||
|
@ -14,7 +14,7 @@ import copy
|
||||
import datetime
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient.tests.v2_0 import utils
|
||||
|
@ -13,7 +13,7 @@
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystoneclient import access
|
||||
from keystoneclient import fixture
|
||||
|
@ -14,7 +14,7 @@
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from testtools import matchers
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient.tests.v3 import utils
|
||||
|
@ -17,7 +17,7 @@ import inspect
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from oslo.utils import encodeutils
|
||||
from oslo_utils import encodeutils
|
||||
import prettytable
|
||||
import six
|
||||
|
||||
|
@ -26,7 +26,7 @@ import argparse
|
||||
import getpass
|
||||
import sys
|
||||
|
||||
from oslo.utils import strutils
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
|
||||
from keystoneclient.i18n import _
|
||||
|
@ -10,7 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystoneclient import base
|
||||
from keystoneclient import exceptions
|
||||
|
Loading…
Reference in New Issue
Block a user