From 77656b386b97f1781e461a7803824260db5d8555 Mon Sep 17 00:00:00 2001
From: Piotr Maslanka <piotr.maslanka@henrietta.com.pl>
Date: Sun, 8 Oct 2017 05:26:01 +0200
Subject: [PATCH] qosif

---
 coolamqp/attaches/consumer.py                   | 17 +++++++++++------
 .../framing/compilation/content_property.py     |  4 ++--
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/coolamqp/attaches/consumer.py b/coolamqp/attaches/consumer.py
index 5deb6bb..0610bb7 100644
--- a/coolamqp/attaches/consumer.py
+++ b/coolamqp/attaches/consumer.py
@@ -40,6 +40,7 @@ class BodyReceiveMode(object):
     # these constitute received pieces. this is always ZC
 
 
+
 class Consumer(Channeler):
     """
     This object represents a consumer in the system.
@@ -123,12 +124,7 @@ class Consumer(Channeler):
         self.attache_group = None  # attache group this belongs to.
         # if this is not None, then it has an attribute
         # on_cancel_customer(Consumer instance)
-        if qos is not None:
-            if isinstance(qos, int):
-                qos = 0, qos
-            elif qos[0] is None:
-                qos = 0, qos[1]  # prefetch_size=0=undefined
-        self.qos = qos
+        self.qos = _qosify(qos)
         self.qos_update_sent = False  # QoS was not sent to server
 
         self.future_to_notify = future_to_notify
@@ -410,6 +406,15 @@ class Consumer(Channeler):
                 self.set_qos(self.qos[0], self.qos[1])
 
 
+def _qosify(qos):
+    if qos is not None:
+        if isinstance(qos, int):
+            qos = 0, qos
+        elif qos[0] is None:
+            qos = 0, qos[1]  # prefetch_size=0=undefined
+    return qos
+
+
 class MessageReceiver(object):
     """This is an object that is used to received messages.
 
diff --git a/coolamqp/framing/compilation/content_property.py b/coolamqp/framing/compilation/content_property.py
index a3cfe54..e011d76 100644
--- a/coolamqp/framing/compilation/content_property.py
+++ b/coolamqp/framing/compilation/content_property.py
@@ -34,7 +34,7 @@ UNICO = u"u'%s'"
 SPACER = u'''
     """
 '''
-
+GET_SIZE_HEADER = u'\n    def get_size(self):\n'
 
 def _compile_particular_content_property_list_class(zpf, fields):
     """
@@ -129,7 +129,7 @@ def _compile_particular_content_property_list_class(zpf, fields):
     mod.append(u'        return cls(%s)\n' % (FFN, ))
 
     # get_size
-    mod.append(u'\n    def get_size(self):\n')
+    mod.append(GET_SIZE_HEADER)
     mod.append(get_counter(present_fields, prefix=u'self.', indent_level=2)[
                :-1])  # skip eol
     mod.append(u' + %s\n' % (zpf_length,))  # account for pf length
-- 
GitLab