Skip to content

Commit 44be5f6

Browse files
committed
Add back patch to RKbug.py
* Ah ... this file has CRLF line terminators ;)
1 parent 2a78ad9 commit 44be5f6

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

tests/RKbug.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
from xlwt import *
1+
from __future__ import print_function
2+
from __future__ import absolute_import
3+
from __future__ import division
4+
25
import sys
36
from struct import pack, unpack
47

8+
from future import *
9+
10+
from xlwt import *
11+
12+
513
def cellname(rowx, colx):
614
# quick kludge, works up to 26 cols :-)
715
return chr(ord('A') + colx) + str(rowx + 1)
816

917
def RK_pack_check(num, anint, case=None):
1018
if not(-0x7fffffff - 1 <= anint <= 0x7fffffff):
11-
print "RK_pack_check: not a signed 32-bit int: %r (%r); case: %r" \
12-
% (anint, hex(anint), case)
19+
print("RK_pack_check: not a signed 32-bit int: %r (%r); case: %r" \
20+
% (anint, hex(anint), case))
1321
pstr = pack("<i", anint)
1422
actual = unpack_RK(pstr)
1523
if actual != num:
16-
print "RK_pack_check: round trip failure: %r (%r); case %r; %r in, %r out" \
17-
% (anint, hex(anint), case, num, actual)
24+
print("RK_pack_check: round trip failure: %r (%r); case %r; %r in, %r out" \
25+
% (anint, hex(anint), case, num, actual))
1826

1927

2028
def RK_encode(num, blah=0):
@@ -25,22 +33,22 @@ def RK_encode(num, blah=0):
2533
rk_encoded = 0
2634
packed = pack('<d', num)
2735

28-
if blah: print
29-
if blah: print repr(num)
36+
if blah: print()
37+
if blah: print(repr(num))
3038
w01, w23 = unpack('<2i', packed)
3139
if not w01 and not(w23 & 3):
3240
# 34 lsb are 0
33-
if blah: print "float RK", w23, hex(w23)
41+
if blah: print("float RK", w23, hex(w23))
3442
return RK_pack_check(num, w23, 0)
3543
# return RKRecord(
3644
# self.__parent.get_index(), self.__idx, self.__xf_idx, w23).get()
3745

3846
if -0x20000000 <= num < 0x20000000:
3947
inum = int(num)
4048
if inum == num:
41-
if blah: print "30-bit integer RK", inum, hex(inum)
49+
if blah: print("30-bit integer RK", inum, hex(inum))
4250
rk_encoded = 2 | (inum << 2)
43-
if blah: print "rk", rk_encoded, hex(rk_encoded)
51+
if blah: print("rk", rk_encoded, hex(rk_encoded))
4452
return RK_pack_check(num, rk_encoded, 2)
4553
# return RKRecord(
4654
# self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
@@ -50,22 +58,22 @@ def RK_encode(num, blah=0):
5058
w01, w23 = unpack('<2i', packed100)
5159
if not w01 and not(w23 & 3):
5260
# 34 lsb are 0
53-
if blah: print "float RK*100", w23, hex(w23)
61+
if blah: print("float RK*100", w23, hex(w23))
5462
return RK_pack_check(num, w23 | 1, 1)
5563
# return RKRecord(
5664
# self.__parent.get_index(), self.__idx, self.__xf_idx, w23 | 1).get()
5765

5866
if -0x20000000 <= temp < 0x20000000:
5967
itemp = int(round(temp, 0))
60-
if blah: print (itemp == temp), (itemp / 100.0 == num)
68+
if blah: print((itemp == temp), (itemp / 100.0 == num))
6169
if itemp / 100.0 == num:
62-
if blah: print "30-bit integer RK*100", itemp, hex(itemp)
70+
if blah: print("30-bit integer RK*100", itemp, hex(itemp))
6371
rk_encoded = 3 | (itemp << 2)
6472
return RK_pack_check(num, rk_encoded, 3)
6573
# return RKRecord(
6674
# self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
6775

68-
if blah: print "Number"
76+
if blah: print("Number")
6977
# return NumberRecord(
7078
# self.__parent.get_index(), self.__idx, self.__xf_idx, num).get()
7179

0 commit comments

Comments
 (0)