Skip to content

Commit 8fa0121

Browse files
authored
Merge pull request #3 from jaicis/py3convert
python forward porting
2 parents fad7f3a + 95990d8 commit 8fa0121

57 files changed

Lines changed: 355 additions & 448 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/addresses.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def encodeAddress(version, stream, ripe):
158158
raise Exception(
159159
'Programming error in encodeAddress: The length of'
160160
' a given ripe hash was not 20.')
161-
ripe = ripe.lstrip('\x00')
161+
ripe = ripe.lstrip('\x00'.encode('utf-8'))
162162

163163
storedBinaryData = encodeVarint(version) + encodeVarint(stream) + ripe
164164

@@ -180,7 +180,6 @@ def decodeAddress(address):
180180
data (almost certainly a ripe hash))
181181
"""
182182
# pylint: disable=too-many-return-statements,too-many-statements,too-many-return-statements,too-many-branches
183-
184183
address = str(address).strip()
185184

186185
if address[:3] == 'BM-':
@@ -192,7 +191,7 @@ def decodeAddress(address):
192191
return status, 0, 0, ''
193192
# after converting to hex, the string will be prepended
194193
# with a 0x and appended with a L
195-
hexdata = hex(integer)[2:-1]
194+
hexdata = hex(integer)[2:]
196195

197196
if len(hexdata) % 2 != 0:
198197
hexdata = '0' + hexdata
@@ -248,7 +247,7 @@ def decodeAddress(address):
248247
embeddedRipeData
249248
elif len(embeddedRipeData) == 18:
250249
return status, addressVersionNumber, streamNumber, \
251-
'\x00\x00' + embeddedRipeData
250+
'\x00\x00'.encode('utf-8') + embeddedRipeData
252251
elif len(embeddedRipeData) < 18:
253252
return 'ripetooshort', 0, 0, ''
254253
elif len(embeddedRipeData) > 20:
@@ -265,7 +264,8 @@ def decodeAddress(address):
265264
return 'ripetoolong', 0, 0, ''
266265
elif len(embeddedRipeData) < 4:
267266
return 'ripetooshort', 0, 0, ''
268-
x00string = '\x00' * (20 - len(embeddedRipeData))
267+
x00string = '\x00'.encode('utf-8') * (20 - len(embeddedRipeData))
268+
269269
return status, addressVersionNumber, streamNumber, \
270270
x00string + embeddedRipeData
271271

src/bitmessagekivy/identiconGeneration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def generate_hash(string):
4646
# make input case insensitive
4747
string = str.lower(string)
4848
hash_object = hashlib.md5(str.encode(string))
49-
print hash_object.hexdigest()
49+
print(hash_object.hexdigest())
5050

5151
# returned object is a hex string
5252
return hash_object.hexdigest()
5353

5454
except IndexError:
55-
print "Error: Please enter a string as an argument."
55+
print("Error: Please enter a string as an argument.")
5656

5757

5858
def random_color(hash_string):

0 commit comments

Comments
 (0)