src/reportlab/__init__.py
author robin <robin@reportlab.com>
Thu, 31 May 2018 12:07:34 +0100
changeset 4405 c985bd7093ad
parent 4404 b055f51699ca
child 4409 e1546608f841
permissions -rw-r--r--
split out DocTemplate _makeCanvas suggested by Chris Jerdonek cjerdonek @ bitbucket; version --> 3.4.41
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4303
1dbe6269e831 improved support for images in renderPM/renderSVG bug report from Claude Paroz; version --> 3.3.26
robin
parents: 4302
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2017
494
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 478
diff changeset
     2
#see license.txt for license details
681
934a4f24ea5d Added explicit font and encoding support
andy_robinson
parents: 625
diff changeset
     3
__doc__="""The Reportlab PDF generation library."""
4405
c985bd7093ad split out DocTemplate _makeCanvas suggested by Chris Jerdonek cjerdonek @ bitbucket; version --> 3.4.41
robin <robin@reportlab.com>
parents: 4404
diff changeset
     4
Version = "3.4.41"
4194
9ecdf084933c allow Table.repeatRows to be a list/tuple; version-->3.1.59
robin
parents: 4192
diff changeset
     5
__version__=Version
4405
c985bd7093ad split out DocTemplate _makeCanvas suggested by Chris Jerdonek cjerdonek @ bitbucket; version --> 3.4.41
robin <robin@reportlab.com>
parents: 4404
diff changeset
     6
__date__='20180531'
2618
19c47ce76a0c changed version and added warning for old Python users
andy
parents: 2407
diff changeset
     7
4260
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
     8
import sys, os
2618
19c47ce76a0c changed version and added warning for old Python users
andy
parents: 2407
diff changeset
     9
3940
39b5e5c82ea1 reportlab/__init__.py: fix allowed version checks & remove cruft
robin
parents: 3820
diff changeset
    10
if sys.version_info[0:2]!=(2, 7) and sys.version_info<(3, 3):
39b5e5c82ea1 reportlab/__init__.py: fix allowed version checks & remove cruft
robin
parents: 3820
diff changeset
    11
    raise ImportError("""reportlab requires Python 2.7+ or 3.3+; 3.0-3.2 are not supported.""")
3820
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    12
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    13
#define these early in reportlab's life
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    14
isPy3 = sys.version_info[0]==3
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    15
if isPy3:
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    16
    def cmp(a,b):
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    17
        return -1 if a<b else (1 if a>b else 0)
4367
9960d82643bf remove ascii, cmp & xrange builtins abuse; version-->3.4.15
robin <robin@reportlab.com>
parents: 4363
diff changeset
    18
    xrange = range
9960d82643bf remove ascii, cmp & xrange builtins abuse; version-->3.4.15
robin <robin@reportlab.com>
parents: 4363
diff changeset
    19
    ascii = ascii
3820
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    20
4260
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    21
    def _fake_import(fn,name):
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    22
        from importlib import machinery
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    23
        m = machinery.SourceFileLoader(name,fn)
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    24
        try:
4261
8ad30c29b9af __init__.py load fake imprt into sys modules
robin
parents: 4260
diff changeset
    25
            sys.modules[name] = m.load_module(name)
4260
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    26
        except FileNotFoundError:
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    27
            raise ImportError('file %s not found' % ascii(fn))
3820
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    28
else:
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    29
    from future_builtins import ascii
4367
9960d82643bf remove ascii, cmp & xrange builtins abuse; version-->3.4.15
robin <robin@reportlab.com>
parents: 4363
diff changeset
    30
    xrange = xrange
9960d82643bf remove ascii, cmp & xrange builtins abuse; version-->3.4.15
robin <robin@reportlab.com>
parents: 4363
diff changeset
    31
    cmp = cmp
4260
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    32
    def _fake_import(fn,name):
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    33
        if os.path.isfile(fn):
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    34
            import imp
58d91bf065e0 address issue #76
robin
parents: 4259
diff changeset
    35
            with open(fn,'rb') as f:
4261
8ad30c29b9af __init__.py load fake imprt into sys modules
robin
parents: 4260
diff changeset
    36
                sys.modules[name] = imp.load_source(name,fn,f)
4032
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    37
4050
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    38
#try to use dynamic modifications from
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    39
#reportlab.local_rl_mods.py
4053
173718fd2975 __init__.py: minimal text change and date bump
robin
parents: 4050
diff changeset
    40
#reportlab_mods.py or ~/.reportlab_mods
4032
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    41
try:
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    42
    import reportlab.local_rl_mods
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    43
except ImportError:
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    44
    pass
4050
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    45
4363
fa1c8635929e attempted fix for bitbucket #issue 114 reported by Martin Groen; version-->3.4.14
robin <robin@reportlab.com>
parents: 4362
diff changeset
    46
if not isPy3:
fa1c8635929e attempted fix for bitbucket #issue 114 reported by Martin Groen; version-->3.4.14
robin <robin@reportlab.com>
parents: 4362
diff changeset
    47
    PermissionError = ImportError
fa1c8635929e attempted fix for bitbucket #issue 114 reported by Martin Groen; version-->3.4.14
robin <robin@reportlab.com>
parents: 4362
diff changeset
    48
4050
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    49
try:
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    50
    import reportlab_mods   #application specific modifications can be anywhere on python path
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    51
except ImportError:
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    52
    try:
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    53
        _fake_import(os.path.expanduser(os.path.join('~','.reportlab_mods')),'reportlab_mods')
4363
fa1c8635929e attempted fix for bitbucket #issue 114 reported by Martin Groen; version-->3.4.14
robin <robin@reportlab.com>
parents: 4362
diff changeset
    54
    except (ImportError,KeyError,PermissionError):
4050
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    55
        pass