mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-03 10:00:12 -05:00
Fix Python 2 vs 3 breakage relating to hex().
In Python 2, hex() of large ints has a "L" on the end.
This commit is contained in:
parent
3f3fe3bb67
commit
5390c45e04
@ -44,11 +44,11 @@ f = open(args.input_file_path, 'r')
|
||||
namespaces, variable_name = crack_variable_path(args.variable_path)
|
||||
|
||||
def to_hex(value, length_bits):
|
||||
return hex(value)[2:].zfill((length_bits + 3) >> 2)
|
||||
return ('%x' % value).zfill((length_bits + 3) >> 2)
|
||||
|
||||
def long_int_to_bytes(n, bit_count):
|
||||
byte_count = (bit_count + 7) >> 3
|
||||
h = hex(n)[2:].zfill(byte_count * 2)
|
||||
h = ('%x' % n).zfill(byte_count * 2)
|
||||
return [int(h[n:n+2], 16) for n in range(0, len(h), 2)]
|
||||
|
||||
re_sdr = re.compile(r'^(?P<length>\d+)\s*TDI\s*\((?P<tdi>[0-9A-F]+)\)(|\s*SMASK\s*\((?P<smask>[0-9A-F]+)\))(|\s*TDO\s*\((?P<tdo>[0-9A-F]+)\))(|\s*MASK\s*\((?P<mask>[0-9A-F]+)\))\s*;$')
|
||||
|
Loading…
x
Reference in New Issue
Block a user