def _load_bytecode_from_dump(input):
# Read the data.
data = input.read()
# If it's an hexadecimal dump, decode and return it.
if _re_is_hexa.match(data):
hexstr = ''.join(_re_get_hexa.findall(data))
hexdump = [ int(hexstr[i:i+2], 16) for i in xrange(0, len(hexstr), 2) ]
return struct.pack('B' * len(hexdump), *hexdump)
# If it's base64 encoded data, decode and return it.
if _re_is_b64.match(data):
return data.decode('base64')
# Assume it's a raw binary dump and return it unchanged.
return data
#-----------------------------------------------------------------------------#
评论列表
文章目录