From c98478df188876fe8d2607d4b2156b2a46ca2f84 Mon Sep 17 00:00:00 2001 From: Laszlo Hegedus Date: Wed, 25 May 2016 10:49:50 +0200 Subject: [PATCH] Make monasca-common pep8 compatible Cleaned up test-requirements.txt in order to use the latest hacking package. Removed the ignored pep8 checks and made the code pass all of them. Also removed the OpenStack Foundation copyright notice that was put there accidentally before. Change-Id: I3d287eb71fc2bf0e4d52856c11cbc8a347cac2ed --- monasca_common/kafka/consumer.py | 5 ++++- monasca_common/kafka/producer.py | 8 ++++++-- monasca_common/rest/utils.py | 3 +-- monasca_common/tests/test_kafka.py | 21 +++++++++------------ monasca_common/tests/test_rest.py | 2 -- test-requirements.txt | 4 +--- tox.ini | 1 - 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/monasca_common/kafka/consumer.py b/monasca_common/kafka/consumer.py index 208732da..3c2171f2 100644 --- a/monasca_common/kafka/consumer.py +++ b/monasca_common/kafka/consumer.py @@ -54,6 +54,7 @@ class KafkaConsumer(object): commit_callback=None, commit_timeout=30): """Init + kafka_url - Kafka location zookeeper_url - Zookeeper location zookeeper_path - Zookeeper path used for partition @@ -151,7 +152,9 @@ class KafkaConsumer(object): return not self._set_partitioner.acquired def _partition(self): - """Consume messages from kafka using the Kazoo SetPartitioner to + """Consume messages from kafka + + Consume messages from kafka using the Kazoo SetPartitioner to allow multiple consumer processes to negotiate access to the kafka partitions """ diff --git a/monasca_common/kafka/producer.py b/monasca_common/kafka/producer.py index a389dedb..ffa9700e 100644 --- a/monasca_common/kafka/producer.py +++ b/monasca_common/kafka/producer.py @@ -13,20 +13,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -import kafka.client -import kafka.producer import logging import time +import kafka.client +import kafka.producer + log = logging.getLogger(__name__) class KafkaProducer(object): """Adds messages to a kafka topic + """ def __init__(self, url): """Init + url - kafka connection details """ self._kafka = kafka.client.KafkaClient(url) @@ -38,6 +41,7 @@ class KafkaProducer(object): def publish(self, topic, messages, key=None): """Takes messages and puts them on the supplied kafka topic + """ if not isinstance(messages, list): diff --git a/monasca_common/rest/utils.py b/monasca_common/rest/utils.py index 43757c17..13386efc 100644 --- a/monasca_common/rest/utils.py +++ b/monasca_common/rest/utils.py @@ -12,9 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import ujson as json - import six +import ujson as json from monasca_common.rest import exceptions diff --git a/monasca_common/tests/test_kafka.py b/monasca_common/tests/test_kafka.py index 50f35968..a1470e45 100644 --- a/monasca_common/tests/test_kafka.py +++ b/monasca_common/tests/test_kafka.py @@ -1,17 +1,14 @@ -# Copyright (c) 2016 OpenStack Foundation -# All Rights Reserved. +# 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 # -# 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 # -# 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. +# 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 mock import unittest diff --git a/monasca_common/tests/test_rest.py b/monasca_common/tests/test_rest.py index 7d5cbaa8..e137b6c8 100644 --- a/monasca_common/tests/test_rest.py +++ b/monasca_common/tests/test_rest.py @@ -1,5 +1,3 @@ -# Copyright 2016 OpenStack Foundation -# # 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 diff --git a/test-requirements.txt b/test-requirements.txt index b09464c7..a154b0c1 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,11 +1,9 @@ # Hacking already pins down pep8, pyflakes and flake8 -hacking>=0.9.2,<0.10 +hacking>=0.11.0,<0.12 # Apache-2.0 Babel>=1.3 coverage>=3.6 discover fixtures>=0.3.14 -flake8==2.1.0 -pep8<=1.5.6 httplib2>=0.7.5 mock>=1.0 mox>=0.5.3 diff --git a/tox.ini b/tox.ini index b256adf9..5df48b91 100644 --- a/tox.ini +++ b/tox.ini @@ -27,6 +27,5 @@ commands = {posargs} max-complexity = 50 max-line-length = 120 builtins = _ -ignore = F821,H201,H302,H305,H307,H405,H904 exclude=.venv,.git,.tox,dist,*openstack/common*,*egg,build show-source = True