diff --git a/IPython/kernel/blocking/channels.py b/IPython/kernel/blocking/channels.py index ac383e9..6f762b6 100644 --- a/IPython/kernel/blocking/channels.py +++ b/IPython/kernel/blocking/channels.py @@ -11,21 +11,6 @@ try: except ImportError: from Queue import Queue, Empty # Py 2 -from IPython.utils.py3compat import string_types, iteritems - -# some utilities to validate message structure, these might get moved elsewhere -# if they prove to have more generic utility - -def validate_string_dict(dct): - """Validate that the input is a dict with string keys and values. - - Raises ValueError if not.""" - for k,v in iteritems(dct): - if not isinstance(k, string_types): - raise ValueError('key %r in dict must be a string' % k) - if not isinstance(v, string_types): - raise ValueError('value %r in dict must be a string' % v) - class ZMQSocketChannel(object): """A ZMQ socket in a simple blocking API""" diff --git a/IPython/kernel/channels.py b/IPython/kernel/channels.py index 3e700f5..6fed384 100644 --- a/IPython/kernel/channels.py +++ b/IPython/kernel/channels.py @@ -14,12 +14,10 @@ import zmq # import ZMQError in top-level namespace, to avoid ugly attribute-error messages # during garbage collection of threads at exit: from zmq import ZMQError -from zmq.eventloop import ioloop, zmqstream from IPython.core.release import kernel_protocol_version_info from .channelsabc import HBChannelABC -from IPython.utils.py3compat import string_types, iteritems #----------------------------------------------------------------------------- # Constants and exceptions @@ -30,23 +28,6 @@ major_protocol_version = kernel_protocol_version_info[0] class InvalidPortNumber(Exception): pass -#----------------------------------------------------------------------------- -# Utility functions -#----------------------------------------------------------------------------- - -# some utilities to validate message structure, these might get moved elsewhere -# if they prove to have more generic utility - -def validate_string_dict(dct): - """Validate that the input is a dict with string keys and values. - - Raises ValueError if not.""" - for k,v in iteritems(dct): - if not isinstance(k, string_types): - raise ValueError('key %r in dict must be a string' % k) - if not isinstance(v, string_types): - raise ValueError('value %r in dict must be a string' % v) - def make_shell_socket(context, identity, address): socket = context.socket(zmq.DEALER) diff --git a/IPython/kernel/client.py b/IPython/kernel/client.py index 959bc96..9046dcc 100644 --- a/IPython/kernel/client.py +++ b/IPython/kernel/client.py @@ -4,8 +4,8 @@ # Distributed under the terms of the Modified BSD License. from __future__ import absolute_import -from IPython.kernel.channels import validate_string_dict, major_protocol_version -from IPython.utils.py3compat import string_types +from IPython.kernel.channels import major_protocol_version +from IPython.utils.py3compat import string_types, iteritems import zmq @@ -21,6 +21,20 @@ from .clientabc import KernelClientABC from .connect import ConnectionFileMixin +# some utilities to validate message structure, these might get moved elsewhere +# if they prove to have more generic utility + +def validate_string_dict(dct): + """Validate that the input is a dict with string keys and values. + + Raises ValueError if not.""" + for k,v in iteritems(dct): + if not isinstance(k, string_types): + raise ValueError('key %r in dict must be a string' % k) + if not isinstance(v, string_types): + raise ValueError('value %r in dict must be a string' % v) + + class KernelClient(ConnectionFileMixin): """Communicates with a single kernel on any host via zmq channels. diff --git a/IPython/qt/client.py b/IPython/qt/client.py index 3414523..902f37d 100644 --- a/IPython/qt/client.py +++ b/IPython/qt/client.py @@ -37,28 +37,11 @@ class QtHBChannel(SuperQObject, HBChannel): from IPython.core.release import kernel_protocol_version_info -from IPython.utils.py3compat import string_types, iteritems - major_protocol_version = kernel_protocol_version_info[0] class InvalidPortNumber(Exception): pass -# some utilities to validate message structure, these might get moved elsewhere -# if they prove to have more generic utility - - -def validate_string_dict(dct): - """Validate that the input is a dict with string keys and values. - - Raises ValueError if not.""" - for k,v in iteritems(dct): - if not isinstance(k, string_types): - raise ValueError('key %r in dict must be a string' % k) - if not isinstance(v, string_types): - raise ValueError('value %r in dict must be a string' % v) - - class QtZMQSocketChannel(SuperQObject): """A ZMQ socket emitting a Qt signal when a message is received."""