Simplify public symbol exports
Inspired by tulip, have every module define a __all__ list and import * from the top-level module. Rename transport.set_defaults() since we don't want this to be a top-level set_defaults() function as there may be multiple. Also, rather than configuring flake8 to allow star imports, just exclude the __init__.py files from flake8 checks.
This commit is contained in:
parent
d31ae442ca
commit
03aafcb49c
@ -13,43 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.messaging import exceptions
|
||||
from oslo.messaging.rpc import client
|
||||
from oslo.messaging.rpc import dispatcher as rpc_dispatcher
|
||||
from oslo.messaging.rpc import server as rpc_server
|
||||
from oslo.messaging import serializer
|
||||
from oslo.messaging import server
|
||||
from oslo.messaging import target
|
||||
from oslo.messaging import transport
|
||||
|
||||
|
||||
get_transport = transport.get_transport
|
||||
Target = target.Target
|
||||
|
||||
RPCClient = client.RPCClient
|
||||
|
||||
MessageHandlingServer = server.MessageHandlingServer
|
||||
get_rpc_server = rpc_server.get_rpc_server
|
||||
RPCDispatcher = rpc_dispatcher.RPCDispatcher
|
||||
Serializer = serializer.Serializer
|
||||
|
||||
|
||||
#
|
||||
# Exceptions
|
||||
#
|
||||
MessagingException = exceptions.MessagingException
|
||||
MessagingTimeout = exceptions.MessagingTimeout
|
||||
|
||||
DriverLoadFailure = transport.DriverLoadFailure
|
||||
InvalidTransportURL = transport.InvalidTransportURL
|
||||
|
||||
RPCVersionCapError = client.RPCVersionCapError
|
||||
ClientSendError = client.ClientSendError
|
||||
|
||||
MessagingServerError = server.MessagingServerError
|
||||
ExecutorLoadFailure = server.ExecutorLoadFailure
|
||||
ServerListenError = server.ServerListenError
|
||||
|
||||
RPCDispatcherError = rpc_dispatcher.RPCDispatcherError
|
||||
NoSuchMethod = rpc_dispatcher.NoSuchMethod
|
||||
UnsupportedVersion = rpc_dispatcher.UnsupportedVersion
|
||||
from .exceptions import *
|
||||
from .rpc import *
|
||||
from .serializer import *
|
||||
from .server import *
|
||||
from .target import *
|
||||
from .transport import *
|
||||
|
@ -13,6 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__all__ = ['MessagingException', 'MessagingTimeout']
|
||||
|
||||
|
||||
class MessagingException(Exception):
|
||||
"""Base class for exceptions."""
|
||||
|
@ -12,3 +12,18 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__all__ = [
|
||||
'ClientSendError',
|
||||
'NoSuchMethod',
|
||||
'RPCClient',
|
||||
'RPCDispatcher',
|
||||
'RPCDispatcherError',
|
||||
'RPCVersionCapError',
|
||||
'UnsupportedVersion',
|
||||
'get_rpc_server',
|
||||
]
|
||||
|
||||
from client import *
|
||||
from dispatcher import *
|
||||
from server import *
|
||||
|
@ -16,6 +16,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__all__ = [
|
||||
'ClientSendError',
|
||||
'RPCClient',
|
||||
'RPCVersionCapError',
|
||||
]
|
||||
|
||||
import inspect
|
||||
import logging
|
||||
|
||||
|
@ -16,6 +16,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__all__ = [
|
||||
'NoSuchMethod',
|
||||
'RPCDispatcher',
|
||||
'RPCDispatcherError',
|
||||
'UnsupportedVersion',
|
||||
]
|
||||
|
||||
import logging
|
||||
|
||||
from oslo.messaging import _utils as utils
|
||||
|
@ -13,6 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__all__ = ['get_rpc_server']
|
||||
|
||||
from oslo.messaging.rpc import dispatcher as rpc_dispatcher
|
||||
from oslo.messaging import server as msg_server
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__all__ = ['Serializer', 'NoOpSerializer']
|
||||
|
||||
"""Provides the definition of a message serialization handler"""
|
||||
|
||||
import abc
|
||||
|
@ -16,6 +16,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__all__ = [
|
||||
'ExecutorLoadFailure',
|
||||
'MessageHandlingServer',
|
||||
'MessagingServerError',
|
||||
'ServerListenError',
|
||||
]
|
||||
|
||||
import logging
|
||||
|
||||
from stevedore import driver
|
||||
|
@ -16,6 +16,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__all__ = [
|
||||
'DriverLoadFailure',
|
||||
'InvalidTransportURL',
|
||||
'Transport',
|
||||
'get_transport',
|
||||
'set_transport_defaults',
|
||||
]
|
||||
|
||||
import urlparse
|
||||
|
||||
from oslo.config import cfg
|
||||
@ -42,7 +50,7 @@ _transport_opts = [
|
||||
]
|
||||
|
||||
|
||||
def set_defaults(control_exchange):
|
||||
def set_transport_defaults(control_exchange):
|
||||
"""Set defaults for messaging transport configuration options.
|
||||
|
||||
:param control_exchange: the default exchange under which topics are scoped
|
||||
|
@ -209,12 +209,12 @@ class TestSetDefaults(test_utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSetDefaults, self).setUp(conf=cfg.ConfigOpts())
|
||||
self.useFixture(_SetDefaultsFixture(transport.set_defaults,
|
||||
self.useFixture(_SetDefaultsFixture(messaging.set_transport_defaults,
|
||||
transport._transport_opts,
|
||||
'control_exchange'))
|
||||
|
||||
def test_set_default_control_exchange(self):
|
||||
transport.set_defaults(control_exchange='foo')
|
||||
messaging.set_transport_defaults(control_exchange='foo')
|
||||
|
||||
self.mox.StubOutWithMock(driver, 'DriverManager')
|
||||
invoke_kwds = mox.ContainsKeyValue('default_exchange', 'foo')
|
||||
|
Loading…
Reference in New Issue
Block a user