blob: a0e031823bec7645cf0285807d4c9d46d3fc2c3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# A part of pdfrw (https://github.com/pmaupin/pdfrw)
# Copyright (C) 2006-2015 Patrick Maupin, Austin, Texas
# MIT license -- See LICENSE.txt for details
# Deal with Python2/3 differences
try:
import zlib
except ImportError:
zlib = None
try:
unicode = unicode
except NameError:
def convert_load(s):
return s.decode('Latin-1')
def convert_store(s):
return s.encode('Latin-1')
def from_array(a):
return a.tobytes()
else:
def convert_load(s):
return s
def convert_store(s):
return s
def from_array(a):
return a.tostring()
nextattr, = (x for x in dir(iter([])) if 'next' in x)
try:
iteritems = dict.iteritems
except AttributeError:
iteritems = dict.items
try:
xrange = xrange
except NameError:
xrange = range
|