Fixes for other python versions.

This commit is contained in:
Steve Pulec 2014-11-26 21:04:44 -05:00
parent 57d45aa4b8
commit c63b00b8ba
2 changed files with 6 additions and 6 deletions

View File

@ -56,7 +56,7 @@ class Shard(object):
return sequence_number
def get_max_sequence_number(self):
return self.records.keys()[-1]
return list(self.records.keys())[-1]
def to_json(self):
return {
@ -81,7 +81,7 @@ class Stream(object):
self.shards = {}
for index in range(shard_count):
shard_id = "shardId-{}".format(str(index).zfill(12))
shard_id = "shardId-{0}".format(str(index).zfill(12))
self.shards[shard_id] = Shard(shard_id)
@property
@ -100,7 +100,7 @@ class Stream(object):
def get_shard_for_key(self, partition_key):
# TODO implement sharding
shard = self.shards.values()[0]
shard = list(self.shards.values())[0]
return shard
def put_record(self, partition_key, explicit_hash_key, sequence_number_for_ordering, data):

View File

@ -23,9 +23,9 @@ def compose_shard_iterator(stream_name, shard, last_sequence_id):
stream_name,
shard.shard_id,
last_sequence_id,
)
)
).encode("utf-8")
).decode("utf-8")
def decompose_shard_iterator(shard_iterator):
return base64.decodestring(shard_iterator).split(":")
return base64.decodestring(shard_iterator.encode("utf-8")).decode("utf-8").split(":")