Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove UTF-8 decoding in spec

  • Loading branch information...
commit e37f3367883950bf94f35bd29153067c5736608f 1 parent ddc35a9
@gmr gmr authored
Showing with 85 additions and 85 deletions.
  1. +62 −62 pika/spec.py
  2. +23 −23 utils/codegen.py
View
124 pika/spec.py
@@ -73,7 +73,7 @@ def decode(self, encoded, offset=0):
(self.server_properties, offset) = data.decode_table(encoded, offset)
length = struct.unpack_from('>I', encoded, offset)[0]
offset += 4
- self.mechanisms = encoded[offset:offset + length].decode('utf8')
+ self.mechanisms = encoded[offset:offset + length]
try:
self.mechanisms = str(self.mechanisms)
except UnicodeEncodeError:
@@ -81,7 +81,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('>I', encoded, offset)[0]
offset += 4
- self.locales = encoded[offset:offset + length].decode('utf8')
+ self.locales = encoded[offset:offset + length]
try:
self.locales = str(self.locales)
except UnicodeEncodeError:
@@ -125,7 +125,7 @@ def decode(self, encoded, offset=0):
(self.client_properties, offset) = data.decode_table(encoded, offset)
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.mechanism = encoded[offset:offset + length].decode('utf8')
+ self.mechanism = encoded[offset:offset + length]
try:
self.mechanism = str(self.mechanism)
except UnicodeEncodeError:
@@ -133,7 +133,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('>I', encoded, offset)[0]
offset += 4
- self.response = encoded[offset:offset + length].decode('utf8')
+ self.response = encoded[offset:offset + length]
try:
self.response = str(self.response)
except UnicodeEncodeError:
@@ -141,7 +141,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.locale = encoded[offset:offset + length].decode('utf8')
+ self.locale = encoded[offset:offset + length]
try:
self.locale = str(self.locale)
except UnicodeEncodeError:
@@ -184,7 +184,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('>I', encoded, offset)[0]
offset += 4
- self.challenge = encoded[offset:offset + length].decode('utf8')
+ self.challenge = encoded[offset:offset + length]
try:
self.challenge = str(self.challenge)
except UnicodeEncodeError:
@@ -216,7 +216,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('>I', encoded, offset)[0]
offset += 4
- self.response = encoded[offset:offset + length].decode('utf8')
+ self.response = encoded[offset:offset + length]
try:
self.response = str(self.response)
except UnicodeEncodeError:
@@ -310,7 +310,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.virtual_host = encoded[offset:offset + length].decode('utf8')
+ self.virtual_host = encoded[offset:offset + length]
try:
self.virtual_host = str(self.virtual_host)
except UnicodeEncodeError:
@@ -318,7 +318,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.capabilities = encoded[offset:offset + length].decode('utf8')
+ self.capabilities = encoded[offset:offset + length]
try:
self.capabilities = str(self.capabilities)
except UnicodeEncodeError:
@@ -362,7 +362,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.known_hosts = encoded[offset:offset + length].decode('utf8')
+ self.known_hosts = encoded[offset:offset + length]
try:
self.known_hosts = str(self.known_hosts)
except UnicodeEncodeError:
@@ -399,7 +399,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.reply_text = encoded[offset:offset + length].decode('utf8')
+ self.reply_text = encoded[offset:offset + length]
try:
self.reply_text = str(self.reply_text)
except UnicodeEncodeError:
@@ -457,7 +457,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.reason = encoded[offset:offset + length].decode('utf8')
+ self.reason = encoded[offset:offset + length]
try:
self.reason = str(self.reason)
except UnicodeEncodeError:
@@ -514,7 +514,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.out_of_band = encoded[offset:offset + length].decode('utf8')
+ self.out_of_band = encoded[offset:offset + length]
try:
self.out_of_band = str(self.out_of_band)
except UnicodeEncodeError:
@@ -546,7 +546,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('>I', encoded, offset)[0]
offset += 4
- self.channel_id = encoded[offset:offset + length].decode('utf8')
+ self.channel_id = encoded[offset:offset + length]
try:
self.channel_id = str(self.channel_id)
except UnicodeEncodeError:
@@ -635,7 +635,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.reply_text = encoded[offset:offset + length].decode('utf8')
+ self.reply_text = encoded[offset:offset + length]
try:
self.reply_text = str(self.reply_text)
except UnicodeEncodeError:
@@ -704,7 +704,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.realm = encoded[offset:offset + length].decode('utf8')
+ self.realm = encoded[offset:offset + length]
try:
self.realm = str(self.realm)
except UnicodeEncodeError:
@@ -793,7 +793,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.exchange = encoded[offset:offset + length].decode('utf8')
+ self.exchange = encoded[offset:offset + length]
try:
self.exchange = str(self.exchange)
except UnicodeEncodeError:
@@ -801,7 +801,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.type = encoded[offset:offset + length].decode('utf8')
+ self.type = encoded[offset:offset + length]
try:
self.type = str(self.type)
except UnicodeEncodeError:
@@ -884,7 +884,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.exchange = encoded[offset:offset + length].decode('utf8')
+ self.exchange = encoded[offset:offset + length]
try:
self.exchange = str(self.exchange)
except UnicodeEncodeError:
@@ -953,7 +953,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.destination = encoded[offset:offset + length].decode('utf8')
+ self.destination = encoded[offset:offset + length]
try:
self.destination = str(self.destination)
except UnicodeEncodeError:
@@ -961,7 +961,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.source = encoded[offset:offset + length].decode('utf8')
+ self.source = encoded[offset:offset + length]
try:
self.source = str(self.source)
except UnicodeEncodeError:
@@ -969,7 +969,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.routing_key = encoded[offset:offset + length].decode('utf8')
+ self.routing_key = encoded[offset:offset + length]
try:
self.routing_key = str(self.routing_key)
except UnicodeEncodeError:
@@ -1047,7 +1047,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.destination = encoded[offset:offset + length].decode('utf8')
+ self.destination = encoded[offset:offset + length]
try:
self.destination = str(self.destination)
except UnicodeEncodeError:
@@ -1055,7 +1055,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.source = encoded[offset:offset + length].decode('utf8')
+ self.source = encoded[offset:offset + length]
try:
self.source = str(self.source)
except UnicodeEncodeError:
@@ -1063,7 +1063,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.routing_key = encoded[offset:offset + length].decode('utf8')
+ self.routing_key = encoded[offset:offset + length]
try:
self.routing_key = str(self.routing_key)
except UnicodeEncodeError:
@@ -1149,7 +1149,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.queue = encoded[offset:offset + length].decode('utf8')
+ self.queue = encoded[offset:offset + length]
try:
self.queue = str(self.queue)
except UnicodeEncodeError:
@@ -1205,7 +1205,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.queue = encoded[offset:offset + length].decode('utf8')
+ self.queue = encoded[offset:offset + length]
try:
self.queue = str(self.queue)
except UnicodeEncodeError:
@@ -1250,7 +1250,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.queue = encoded[offset:offset + length].decode('utf8')
+ self.queue = encoded[offset:offset + length]
try:
self.queue = str(self.queue)
except UnicodeEncodeError:
@@ -1258,7 +1258,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.exchange = encoded[offset:offset + length].decode('utf8')
+ self.exchange = encoded[offset:offset + length]
try:
self.exchange = str(self.exchange)
except UnicodeEncodeError:
@@ -1266,7 +1266,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.routing_key = encoded[offset:offset + length].decode('utf8')
+ self.routing_key = encoded[offset:offset + length]
try:
self.routing_key = str(self.routing_key)
except UnicodeEncodeError:
@@ -1341,7 +1341,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.queue = encoded[offset:offset + length].decode('utf8')
+ self.queue = encoded[offset:offset + length]
try:
self.queue = str(self.queue)
except UnicodeEncodeError:
@@ -1409,7 +1409,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.queue = encoded[offset:offset + length].decode('utf8')
+ self.queue = encoded[offset:offset + length]
try:
self.queue = str(self.queue)
except UnicodeEncodeError:
@@ -1483,7 +1483,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.queue = encoded[offset:offset + length].decode('utf8')
+ self.queue = encoded[offset:offset + length]
try:
self.queue = str(self.queue)
except UnicodeEncodeError:
@@ -1491,7 +1491,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.exchange = encoded[offset:offset + length].decode('utf8')
+ self.exchange = encoded[offset:offset + length]
try:
self.exchange = str(self.exchange)
except UnicodeEncodeError:
@@ -1499,7 +1499,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.routing_key = encoded[offset:offset + length].decode('utf8')
+ self.routing_key = encoded[offset:offset + length]
try:
self.routing_key = str(self.routing_key)
except UnicodeEncodeError:
@@ -1631,7 +1631,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.queue = encoded[offset:offset + length].decode('utf8')
+ self.queue = encoded[offset:offset + length]
try:
self.queue = str(self.queue)
except UnicodeEncodeError:
@@ -1639,7 +1639,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.consumer_tag = encoded[offset:offset + length].decode('utf8')
+ self.consumer_tag = encoded[offset:offset + length]
try:
self.consumer_tag = str(self.consumer_tag)
except UnicodeEncodeError:
@@ -1695,7 +1695,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.consumer_tag = encoded[offset:offset + length].decode('utf8')
+ self.consumer_tag = encoded[offset:offset + length]
try:
self.consumer_tag = str(self.consumer_tag)
except UnicodeEncodeError:
@@ -1728,7 +1728,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.consumer_tag = encoded[offset:offset + length].decode('utf8')
+ self.consumer_tag = encoded[offset:offset + length]
try:
self.consumer_tag = str(self.consumer_tag)
except UnicodeEncodeError:
@@ -1767,7 +1767,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.consumer_tag = encoded[offset:offset + length].decode('utf8')
+ self.consumer_tag = encoded[offset:offset + length]
try:
self.consumer_tag = str(self.consumer_tag)
except UnicodeEncodeError:
@@ -1805,7 +1805,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.exchange = encoded[offset:offset + length].decode('utf8')
+ self.exchange = encoded[offset:offset + length]
try:
self.exchange = str(self.exchange)
except UnicodeEncodeError:
@@ -1813,7 +1813,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.routing_key = encoded[offset:offset + length].decode('utf8')
+ self.routing_key = encoded[offset:offset + length]
try:
self.routing_key = str(self.routing_key)
except UnicodeEncodeError:
@@ -1866,7 +1866,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.reply_text = encoded[offset:offset + length].decode('utf8')
+ self.reply_text = encoded[offset:offset + length]
try:
self.reply_text = str(self.reply_text)
except UnicodeEncodeError:
@@ -1874,7 +1874,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.exchange = encoded[offset:offset + length].decode('utf8')
+ self.exchange = encoded[offset:offset + length]
try:
self.exchange = str(self.exchange)
except UnicodeEncodeError:
@@ -1882,7 +1882,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.routing_key = encoded[offset:offset + length].decode('utf8')
+ self.routing_key = encoded[offset:offset + length]
try:
self.routing_key = str(self.routing_key)
except UnicodeEncodeError:
@@ -1929,7 +1929,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.consumer_tag = encoded[offset:offset + length].decode('utf8')
+ self.consumer_tag = encoded[offset:offset + length]
try:
self.consumer_tag = str(self.consumer_tag)
except UnicodeEncodeError:
@@ -1942,7 +1942,7 @@ def decode(self, encoded, offset=0):
self.redelivered = (bit_buffer & (1 << 0)) != 0
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.exchange = encoded[offset:offset + length].decode('utf8')
+ self.exchange = encoded[offset:offset + length]
try:
self.exchange = str(self.exchange)
except UnicodeEncodeError:
@@ -1950,7 +1950,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.routing_key = encoded[offset:offset + length].decode('utf8')
+ self.routing_key = encoded[offset:offset + length]
try:
self.routing_key = str(self.routing_key)
except UnicodeEncodeError:
@@ -2001,7 +2001,7 @@ def decode(self, encoded, offset=0):
offset += 2
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.queue = encoded[offset:offset + length].decode('utf8')
+ self.queue = encoded[offset:offset + length]
try:
self.queue = str(self.queue)
except UnicodeEncodeError:
@@ -2050,7 +2050,7 @@ def decode(self, encoded, offset=0):
self.redelivered = (bit_buffer & (1 << 0)) != 0
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.exchange = encoded[offset:offset + length].decode('utf8')
+ self.exchange = encoded[offset:offset + length]
try:
self.exchange = str(self.exchange)
except UnicodeEncodeError:
@@ -2058,7 +2058,7 @@ def decode(self, encoded, offset=0):
offset += length
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.routing_key = encoded[offset:offset + length].decode('utf8')
+ self.routing_key = encoded[offset:offset + length]
try:
self.routing_key = str(self.routing_key)
except UnicodeEncodeError:
@@ -2103,7 +2103,7 @@ def synchronous(self):
def decode(self, encoded, offset=0):
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.cluster_id = encoded[offset:offset + length].decode('utf8')
+ self.cluster_id = encoded[offset:offset + length]
try:
self.cluster_id = str(self.cluster_id)
except UnicodeEncodeError:
@@ -2507,7 +2507,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_CONTENT_TYPE:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.content_type = encoded[offset:offset + length].decode('utf8')
+ self.content_type = encoded[offset:offset + length]
try:
self.content_type = str(self.content_type)
except UnicodeEncodeError:
@@ -2518,7 +2518,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_CONTENT_ENCODING:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.content_encoding = encoded[offset:offset + length].decode('utf8')
+ self.content_encoding = encoded[offset:offset + length]
try:
self.content_encoding = str(self.content_encoding)
except UnicodeEncodeError:
@@ -2543,7 +2543,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_CORRELATION_ID:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.correlation_id = encoded[offset:offset + length].decode('utf8')
+ self.correlation_id = encoded[offset:offset + length]
try:
self.correlation_id = str(self.correlation_id)
except UnicodeEncodeError:
@@ -2554,7 +2554,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_REPLY_TO:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.reply_to = encoded[offset:offset + length].decode('utf8')
+ self.reply_to = encoded[offset:offset + length]
try:
self.reply_to = str(self.reply_to)
except UnicodeEncodeError:
@@ -2565,7 +2565,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_EXPIRATION:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.expiration = encoded[offset:offset + length].decode('utf8')
+ self.expiration = encoded[offset:offset + length]
try:
self.expiration = str(self.expiration)
except UnicodeEncodeError:
@@ -2576,7 +2576,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_MESSAGE_ID:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.message_id = encoded[offset:offset + length].decode('utf8')
+ self.message_id = encoded[offset:offset + length]
try:
self.message_id = str(self.message_id)
except UnicodeEncodeError:
@@ -2592,7 +2592,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_TYPE:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.type = encoded[offset:offset + length].decode('utf8')
+ self.type = encoded[offset:offset + length]
try:
self.type = str(self.type)
except UnicodeEncodeError:
@@ -2603,7 +2603,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_USER_ID:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.user_id = encoded[offset:offset + length].decode('utf8')
+ self.user_id = encoded[offset:offset + length]
try:
self.user_id = str(self.user_id)
except UnicodeEncodeError:
@@ -2614,7 +2614,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_APP_ID:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.app_id = encoded[offset:offset + length].decode('utf8')
+ self.app_id = encoded[offset:offset + length]
try:
self.app_id = str(self.app_id)
except UnicodeEncodeError:
@@ -2625,7 +2625,7 @@ def decode(self, encoded, offset=0):
if flags & BasicProperties.FLAG_CLUSTER_ID:
length = struct.unpack_from('B', encoded, offset)[0]
offset += 1
- self.cluster_id = encoded[offset:offset + length].decode('utf8')
+ self.cluster_id = encoded[offset:offset + length]
try:
self.cluster_id = str(self.cluster_id)
except UnicodeEncodeError:
View
46 utils/codegen.py
@@ -90,7 +90,7 @@ def genSingleDecode(prefix, cLvalue, unresolved_domain):
if type == 'shortstr':
print(prefix + "length = struct.unpack_from('B', encoded, offset)[0]")
print(prefix + "offset += 1")
- print(prefix + "%s = encoded[offset:offset + length].decode('utf8')" % cLvalue)
+ print(prefix + "%s = encoded[offset:offset + length]" % cLvalue)
print(prefix + "try:")
print(prefix + " %s = str(%s)" % (cLvalue, cLvalue))
print(prefix + "except UnicodeEncodeError:")
@@ -99,7 +99,7 @@ def genSingleDecode(prefix, cLvalue, unresolved_domain):
elif type == 'longstr':
print(prefix + "length = struct.unpack_from('>I', encoded, offset)[0]")
print(prefix + "offset += 4")
- print(prefix + "%s = encoded[offset:offset + length].decode('utf8')" % cLvalue)
+ print(prefix + "%s = encoded[offset:offset + length]" % cLvalue)
print(prefix + "try:")
print(prefix + " %s = str(%s)" % (cLvalue, cLvalue))
print(prefix + "except UnicodeEncodeError:")
@@ -180,7 +180,7 @@ def genDecodeMethodFields(m):
bitindex = None
genSingleDecode(" ", "self.%s" % (pyize(f.name),), f.domain)
print(" return self")
- print()
+ print('')
def genDecodeProperties(c):
print(" def decode(self, encoded, offset=0):")
@@ -202,7 +202,7 @@ def genDecodeProperties(c):
print(" else:")
print(" self.%s = None" % (pyize(f.name),))
print(" return self")
- print()
+ print('')
def genEncodeMethodFields(m):
print(" def encode(self):")
@@ -231,7 +231,7 @@ def finishBits():
genSingleEncode(" ", "self.%s" % (pyize(f.name),), f.domain)
finishBits()
print(" return pieces")
- print()
+ print('')
def genEncodeProperties(c):
print(" def encode(self):")
@@ -255,7 +255,7 @@ def genEncodeProperties(c):
print(" if not flags:")
print(" break")
print(" return flag_pieces + pieces")
- print()
+ print('')
def fieldDeclList(fields):
return ''.join([", %s=%s" % (pyize(f.name), fieldvalue(f.defaultvalue)) for f in fields])
@@ -284,7 +284,7 @@ def fieldInitList(prefix, fields):
print("PROTOCOL_VERSION = (%d, %d, %d)" % (spec.major, spec.minor,
spec.revision))
print("PORT = %d" % spec.port)
- print()
+ print('')
# Append some constants that arent in the spec json file
spec.constants.append(('FRAME_MAX_SIZE', 131072, ''))
@@ -297,19 +297,19 @@ def fieldInitList(prefix, fields):
for key in sorted(constants.keys()):
print("%s = %s" % (key, constants[key]))
- print()
+ print('')
for c in spec.allClasses():
- print()
+ print('')
print('class %s(amqp_object.Class):' % (camel(c.name),))
- print()
+ print('')
print(" INDEX = 0x%.04X # %d" % (c.index, c.index))
print(" NAME = %s" % (fieldvalue(camel(c.name)),))
- print()
+ print('')
for m in c.allMethods():
print(' class %s(amqp_object.Method):' % (camel(m.name),))
- print()
+ print('')
methodid = m.klass.index << 16 | m.index
print(" INDEX = 0x%.08X # %d, %d; %d" % \
(methodid,
@@ -317,25 +317,25 @@ def fieldInitList(prefix, fields):
m.index,
methodid))
print(" NAME = %s" % (fieldvalue(m.structName(),)))
- print()
+ print('')
print(" def __init__(self%s):" % (fieldDeclList(m.arguments),))
print(fieldInitList(' ', m.arguments))
print(" @property")
print(" def synchronous(self):")
print(" return %s" % m.isSynchronous)
- print()
+ print('')
genDecodeMethodFields(m)
genEncodeMethodFields(m)
for c in spec.allClasses():
if c.fields:
- print()
+ print('')
print('class %s(amqp_object.Properties):' % (c.structName(),))
- print()
+ print('')
print(" CLASS = %s" % (camel(c.name),))
print(" INDEX = 0x%.04X # %d" % (c.index, c.index))
print(" NAME = %s" % (fieldvalue(c.structName(),)))
- print()
+ print('')
index = 0
if c.fields:
@@ -347,7 +347,7 @@ def fieldInitList(prefix, fields):
bitindex = shortnum * 16 + partialindex
print(' %s = (1 << %d)' % (flagName(None, f), bitindex))
index += 1
- print()
+ print('')
print(" def __init__(self%s):" % (fieldDeclList(c.fields),))
print(fieldInitList(' ', c.fields))
@@ -358,24 +358,24 @@ def fieldInitList(prefix, fields):
print(',\n'.join([" 0x%08X: %s" % (m.klass.index << 16 | m.index, m.structName()) \
for m in spec.allMethods()]))
print("}")
- print()
+ print('')
print("props = {")
print(',\n'.join([" 0x%04X: %s" % (c.index, c.structName()) \
for c in spec.allClasses() \
if c.fields]))
print("}")
- print()
- print()
+ print('')
+ print('')
print("def has_content(methodNumber):")
- print()
+ print('')
for m in spec.allMethods():
if m.hasContent:
print(' if methodNumber == %s.INDEX:' % m.structName())
print(' return True')
print(" return False")
- print()
+ print('')
if __name__ == "__main__":
with open(PIKA_SPEC, 'w') as handle:
Please sign in to comment.
Something went wrong with that request. Please try again.