Changed / to // for clarity.
parent
b589da51b7
commit
c97ec3048e
|
@ -698,12 +698,12 @@ class CCITTFaxDecoder(CCITTG4Parser):
|
|||
return self._buf
|
||||
|
||||
def output_line(self, y, bits):
|
||||
bytes = array.array('B', [0]*((len(bits)+7)/8))
|
||||
bytes = array.array('B', [0]*((len(bits)+7)//8))
|
||||
if self.reversed:
|
||||
bits = [1-b for b in bits]
|
||||
for (i, b) in enumerate(bits):
|
||||
if b:
|
||||
bytes[i/8] += (128, 64, 32, 16, 8, 4, 2, 1)[i % 8]
|
||||
bytes[i//8] += (128, 64, 32, 16, 8, 4, 2, 1)[i % 8]
|
||||
self._buf += bytes.tostring()
|
||||
return
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ class IdentityCMap(object):
|
|||
return self.vertical
|
||||
|
||||
def decode(self, code):
|
||||
n = len(code)/2
|
||||
n = len(code)//2
|
||||
if n:
|
||||
return struct.unpack('>%dH' % n, code)
|
||||
else:
|
||||
|
|
|
@ -7,7 +7,7 @@ from pdfcolor import LITERAL_DEVICE_GRAY, LITERAL_DEVICE_RGB, LITERAL_DEVICE_CMY
|
|||
|
||||
|
||||
def align32(x):
|
||||
return ((x+3)/4)*4
|
||||
return ((x+3)//4)*4
|
||||
|
||||
|
||||
## BMPWriter
|
||||
|
@ -27,7 +27,7 @@ class BMPWriter(object):
|
|||
ncols = 0
|
||||
else:
|
||||
raise ValueError(bits)
|
||||
self.linesize = align32((self.width*self.bits+7)/8)
|
||||
self.linesize = align32((self.width*self.bits+7)//8)
|
||||
self.datasize = self.linesize * self.height
|
||||
headersize = 14+40+ncols*4
|
||||
info = struct.pack('<IiiHHIIIIII', 40, self.width, self.height, 1, self.bits, 0, self.datasize, 0, 0, ncols, 0)
|
||||
|
@ -94,7 +94,7 @@ class ImageWriter(object):
|
|||
bmp = BMPWriter(fp, 1, width, height)
|
||||
data = stream.get_data()
|
||||
i = 0
|
||||
width = (width+7)/8
|
||||
width = (width+7)//8
|
||||
for y in xrange(height):
|
||||
bmp.write_line(y, data[i:i+width])
|
||||
i += width
|
||||
|
|
|
@ -215,7 +215,7 @@ class LTChar(LTComponent, LTText):
|
|||
width = font.get_width() * fontsize
|
||||
(vx, vy) = textdisp
|
||||
if vx is None:
|
||||
vx = width/2
|
||||
vx = width//2
|
||||
else:
|
||||
vx = vx * fontsize * .001
|
||||
vy = (1000 - vy) * fontsize * .001
|
||||
|
|
|
@ -190,7 +190,7 @@ class PDFXRefFallback(PDFXRef):
|
|||
objs.append(obj)
|
||||
except PSEOF:
|
||||
pass
|
||||
n = min(n, len(objs)/2)
|
||||
n = min(n, len(objs)//2)
|
||||
for index in xrange(n):
|
||||
objid1 = objs[index*2]
|
||||
self.offsets[objid1] = (objid, index, 0)
|
||||
|
@ -369,8 +369,8 @@ class PDFDocument(object):
|
|||
if 3 <= R:
|
||||
# 8
|
||||
for _ in xrange(50):
|
||||
hash = md5.md5(hash.digest()[:length/8])
|
||||
key = hash.digest()[:length/8]
|
||||
hash = md5.md5(hash.digest()[:length//8])
|
||||
key = hash.digest()[:length//8]
|
||||
if R == 2:
|
||||
# Algorithm 3.4
|
||||
u1 = Arcfour(key).process(self.PASSWORD_PADDING)
|
||||
|
|
|
@ -397,8 +397,8 @@ class TrueTypeFont(object):
|
|||
subheaderkeys = struct.unpack('>256H', fp.read(512))
|
||||
firstbytes = [0]*8192
|
||||
for (i, k) in enumerate(subheaderkeys):
|
||||
firstbytes[k/8] = i
|
||||
nhdrs = max(subheaderkeys)/8 + 1
|
||||
firstbytes[k//8] = i
|
||||
nhdrs = max(subheaderkeys)//8 + 1
|
||||
hdrs = []
|
||||
for i in xrange(nhdrs):
|
||||
(firstcode, entcount, delta, offset) = struct.unpack('>HHhH', fp.read(8))
|
||||
|
@ -415,7 +415,7 @@ class TrueTypeFont(object):
|
|||
char2gid[first+c] = gid
|
||||
elif fmttype == 4:
|
||||
(segcount, _1, _2, _3) = struct.unpack('>HHHH', fp.read(8))
|
||||
segcount /= 2
|
||||
segcount //= 2
|
||||
ecs = struct.unpack('>%dH' % segcount, fp.read(2*segcount))
|
||||
fp.read(2)
|
||||
scs = struct.unpack('>%dH' % segcount, fp.read(2*segcount))
|
||||
|
|
|
@ -14,15 +14,15 @@ import struct
|
|||
|
||||
|
||||
def KEYLENGTH(keybits):
|
||||
return (keybits)/8
|
||||
return (keybits)//8
|
||||
|
||||
|
||||
def RKLENGTH(keybits):
|
||||
return (keybits)/8+28
|
||||
return (keybits)//8+28
|
||||
|
||||
|
||||
def NROUNDS(keybits):
|
||||
return (keybits)/32+6
|
||||
return (keybits)//32+6
|
||||
|
||||
Te0 = [
|
||||
0xc66363a5L, 0xf87c7c84L, 0xee777799L, 0xf67b7b8dL,
|
||||
|
|
|
@ -12,7 +12,7 @@ def apply_png_predictor(pred, colors, columns, bitspercomponent, data):
|
|||
if bitspercomponent != 8:
|
||||
# unsupported
|
||||
raise ValueError(bitspercomponent)
|
||||
nbytes = colors*columns*bitspercomponent/8
|
||||
nbytes = colors*columns*bitspercomponent//8
|
||||
i = 0
|
||||
buf = ''
|
||||
line0 = '\x00' * columns
|
||||
|
@ -39,7 +39,7 @@ def apply_png_predictor(pred, colors, columns, bitspercomponent, data):
|
|||
# PNG average (UNTESTED)
|
||||
c = 0
|
||||
for (a, b) in zip(line0, line1):
|
||||
c = ((c+ord(a)+ord(b))/2) & 255
|
||||
c = ((c+ord(a)+ord(b))//2) & 255
|
||||
buf += chr(c)
|
||||
else:
|
||||
# unsupported
|
||||
|
@ -114,7 +114,7 @@ def fsplit(pred, objs):
|
|||
def drange(v0, v1, d):
|
||||
"""Returns a discrete range."""
|
||||
assert v0 < v1
|
||||
return xrange(int(v0)/d, int(v1+d)/d)
|
||||
return xrange(int(v0)//d, int(v1+d)//d)
|
||||
|
||||
|
||||
# get_bound
|
||||
|
|
Loading…
Reference in New Issue