summaryrefslogtreecommitdiff
path: root/kafka/codec.py
diff options
context:
space:
mode:
authorMahendra M <mahendra.m@gmail.com>2013-05-29 14:20:58 +0530
committerDavid Arthur <mumrah@gmail.com>2013-05-29 16:38:39 -0400
commit2c257eeb1f02748840a8f4535d8d2a88ef5235f2 (patch)
tree73ff852a845bdb947f0820ea1ff64c7b72436c9b /kafka/codec.py
parent97962d4af3c0e57a549f432a7604f8ba0c5914fd (diff)
downloadkafka-python-2c257eeb1f02748840a8f4535d8d2a88ef5235f2.tar.gz
PEP8-ify most of the files
consumer.py and conn.py will be done later after pending merges
Diffstat (limited to 'kafka/codec.py')
-rw-r--r--kafka/codec.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/kafka/codec.py b/kafka/codec.py
index 83f3c0b..c7d3992 100644
--- a/kafka/codec.py
+++ b/kafka/codec.py
@@ -6,10 +6,11 @@ log = logging.getLogger("kafka.codec")
try:
import snappy
- hasSnappy=True
+ hasSnappy = True
except ImportError:
log.warn("Snappy codec not available")
- hasSnappy=False
+ hasSnappy = False
+
def gzip_encode(payload):
buf = StringIO()
@@ -21,6 +22,7 @@ def gzip_encode(payload):
buf.close()
return out
+
def gzip_decode(payload):
buf = StringIO(payload)
f = gzip.GzipFile(fileobj=buf, mode='r')
@@ -29,11 +31,13 @@ def gzip_decode(payload):
buf.close()
return out
+
def snappy_encode(payload):
if not hasSnappy:
raise NotImplementedError("Snappy codec not available")
return snappy.compress(payload)
+
def snappy_decode(payload):
if not hasSnappy:
raise NotImplementedError("Snappy codec not available")