Changed / to // for clarity.

pull/1/head
Yusuke Shinyama 2013-11-26 21:35:16 +09:00
parent b589da51b7
commit c97ec3048e
8 changed files with 19 additions and 19 deletions

View File

@ -698,12 +698,12 @@ class CCITTFaxDecoder(CCITTG4Parser):
return self._buf return self._buf
def output_line(self, y, bits): 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: if self.reversed:
bits = [1-b for b in bits] bits = [1-b for b in bits]
for (i, b) in enumerate(bits): for (i, b) in enumerate(bits):
if b: 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() self._buf += bytes.tostring()
return return

View File

@ -96,7 +96,7 @@ class IdentityCMap(object):
return self.vertical return self.vertical
def decode(self, code): def decode(self, code):
n = len(code)/2 n = len(code)//2
if n: if n:
return struct.unpack('>%dH' % n, code) return struct.unpack('>%dH' % n, code)
else: else:

View File

@ -7,7 +7,7 @@ from pdfcolor import LITERAL_DEVICE_GRAY, LITERAL_DEVICE_RGB, LITERAL_DEVICE_CMY
def align32(x): def align32(x):
return ((x+3)/4)*4 return ((x+3)//4)*4
## BMPWriter ## BMPWriter
@ -27,7 +27,7 @@ class BMPWriter(object):
ncols = 0 ncols = 0
else: else:
raise ValueError(bits) 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 self.datasize = self.linesize * self.height
headersize = 14+40+ncols*4 headersize = 14+40+ncols*4
info = struct.pack('<IiiHHIIIIII', 40, self.width, self.height, 1, self.bits, 0, self.datasize, 0, 0, ncols, 0) 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) bmp = BMPWriter(fp, 1, width, height)
data = stream.get_data() data = stream.get_data()
i = 0 i = 0
width = (width+7)/8 width = (width+7)//8
for y in xrange(height): for y in xrange(height):
bmp.write_line(y, data[i:i+width]) bmp.write_line(y, data[i:i+width])
i += width i += width

View File

@ -215,7 +215,7 @@ class LTChar(LTComponent, LTText):
width = font.get_width() * fontsize width = font.get_width() * fontsize
(vx, vy) = textdisp (vx, vy) = textdisp
if vx is None: if vx is None:
vx = width/2 vx = width//2
else: else:
vx = vx * fontsize * .001 vx = vx * fontsize * .001
vy = (1000 - vy) * fontsize * .001 vy = (1000 - vy) * fontsize * .001

View File

@ -190,7 +190,7 @@ class PDFXRefFallback(PDFXRef):
objs.append(obj) objs.append(obj)
except PSEOF: except PSEOF:
pass pass
n = min(n, len(objs)/2) n = min(n, len(objs)//2)
for index in xrange(n): for index in xrange(n):
objid1 = objs[index*2] objid1 = objs[index*2]
self.offsets[objid1] = (objid, index, 0) self.offsets[objid1] = (objid, index, 0)
@ -369,8 +369,8 @@ class PDFDocument(object):
if 3 <= R: if 3 <= R:
# 8 # 8
for _ in xrange(50): for _ in xrange(50):
hash = md5.md5(hash.digest()[:length/8]) hash = md5.md5(hash.digest()[:length//8])
key = hash.digest()[:length/8] key = hash.digest()[:length//8]
if R == 2: if R == 2:
# Algorithm 3.4 # Algorithm 3.4
u1 = Arcfour(key).process(self.PASSWORD_PADDING) u1 = Arcfour(key).process(self.PASSWORD_PADDING)

View File

@ -397,8 +397,8 @@ class TrueTypeFont(object):
subheaderkeys = struct.unpack('>256H', fp.read(512)) subheaderkeys = struct.unpack('>256H', fp.read(512))
firstbytes = [0]*8192 firstbytes = [0]*8192
for (i, k) in enumerate(subheaderkeys): for (i, k) in enumerate(subheaderkeys):
firstbytes[k/8] = i firstbytes[k//8] = i
nhdrs = max(subheaderkeys)/8 + 1 nhdrs = max(subheaderkeys)//8 + 1
hdrs = [] hdrs = []
for i in xrange(nhdrs): for i in xrange(nhdrs):
(firstcode, entcount, delta, offset) = struct.unpack('>HHhH', fp.read(8)) (firstcode, entcount, delta, offset) = struct.unpack('>HHhH', fp.read(8))
@ -415,7 +415,7 @@ class TrueTypeFont(object):
char2gid[first+c] = gid char2gid[first+c] = gid
elif fmttype == 4: elif fmttype == 4:
(segcount, _1, _2, _3) = struct.unpack('>HHHH', fp.read(8)) (segcount, _1, _2, _3) = struct.unpack('>HHHH', fp.read(8))
segcount /= 2 segcount //= 2
ecs = struct.unpack('>%dH' % segcount, fp.read(2*segcount)) ecs = struct.unpack('>%dH' % segcount, fp.read(2*segcount))
fp.read(2) fp.read(2)
scs = struct.unpack('>%dH' % segcount, fp.read(2*segcount)) scs = struct.unpack('>%dH' % segcount, fp.read(2*segcount))

View File

@ -14,15 +14,15 @@ import struct
def KEYLENGTH(keybits): def KEYLENGTH(keybits):
return (keybits)/8 return (keybits)//8
def RKLENGTH(keybits): def RKLENGTH(keybits):
return (keybits)/8+28 return (keybits)//8+28
def NROUNDS(keybits): def NROUNDS(keybits):
return (keybits)/32+6 return (keybits)//32+6
Te0 = [ Te0 = [
0xc66363a5L, 0xf87c7c84L, 0xee777799L, 0xf67b7b8dL, 0xc66363a5L, 0xf87c7c84L, 0xee777799L, 0xf67b7b8dL,

View File

@ -12,7 +12,7 @@ def apply_png_predictor(pred, colors, columns, bitspercomponent, data):
if bitspercomponent != 8: if bitspercomponent != 8:
# unsupported # unsupported
raise ValueError(bitspercomponent) raise ValueError(bitspercomponent)
nbytes = colors*columns*bitspercomponent/8 nbytes = colors*columns*bitspercomponent//8
i = 0 i = 0
buf = '' buf = ''
line0 = '\x00' * columns line0 = '\x00' * columns
@ -39,7 +39,7 @@ def apply_png_predictor(pred, colors, columns, bitspercomponent, data):
# PNG average (UNTESTED) # PNG average (UNTESTED)
c = 0 c = 0
for (a, b) in zip(line0, line1): 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) buf += chr(c)
else: else:
# unsupported # unsupported
@ -114,7 +114,7 @@ def fsplit(pred, objs):
def drange(v0, v1, d): def drange(v0, v1, d):
"""Returns a discrete range.""" """Returns a discrete range."""
assert v0 < v1 assert v0 < v1
return xrange(int(v0)/d, int(v1+d)/d) return xrange(int(v0)//d, int(v1+d)//d)
# get_bound # get_bound