Kivy Mock added
0
src/tests/mock/__init__.py
Normal file
38
src/tests/mock/bitmessagemock.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
"""
|
||||
Bitmessage mock
|
||||
"""
|
||||
from pybitmessage.class_addressGenerator import addressGenerator
|
||||
from pybitmessage.inventory import Inventory
|
||||
from pybitmessage.bmconfigparser import BMConfigParser
|
||||
from pybitmessage import state
|
||||
|
||||
|
||||
class MockMain:
|
||||
"""Mock main function"""
|
||||
|
||||
def start(self):
|
||||
"""Start main application"""
|
||||
# pylint: disable=too-many-statements,too-many-branches,too-many-locals, unused-variable
|
||||
config = BMConfigParser()
|
||||
daemon = config.safeGetBoolean('bitmessagesettings', 'daemon')
|
||||
# Start the address generation thread
|
||||
addressGeneratorThread = addressGenerator()
|
||||
# close the main program even if there are threads left
|
||||
addressGeneratorThread.daemon = True
|
||||
addressGeneratorThread.start()
|
||||
Inventory()
|
||||
from pybitmessage.mpybit import NavigateApp
|
||||
state.kivyapp = NavigateApp()
|
||||
state.kivyapp.run()
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
"""Triggers main module"""
|
||||
mainprogram = MockMain()
|
||||
mainprogram.start()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
BIN
src/tests/mock/images/kivy/3.zip
Normal file
BIN
src/tests/mock/images/kivy/account_multiple.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
src/tests/mock/images/kivy/addressbook.png
Normal file
After Width: | Height: | Size: 673 B |
BIN
src/tests/mock/images/kivy/addressbookadd.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/tests/mock/images/kivy/avatar.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
src/tests/mock/images/kivy/back-button.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
src/tests/mock/images/kivy/bitmessage.icns
Normal file
BIN
src/tests/mock/images/kivy/black_cross.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
src/tests/mock/images/kivy/blacklist.png
Normal file
After Width: | Height: | Size: 752 B |
BIN
src/tests/mock/images/kivy/blue-plus-icon-12.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
src/tests/mock/images/kivy/can-icon-16px.png
Normal file
After Width: | Height: | Size: 1007 B |
BIN
src/tests/mock/images/kivy/can-icon-24px-green.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
src/tests/mock/images/kivy/can-icon-24px-red.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
src/tests/mock/images/kivy/can-icon-24px-yellow.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
src/tests/mock/images/kivy/can-icon-24px.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
src/tests/mock/images/kivy/can-icon.ico
Normal file
After Width: | Height: | Size: 97 KiB |
BIN
src/tests/mock/images/kivy/copy_text.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
src/tests/mock/images/kivy/down-arrow.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
src/tests/mock/images/kivy/drawer_logo1.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
src/tests/mock/images/kivy/greenicon.png
Normal file
After Width: | Height: | Size: 820 B |
BIN
src/tests/mock/images/kivy/identities.png
Normal file
After Width: | Height: | Size: 870 B |
BIN
src/tests/mock/images/kivy/inbox.png
Normal file
After Width: | Height: | Size: 687 B |
BIN
src/tests/mock/images/kivy/kivymd_logo.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
src/tests/mock/images/kivy/left_arrow.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
src/tests/mock/images/kivy/loader.gif
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
src/tests/mock/images/kivy/loader.zip
Normal file
BIN
src/tests/mock/images/kivy/me.jpg
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
src/tests/mock/images/kivy/networkstatus.png
Normal file
After Width: | Height: | Size: 629 B |
BIN
src/tests/mock/images/kivy/no_identicons.png
Normal file
After Width: | Height: | Size: 197 B |
BIN
src/tests/mock/images/kivy/payment/btc.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
src/tests/mock/images/kivy/payment/buy.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
src/tests/mock/images/kivy/payment/buynew.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
src/tests/mock/images/kivy/payment/buynew1.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
src/tests/mock/images/kivy/payment/credits.jpeg
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
src/tests/mock/images/kivy/payment/creditss.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
src/tests/mock/images/kivy/payment/gpay.png
Normal file
After Width: | Height: | Size: 101 KiB |
BIN
src/tests/mock/images/kivy/payment/gplay.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
src/tests/mock/images/kivy/payment/gplayfinal.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
src/tests/mock/images/kivy/payment/gplayss.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
src/tests/mock/images/kivy/payment/paypal.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
src/tests/mock/images/kivy/plus-4-xxl.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/tests/mock/images/kivy/plus.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
src/tests/mock/images/kivy/qidenticon.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
src/tests/mock/images/kivy/qidenticon_two.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
src/tests/mock/images/kivy/qidenticon_two_x.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
src/tests/mock/images/kivy/qidenticon_x.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
src/tests/mock/images/kivy/red.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
src/tests/mock/images/kivy/redicon.png
Normal file
After Width: | Height: | Size: 716 B |
BIN
src/tests/mock/images/kivy/right-arrow.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
src/tests/mock/images/kivy/search.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
src/tests/mock/images/kivy/search_mail.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/tests/mock/images/kivy/send.png
Normal file
After Width: | Height: | Size: 823 B |
BIN
src/tests/mock/images/kivy/sent.png
Normal file
After Width: | Height: | Size: 548 B |
BIN
src/tests/mock/images/kivy/subscriptions.png
Normal file
After Width: | Height: | Size: 631 B |
BIN
src/tests/mock/images/kivy/text_images/!.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/tests/mock/images/kivy/text_images/0.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
src/tests/mock/images/kivy/text_images/1.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/tests/mock/images/kivy/text_images/2.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
src/tests/mock/images/kivy/text_images/3.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
src/tests/mock/images/kivy/text_images/4.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
src/tests/mock/images/kivy/text_images/5.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
src/tests/mock/images/kivy/text_images/6.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
src/tests/mock/images/kivy/text_images/7.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
src/tests/mock/images/kivy/text_images/8.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/tests/mock/images/kivy/text_images/9.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/tests/mock/images/kivy/text_images/A.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
src/tests/mock/images/kivy/text_images/B.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
src/tests/mock/images/kivy/text_images/C.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
src/tests/mock/images/kivy/text_images/D.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
src/tests/mock/images/kivy/text_images/E.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/tests/mock/images/kivy/text_images/F.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/tests/mock/images/kivy/text_images/G.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
src/tests/mock/images/kivy/text_images/H.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/tests/mock/images/kivy/text_images/I.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
src/tests/mock/images/kivy/text_images/J.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
src/tests/mock/images/kivy/text_images/K.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
src/tests/mock/images/kivy/text_images/L.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
src/tests/mock/images/kivy/text_images/M.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
src/tests/mock/images/kivy/text_images/N.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
src/tests/mock/images/kivy/text_images/O.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
src/tests/mock/images/kivy/text_images/P.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
src/tests/mock/images/kivy/text_images/Q.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
src/tests/mock/images/kivy/text_images/R.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
src/tests/mock/images/kivy/text_images/S.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/tests/mock/images/kivy/text_images/T.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/tests/mock/images/kivy/text_images/U.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
src/tests/mock/images/kivy/text_images/V.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
src/tests/mock/images/kivy/text_images/W.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/tests/mock/images/kivy/text_images/X.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
src/tests/mock/images/kivy/text_images/Y.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
src/tests/mock/images/kivy/text_images/Z.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
src/tests/mock/images/kivy/transparent.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
src/tests/mock/images/kivy/white.png
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
src/tests/mock/images/kivy/yellowicon.png
Normal file
After Width: | Height: | Size: 634 B |
8
src/tests/mock/kivy_main.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
"""Mock kivy app with mock threads."""
|
||||
from pybitmessage import state
|
||||
|
||||
if __name__ == '__main__':
|
||||
state.kivy = True
|
||||
print("Kivy Loading......")
|
||||
from bitmessagemock import main
|
||||
main()
|
0
src/tests/mock/pybitmessage/__init__.py
Normal file
278
src/tests/mock/pybitmessage/addresses.py
Normal file
|
@ -0,0 +1,278 @@
|
|||
"""
|
||||
Operations with addresses
|
||||
"""
|
||||
# pylint: disable=redefined-outer-name,inconsistent-return-statements
|
||||
import hashlib
|
||||
from binascii import hexlify, unhexlify
|
||||
from struct import pack, unpack
|
||||
|
||||
# from debug import logger
|
||||
|
||||
ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
||||
|
||||
|
||||
def encodeBase58(num, alphabet=ALPHABET):
|
||||
"""Encode a number in Base X
|
||||
|
||||
Args:
|
||||
num: The number to encode
|
||||
alphabet: The alphabet to use for encoding
|
||||
"""
|
||||
if num == 0:
|
||||
return alphabet[0]
|
||||
arr = []
|
||||
base = len(alphabet)
|
||||
while num:
|
||||
rem = num % base
|
||||
num = num // base
|
||||
arr.append(alphabet[rem])
|
||||
arr.reverse()
|
||||
return ''.join(arr)
|
||||
|
||||
|
||||
def decodeBase58(string, alphabet=ALPHABET):
|
||||
"""Decode a Base X encoded string into the number
|
||||
|
||||
Args:
|
||||
string: The encoded string
|
||||
alphabet: The alphabet to use for encoding
|
||||
"""
|
||||
base = len(alphabet)
|
||||
num = 0
|
||||
|
||||
try:
|
||||
for char in string:
|
||||
num *= base
|
||||
num += alphabet.index(char)
|
||||
# ValueError
|
||||
except:
|
||||
# character not found (like a space character or a 0)
|
||||
return 0
|
||||
return num
|
||||
|
||||
|
||||
class varintEncodeError(Exception):
|
||||
"""Exception class for encoding varint"""
|
||||
pass
|
||||
|
||||
|
||||
class varintDecodeError(Exception):
|
||||
"""Exception class for decoding varint data"""
|
||||
pass
|
||||
|
||||
|
||||
def encodeVarint(integer):
|
||||
"""Convert integer into varint bytes"""
|
||||
if integer < 0:
|
||||
raise varintEncodeError('varint cannot be < 0')
|
||||
if integer < 253:
|
||||
return pack('>B', integer)
|
||||
if integer >= 253 and integer < 65536:
|
||||
return pack('>B', 253) + pack('>H', integer)
|
||||
if integer >= 65536 and integer < 4294967296:
|
||||
return pack('>B', 254) + pack('>I', integer)
|
||||
if integer >= 4294967296 and integer < 18446744073709551616:
|
||||
return pack('>B', 255) + pack('>Q', integer)
|
||||
if integer >= 18446744073709551616:
|
||||
raise varintEncodeError('varint cannot be >= 18446744073709551616')
|
||||
|
||||
|
||||
def decodeVarint(data):
|
||||
"""
|
||||
Decodes an encoded varint to an integer and returns it.
|
||||
Per protocol v3, the encoded value must be encoded with
|
||||
the minimum amount of data possible or else it is malformed.
|
||||
Returns a tuple: (theEncodedValue, theSizeOfTheVarintInBytes)
|
||||
"""
|
||||
if not data:
|
||||
return (0, 0)
|
||||
firstByte, = unpack('>B', data[0:1])
|
||||
if firstByte < 253:
|
||||
# encodes 0 to 252
|
||||
# the 1 is the length of the varint
|
||||
return (firstByte, 1)
|
||||
if firstByte == 253:
|
||||
# encodes 253 to 65535
|
||||
if len(data) < 3:
|
||||
raise varintDecodeError(
|
||||
'The first byte of this varint as an integer is %s'
|
||||
' but the total length is only %s. It needs to be'
|
||||
' at least 3.' % (firstByte, len(data)))
|
||||
encodedValue, = unpack('>H', data[1:3])
|
||||
if encodedValue < 253:
|
||||
raise varintDecodeError(
|
||||
'This varint does not encode the value with the lowest'
|
||||
' possible number of bytes.')
|
||||
return (encodedValue, 3)
|
||||
if firstByte == 254:
|
||||
# encodes 65536 to 4294967295
|
||||
if len(data) < 5:
|
||||
raise varintDecodeError(
|
||||
'The first byte of this varint as an integer is %s'
|
||||
' but the total length is only %s. It needs to be'
|
||||
' at least 5.' % (firstByte, len(data)))
|
||||
encodedValue, = unpack('>I', data[1:5])
|
||||
if encodedValue < 65536:
|
||||
raise varintDecodeError(
|
||||
'This varint does not encode the value with the lowest'
|
||||
' possible number of bytes.')
|
||||
return (encodedValue, 5)
|
||||
if firstByte == 255:
|
||||
# encodes 4294967296 to 18446744073709551615
|
||||
if len(data) < 9:
|
||||
raise varintDecodeError(
|
||||
'The first byte of this varint as an integer is %s'
|
||||
' but the total length is only %s. It needs to be'
|
||||
' at least 9.' % (firstByte, len(data)))
|
||||
encodedValue, = unpack('>Q', data[1:9])
|
||||
if encodedValue < 4294967296:
|
||||
raise varintDecodeError(
|
||||
'This varint does not encode the value with the lowest'
|
||||
' possible number of bytes.')
|
||||
return (encodedValue, 9)
|
||||
|
||||
|
||||
def calculateInventoryHash(data):
|
||||
"""Calculate inventory hash from object data"""
|
||||
sha = hashlib.new('sha512')
|
||||
sha2 = hashlib.new('sha512')
|
||||
sha.update(data)
|
||||
sha2.update(sha.digest())
|
||||
return sha2.digest()[0:32]
|
||||
|
||||
|
||||
def encodeAddress(version, stream, ripe):
|
||||
"""Convert ripe to address"""
|
||||
if version >= 2 and version < 4:
|
||||
if len(ripe) != 20:
|
||||
raise Exception(
|
||||
'Programming error in encodeAddress: The length of'
|
||||
' a given ripe hash was not 20.'
|
||||
)
|
||||
if ripe[:2] == '\x00\x00':
|
||||
ripe = ripe[2:]
|
||||
elif ripe[:1] == '\x00':
|
||||
ripe = ripe[1:]
|
||||
elif version == 4:
|
||||
if len(ripe) != 20:
|
||||
raise Exception(
|
||||
'Programming error in encodeAddress: The length of'
|
||||
' a given ripe hash was not 20.')
|
||||
ripe = ripe.lstrip('\x00'.encode('utf-8'))
|
||||
|
||||
storedBinaryData = encodeVarint(version) + encodeVarint(stream) + ripe
|
||||
|
||||
# Generate the checksum
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(storedBinaryData)
|
||||
currentHash = sha.digest()
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(currentHash)
|
||||
checksum = sha.digest()[0:4]
|
||||
|
||||
asInt = int(hexlify(storedBinaryData) + hexlify(checksum), 16)
|
||||
return 'BM-' + encodeBase58(asInt)
|
||||
|
||||
|
||||
def decodeAddress(address):
|
||||
"""
|
||||
returns (status, address version number, stream number,
|
||||
data (almost certainly a ripe hash))
|
||||
"""
|
||||
# pylint: disable=too-many-return-statements,too-many-statements
|
||||
# pylint: disable=too-many-branches
|
||||
address = str(address).strip()
|
||||
|
||||
if address[:3] == 'BM-':
|
||||
integer = decodeBase58(address[3:])
|
||||
else:
|
||||
integer = decodeBase58(address)
|
||||
if integer == 0:
|
||||
status = 'invalidcharacters'
|
||||
return status, 0, 0, ''
|
||||
# after converting to hex, the string will be prepended
|
||||
# with a 0x and appended with a L
|
||||
hexdata = hex(integer)[2:]
|
||||
|
||||
if len(hexdata) % 2 != 0:
|
||||
hexdata = '0' + hexdata
|
||||
|
||||
data = unhexlify(hexdata)
|
||||
checksum = data[-4:]
|
||||
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(data[:-4])
|
||||
currentHash = sha.digest()
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(currentHash)
|
||||
|
||||
if checksum != sha.digest()[0:4]:
|
||||
status = 'checksumfailed'
|
||||
return status, 0, 0, ''
|
||||
|
||||
try:
|
||||
addressVersionNumber, bytesUsedByVersionNumber = decodeVarint(data[:9])
|
||||
except varintDecodeError as e:
|
||||
# logger.error(str(e))
|
||||
status = 'varintmalformed'
|
||||
return status, 0, 0, ''
|
||||
|
||||
if addressVersionNumber > 4:
|
||||
# logger.error('cannot decode address version numbers this high')
|
||||
status = 'versiontoohigh'
|
||||
return status, 0, 0, ''
|
||||
elif addressVersionNumber == 0:
|
||||
# logger.error('cannot decode address version numbers of zero.')
|
||||
status = 'versiontoohigh'
|
||||
return status, 0, 0, ''
|
||||
|
||||
try:
|
||||
streamNumber, bytesUsedByStreamNumber = \
|
||||
decodeVarint(data[bytesUsedByVersionNumber:])
|
||||
except varintDecodeError as e:
|
||||
# logger.error(str(e))
|
||||
status = 'varintmalformed'
|
||||
return status, 0, 0, ''
|
||||
|
||||
status = 'success'
|
||||
if addressVersionNumber == 1:
|
||||
return status, addressVersionNumber, streamNumber, data[-24:-4]
|
||||
# elif addressVersionNumber == 2 or addressVersionNumber == 3:
|
||||
elif addressVersionNumber in (2, 3):
|
||||
embeddedRipeData = \
|
||||
data[bytesUsedByVersionNumber + bytesUsedByStreamNumber:-4]
|
||||
if len(embeddedRipeData) == 19:
|
||||
return status, addressVersionNumber, streamNumber, \
|
||||
'\x00' + embeddedRipeData
|
||||
elif len(embeddedRipeData) == 20:
|
||||
return status, addressVersionNumber, streamNumber, \
|
||||
embeddedRipeData
|
||||
elif len(embeddedRipeData) == 18:
|
||||
return status, addressVersionNumber, streamNumber, \
|
||||
'\x00\x00'.encode('utf-8') + embeddedRipeData
|
||||
elif len(embeddedRipeData) < 18:
|
||||
return 'ripetooshort', 0, 0, ''
|
||||
elif len(embeddedRipeData) > 20:
|
||||
return 'ripetoolong', 0, 0, ''
|
||||
return 'otherproblem', 0, 0, ''
|
||||
elif addressVersionNumber == 4:
|
||||
embeddedRipeData = \
|
||||
data[bytesUsedByVersionNumber + bytesUsedByStreamNumber:-4]
|
||||
if embeddedRipeData[0:1] == '\x00':
|
||||
# In order to enforce address non-malleability, encoded
|
||||
# RIPE data must have NULL bytes removed from the front
|
||||
return 'encodingproblem', 0, 0, ''
|
||||
elif len(embeddedRipeData) > 20:
|
||||
return 'ripetoolong', 0, 0, ''
|
||||
elif len(embeddedRipeData) < 4:
|
||||
return 'ripetooshort', 0, 0, ''
|
||||
x00string = '\x00'.encode('utf-8') * (20 - len(embeddedRipeData))
|
||||
|
||||
return status, addressVersionNumber, streamNumber, \
|
||||
x00string + embeddedRipeData
|
||||
|
||||
|
||||
def addBMIfNotPresent(address):
|
||||
"""Prepend BM- to an address if it doesn't already have it"""
|
||||
address = str(address).strip()
|
||||
return address if address[:3] == 'BM-' else 'BM-' + address
|