src/reportlab/__init__.py
author robin
Thu, 28 May 2015 10:44:31 +0100
changeset 4197 23596473c5b5
parent 4194 9ecdf084933c
child 4206 5d54c7381247
permissions -rw-r--r--
userguide fixes version-->3.1.60
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4194
9ecdf084933c allow Table.repeatRows to be a list/tuple; version-->3.1.59
robin
parents: 4192
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2015
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."""
4197
23596473c5b5 userguide fixes version-->3.1.60
robin
parents: 4194
diff changeset
     4
Version = "3.1.60"
4194
9ecdf084933c allow Table.repeatRows to be a list/tuple; version-->3.1.59
robin
parents: 4192
diff changeset
     5
__version__=Version
2618
19c47ce76a0c changed version and added warning for old Python users
andy
parents: 2407
diff changeset
     6
4050
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
     7
import sys, os, imp
2618
19c47ce76a0c changed version and added warning for old Python users
andy
parents: 2407
diff changeset
     8
3940
39b5e5c82ea1 reportlab/__init__.py: fix allowed version checks & remove cruft
robin
parents: 3820
diff changeset
     9
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
    10
    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
    11
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    12
#define these early in reportlab's life
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    13
isPy3 = sys.version_info[0]==3
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    14
if isPy3:
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    15
    def cmp(a,b):
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    16
        return -1 if a<b else (1 if a>b else 0)
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    17
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    18
    import builtins
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    19
    builtins.cmp = cmp
4005
b7dee7fcd927 utils.py: move xrange hack to reportlab.__init__, add rl_add_builtins utility
robin
parents: 3990
diff changeset
    20
    builtins.xrange = range
3820
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    21
    del cmp, builtins
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    22
else:
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    23
    from future_builtins import ascii
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    24
    import __builtin__
47edc5ad9dc6 move utils.py builtins defs to __init__.py
robin
parents: 3695
diff changeset
    25
    __builtin__.ascii = ascii
3990
b484eaf71af9 reportlab/__init__.py: fix del to delete what we imported (not its alias)
robin
parents: 3946
diff changeset
    26
    del ascii, __builtin__
4032
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    27
4050
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    28
#try to use dynamic modifications from
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    29
#reportlab.local_rl_mods.py
4053
173718fd2975 __init__.py: minimal text change and date bump
robin
parents: 4050
diff changeset
    30
#reportlab_mods.py or ~/.reportlab_mods
4032
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    31
try:
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    32
    import reportlab.local_rl_mods
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    33
except ImportError:
5106a9463326 __init__.py: attempt import of reportlab.local_rl_mods for customization
robin
parents: 4031
diff changeset
    34
    pass
4050
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    35
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    36
def _fake_import(fn,name):
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    37
    if os.path.isfile(fn):
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    38
        with open(fn,'rb') as f:
4152
3aef2d5b6c23 __init__.py fix _fake_import to use the name argument
robin
parents: 4150
diff changeset
    39
            imp.load_source(name,fn,f)
4050
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    40
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    41
try:
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    42
    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
    43
except ImportError:
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    44
    try:
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    45
        _fake_import(os.path.expanduser(os.path.join('~','.reportlab_mods')),'reportlab_mods')
4176
de929aeece02 implement fix contributed by JamesBynd@bitbucket
robin
parents: 4175
diff changeset
    46
    except (ImportError,KeyError):
4050
a899d3baa5f4 __init__.py, rl_config.py & rl_settings.py: revamp initialization yet again
robin
parents: 4047
diff changeset
    47
        pass