Skip to content

Commit b936017

Browse files
committed
Import cimple with absolute package name
1 parent 40fe906 commit b936017

File tree

4 files changed

+59
-42
lines changed

4 files changed

+59
-42
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ environment:
22
global:
33
LIBRDKAFKA_NUGET_VERSION: 1.4.0-RC4
44
CIBW_SKIP: cp33-* cp34-*
5-
CIBW_BEFORE_TEST: pip install -r tests/requirements.txt -r confluent_kafka/avro/requirements.txt
5+
CIBW_TEST_REQUIRES: pytest pytest-timeout requests fastavro avro trivup requests-mock
66
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
77
# /E:ON and /V:ON options are not enabled in the batch script intepreter
88
# See: http://stackoverflow.com/a/13751649/163740

confluent_kafka/__init__.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@
1919
from .deserializing_consumer import DeserializingConsumer
2020
from .serializing_producer import SerializingProducer
2121

22-
from .cimpl import (Producer,
23-
Consumer,
24-
KafkaError,
25-
KafkaException,
26-
Message,
27-
TopicPartition,
28-
libversion,
29-
version,
30-
TIMESTAMP_NOT_AVAILABLE,
31-
TIMESTAMP_CREATE_TIME,
32-
TIMESTAMP_LOG_APPEND_TIME,
33-
OFFSET_BEGINNING,
34-
OFFSET_END,
35-
OFFSET_STORED,
36-
OFFSET_INVALID)
37-
38-
__all__ = ['admin', 'AvroSerializer', 'Consumer',
22+
from confluent_kafka.cimpl import (Producer,
23+
Consumer,
24+
KafkaError,
25+
KafkaException,
26+
Message,
27+
TopicPartition,
28+
libversion,
29+
version,
30+
TIMESTAMP_NOT_AVAILABLE,
31+
TIMESTAMP_CREATE_TIME,
32+
TIMESTAMP_LOG_APPEND_TIME,
33+
OFFSET_BEGINNING,
34+
OFFSET_END,
35+
OFFSET_STORED,
36+
OFFSET_INVALID)
37+
38+
__all__ = ['admin', 'Consumer',
3939
'KafkaError', 'KafkaException',
4040
'kafkatest', 'libversion', 'Message',
4141
'OFFSET_BEGINNING', 'OFFSET_END', 'OFFSET_INVALID', 'OFFSET_STORED',

confluent_kafka/admin/__init__.py

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
"""
22
Kafka Admin client: create, view, alter, delete topics and resources.
33
"""
4-
from ..cimpl import (KafkaException, # noqa
5-
_AdminClientImpl,
6-
NewTopic,
7-
NewPartitions,
8-
CONFIG_SOURCE_UNKNOWN_CONFIG,
9-
CONFIG_SOURCE_DYNAMIC_TOPIC_CONFIG,
10-
CONFIG_SOURCE_DYNAMIC_BROKER_CONFIG,
11-
CONFIG_SOURCE_DYNAMIC_DEFAULT_BROKER_CONFIG,
12-
CONFIG_SOURCE_STATIC_BROKER_CONFIG,
13-
CONFIG_SOURCE_DEFAULT_CONFIG,
14-
RESOURCE_UNKNOWN,
15-
RESOURCE_ANY,
16-
RESOURCE_TOPIC,
17-
RESOURCE_GROUP,
18-
RESOURCE_BROKER)
4+
from confluent_kafka.cimpl import (KafkaException,
5+
_AdminClientImpl,
6+
NewTopic,
7+
NewPartitions,
8+
CONFIG_SOURCE_UNKNOWN_CONFIG,
9+
CONFIG_SOURCE_DYNAMIC_TOPIC_CONFIG,
10+
CONFIG_SOURCE_DYNAMIC_BROKER_CONFIG,
11+
CONFIG_SOURCE_DYNAMIC_DEFAULT_BROKER_CONFIG,
12+
CONFIG_SOURCE_STATIC_BROKER_CONFIG,
13+
CONFIG_SOURCE_DEFAULT_CONFIG,
14+
RESOURCE_UNKNOWN,
15+
RESOURCE_ANY,
16+
RESOURCE_TOPIC,
17+
RESOURCE_GROUP,
18+
RESOURCE_BROKER)
19+
20+
__all__ = ['CONFIG_SOURCE_DEFAULT_CONFIG',
21+
'CONFIG_SOURCE_DYNAMIC_BROKER_CONFIG',
22+
'CONFIG_SOURCE_DYNAMIC_DEFAULT_BROKER_CONFIG',
23+
'CONFIG_SOURCE_DYNAMIC_TOPIC_CONFIG',
24+
'CONFIG_SOURCE_STATIC_BROKER_CONFIG',
25+
'CONFIG_SOURCE_UNKNOWN_CONFIG',
26+
'NewTopic',
27+
'NewPartitions']
1928

2029
import concurrent.futures
2130
import functools
@@ -122,7 +131,8 @@ def __init__(self, restype, name,
122131
try:
123132
restype = ConfigResource.Type[restype.upper()]
124133
except KeyError:
125-
raise ValueError("Unknown resource type \"%s\": should be a ConfigResource.Type" % restype)
134+
raise ValueError(
135+
"Unknown resource type \"%s\": should be a ConfigResource.Type" % restype)
126136

127137
elif type(restype) == int:
128138
# The C-code passes restype as an int, convert to Type.
@@ -182,7 +192,7 @@ def set_config(self, name, value, overwrite=True):
182192
self.set_config_dict[name] = value
183193

184194

185-
class AdminClient (_AdminClientImpl):
195+
class AdminClient(_AdminClientImpl):
186196
"""
187197
AdminClient provides admin operations for Kafka brokers, topics, groups,
188198
and other resource types supported by the broker.
@@ -203,6 +213,7 @@ class AdminClient (_AdminClientImpl):
203213
204214
Requires broker version v0.11.0.0 or later.
205215
"""
216+
206217
def __init__(self, conf):
207218
"""
208219
Create a new AdminClient using the provided configuration dictionary.
@@ -250,7 +261,8 @@ def _make_resource_result(f, futmap):
250261
for resource, configs in result.items():
251262
fut = futmap.get(resource, None)
252263
if fut is None:
253-
raise RuntimeError("Resource {} not found in future-map: {}".format(resource, futmap))
264+
raise RuntimeError(
265+
"Resource {} not found in future-map: {}".format(resource, futmap))
254266
if resource.error is not None:
255267
# Resource-level exception
256268
fut.set_exception(KafkaException(resource.error))
@@ -462,7 +474,7 @@ def alter_configs(self, resources, **kwargs):
462474
return futmap
463475

464476

465-
class ClusterMetadata (object):
477+
class ClusterMetadata(object):
466478
"""
467479
ClusterMetadata as returned by list_topics() contains information
468480
about the Kafka cluster, brokers, and topics.
@@ -476,6 +488,7 @@ class ClusterMetadata (object):
476488
:ivar int orig_broker_id: The broker this metadata originated from.
477489
:ivar str orig_broker_name: Broker name/address this metadata originated from.
478490
"""
491+
479492
def __init__(self):
480493
self.cluster_id = None
481494
self.controller_id = -1
@@ -491,7 +504,7 @@ def __str__(self):
491504
return str(self.cluster_id)
492505

493506

494-
class BrokerMetadata (object):
507+
class BrokerMetadata(object):
495508
"""
496509
BrokerMetadata contains information about a Kafka broker.
497510
@@ -501,6 +514,7 @@ class BrokerMetadata (object):
501514
:ivar str host: Broker hostname.
502515
:ivar int port: Broker port.
503516
"""
517+
504518
def __init__(self):
505519
self.id = -1
506520
self.host = None
@@ -513,7 +527,7 @@ def __str__(self):
513527
return "{}:{}/{}".format(self.host, self.port, self.id)
514528

515529

516-
class TopicMetadata (object):
530+
class TopicMetadata(object):
517531
"""
518532
TopicMetadata contains information about a Kafka topic.
519533
@@ -523,6 +537,7 @@ class TopicMetadata (object):
523537
:ivar dict partitions: Map of partitions indexed by partition id. Value is PartitionMetadata object.
524538
:ivar KafkaError -error: Topic error, or None. Value is a KafkaError object.
525539
"""
540+
526541
# The dash in "-topic" and "-error" is needed to circumvent a
527542
# Sphinx issue where it tries to reference the same instance variable
528543
# on other classes which raises a warning/error.
@@ -533,15 +548,16 @@ def __init__(self):
533548

534549
def __repr__(self):
535550
if self.error is not None:
536-
return "TopicMetadata({}, {} partitions, {})".format(self.topic, len(self.partitions), self.error)
551+
return "TopicMetadata({}, {} partitions, {})".format(self.topic, len(self.partitions),
552+
self.error)
537553
else:
538554
return "TopicMetadata({}, {} partitions)".format(self.topic, len(self.partitions))
539555

540556
def __str__(self):
541557
return self.topic
542558

543559

544-
class PartitionMetadata (object):
560+
class PartitionMetadata(object):
545561
"""
546562
PartitionsMetadata contains information about a Kafka partition.
547563
@@ -558,6 +574,7 @@ class PartitionMetadata (object):
558574
in ClusterMetadata.brokers. Always check the availability
559575
of a broker id in the brokers dict.
560576
"""
577+
561578
def __init__(self):
562579
self.id = -1
563580
self.leader = -1

confluent_kafka/serializing_producer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# limitations under the License.
1717
#
1818

19-
from .cimpl import Producer as _ProducerImpl
19+
from confluent_kafka.cimpl import Producer as _ProducerImpl
2020
from .serialization import (MessageField,
2121
SerializationContext)
2222

0 commit comments

Comments
 (0)