Coverage for pdfrw/pdfrw/py23_diffs.py: 71%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# A part of pdfrw (https://github.com/pmaupin/pdfrw)
2# Copyright (C) 2006-2015 Patrick Maupin, Austin, Texas
3# MIT license -- See LICENSE.txt for details
5# Deal with Python2/3 differences
7try:
8 import zlib
9except ImportError:
10 zlib = None
12try:
13 unicode = unicode
14except NameError:
16 def convert_load(s):
17 if isinstance(s, bytes):
18 return s.decode('Latin-1')
19 return s
21 def convert_store(s):
22 return s.encode('Latin-1')
24 def from_array(a):
25 return a.tobytes()
27else:
29 def convert_load(s):
30 return s
32 def convert_store(s):
33 return s
35 def from_array(a):
36 return a.tostring()
38nextattr, = (x for x in dir(iter([])) if 'next' in x)
40try:
41 iteritems = dict.iteritems
42except AttributeError:
43 iteritems = dict.items
45try:
46 xrange = xrange
47except NameError:
48 xrange = range
50try:
51 intern = intern
52except NameError:
53 from sys import intern