Change oslo.utils to oslo_utils
The oslo libraries are moving away from namespace packages. A hacking check is added to enforce use of the new location. bp drop-namespace-packages Change-Id: I4ece3ad26c1888388a4a8839f7acf260228a9c71
This commit is contained in:
parent
e0a87595ba
commit
fc009d7e8f
|
@ -16,8 +16,8 @@ import sys
|
|||
|
||||
from keystoneclient.common import cms
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import importutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone.assignment import controllers as assignment_controllers
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystone import auth
|
||||
from keystone.common import controller
|
||||
|
|
|
@ -17,8 +17,8 @@ import datetime
|
|||
|
||||
from dogpile.cache import api
|
||||
from dogpile.cache import util as dp_util
|
||||
from oslo.utils import importutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone import exception
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import dogpile.cache
|
||||
from dogpile.cache import proxy
|
||||
from dogpile.cache import util
|
||||
from oslo.utils import importutils
|
||||
from oslo_utils import importutils
|
||||
|
||||
from keystone import config
|
||||
from keystone import exception
|
||||
|
|
|
@ -22,7 +22,7 @@ from dogpile.cache import proxy
|
|||
from dogpile.cache import region
|
||||
from dogpile.cache import util as dogpile_util
|
||||
from dogpile.core import nameregistry
|
||||
from oslo.utils import importutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
|
||||
from keystone.common import config
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import functools
|
||||
|
||||
from oslo.utils import importutils
|
||||
from oslo_utils import importutils
|
||||
|
||||
|
||||
def response_truncated(f):
|
||||
|
|
|
@ -29,7 +29,7 @@ column.
|
|||
"""
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import strutils
|
||||
from oslo_utils import strutils
|
||||
import sqlalchemy as sql
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ column.
|
|||
"""
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import strutils
|
||||
from oslo_utils import strutils
|
||||
import sqlalchemy as sql
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import migrate
|
|||
from migrate import exceptions
|
||||
from oslo.db.sqlalchemy import migration
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import importutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
import sqlalchemy
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import os
|
|||
import pwd
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import strutils
|
||||
from oslo_utils import strutils
|
||||
import passlib.hash
|
||||
import six
|
||||
from six import moves
|
||||
|
|
|
@ -22,8 +22,8 @@ import copy
|
|||
|
||||
from oslo import i18n
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import importutils
|
||||
from oslo.utils import strutils
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import strutils
|
||||
import routes.middleware
|
||||
import six
|
||||
import webob.dec
|
||||
|
|
|
@ -15,7 +15,7 @@ import os
|
|||
import subprocess
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import saml2
|
||||
from saml2 import md
|
||||
from saml2 import saml
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import re
|
||||
|
||||
import jsonschema
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone.common import config
|
||||
|
|
|
@ -17,7 +17,7 @@ import random
|
|||
import uuid
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone.common import sql
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"""Extensions supporting OAuth1."""
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystone.common import controller
|
||||
from keystone.common import dependency
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
import datetime
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystone.common import kvs
|
||||
from keystone import config
|
||||
|
|
|
@ -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 keystone.common import controller
|
||||
from keystone.common import dependency
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
import abc
|
||||
import datetime
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone.common import cache
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.utils import encodeutils
|
||||
from oslo_utils import encodeutils
|
||||
import six
|
||||
|
||||
from keystone.common import config
|
||||
|
|
|
@ -24,6 +24,7 @@ please see pep8.py.
|
|||
"""
|
||||
|
||||
import ast
|
||||
import re
|
||||
|
||||
import six
|
||||
|
||||
|
@ -396,8 +397,21 @@ class CheckForLoggingIssues(BaseASTChecker):
|
|||
return False
|
||||
|
||||
|
||||
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(CheckForMutableDefaultArgs)
|
||||
register(block_comments_begin_with_a_space)
|
||||
register(CheckForAssertingNoneEquality)
|
||||
register(CheckForLoggingIssues)
|
||||
register(check_oslo_namespace_imports)
|
||||
|
|
|
@ -20,7 +20,7 @@ import os
|
|||
import uuid
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import importutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
|
||||
from keystone import clean
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"""Unified in-memory token model."""
|
||||
|
||||
from keystoneclient.common import cms
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone.common import config
|
||||
|
|
|
@ -179,6 +179,24 @@ class HackingCode(fixtures.Fixture):
|
|||
]
|
||||
}
|
||||
|
||||
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'),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
class HackingLogging(fixtures.Fixture):
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import datetime
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
from testtools import matchers
|
||||
|
||||
from keystone import assignment
|
||||
|
|
|
@ -19,7 +19,7 @@ import uuid
|
|||
|
||||
from keystoneclient.common import cms
|
||||
import mock
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from testtools import matchers
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
import datetime
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone import config
|
||||
|
|
|
@ -19,7 +19,7 @@ from keystoneclient import exceptions as client_exceptions
|
|||
from keystoneclient.v2_0 import client as ks_client
|
||||
import mock
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import webob
|
||||
|
||||
from keystone import config
|
||||
|
|
|
@ -15,7 +15,7 @@ import datetime
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
from testtools import matchers
|
||||
|
||||
from keystone.contrib import revoke
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import datetime
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystone import config
|
||||
from keystone import exception
|
||||
|
|
|
@ -16,7 +16,7 @@ import datetime
|
|||
import uuid
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from testtools import matchers
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import uuid
|
|||
|
||||
from keystoneclient.common import cms
|
||||
import mock
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from testtools import matchers
|
||||
from testtools import testcase
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
import datetime
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from testtools import matchers
|
||||
|
||||
|
|
|
@ -120,3 +120,13 @@ class TestCheckForNonDebugLoggingIssues(BaseStyleCheck):
|
|||
actual_errors = [(e[0] - import_lines, e[1], e[2])
|
||||
for e in actual_errors]
|
||||
self.assertEqual(expected_errors or [], actual_errors)
|
||||
|
||||
|
||||
class TestCheckOsloNamespaceImports(BaseStyleCheck):
|
||||
def get_checker(self):
|
||||
return checks.check_oslo_namespace_imports
|
||||
|
||||
def test(self):
|
||||
code = self.code_ex.oslo_namespace_imports['code']
|
||||
errors = self.code_ex.oslo_namespace_imports['expected_errors']
|
||||
self.assert_has_errors(code, expected_errors=errors)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
import copy
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystone.common import config
|
||||
from keystone import exception
|
||||
|
|
|
@ -17,7 +17,7 @@ import sys
|
|||
|
||||
from keystoneclient.common import cms
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone.common import controller
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
from __future__ import absolute_import
|
||||
import copy
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone.common import kvs
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import copy
|
||||
import functools
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystone.common import sql
|
||||
from keystone import config
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import abc
|
||||
import copy
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone.common import cache
|
||||
|
|
|
@ -21,7 +21,7 @@ import sys
|
|||
import uuid
|
||||
|
||||
from keystoneclient.common import cms
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone.common import cache
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# under the License.
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import time
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from keystone.common import sql
|
||||
from keystone import exception
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from keystone import assignment
|
||||
|
|
Loading…
Reference in New Issue