From 0703ab2de13e0eac7890ccebf9a7f2fbcf8cfd7b Mon Sep 17 00:00:00 2001 From: Piotr Maslanka <piotr.maslanka@henrietta.com.pl> Date: Sun, 8 Oct 2017 07:12:48 +0200 Subject: [PATCH] najs --- coolamqp/framing/field_table.py | 6 +++++- coolamqp/uplink/connection/recv_framer.py | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/coolamqp/framing/field_table.py b/coolamqp/framing/field_table.py index e797556..a818859 100644 --- a/coolamqp/framing/field_table.py +++ b/coolamqp/framing/field_table.py @@ -30,6 +30,7 @@ def _tobufv(buf, value, pattern, *vals): def _frombuf(pattern, buf, offset): return struct.unpack_from(pattern, buf, offset) + def enframe_decimal(buf, v): # convert decimal to bytes dps = 0 for k in six.moves.xrange(20): @@ -63,6 +64,9 @@ def enframe_longstr(buf, value): _tobufv(buf, value, '!I', len(value)) +def _c2none(buf, v): + return None + FIELD_TYPES = { # length, struct, (option)to_bytes (callable(buffer, value)), # (option)from_bytes (callable(buffer, offset) -> @@ -89,7 +93,7 @@ FIELD_TYPES = { lambda val: len(val) + 4), # longstr 'T': (8, '!Q'), - 'V': (0, None, lambda buf, v: None, lambda buf, ofs: None, 0), + 'V': (0, None, _c2none, _c2none, 0), # rendered as None } diff --git a/coolamqp/uplink/connection/recv_framer.py b/coolamqp/uplink/connection/recv_framer.py index 854990f..946e253 100644 --- a/coolamqp/uplink/connection/recv_framer.py +++ b/coolamqp/uplink/connection/recv_framer.py @@ -19,10 +19,7 @@ FRAME_TYPES = { } -if six.PY2: - ordpy2 = ord -else: - ordpy2 = lambda x: x +ordpy2 = ord if six.PY2 else lambda x: x class ReceivingFramer(object): -- GitLab