~openerp-dev/openobject-server/trunk-bug-712254-ysa

« back to all changes in this revision

Viewing changes to bin/reportlab/rl_config.py

  • Committer: pinky
  • Date: 2006-12-07 13:41:40 UTC
  • Revision ID: pinky-3f10ee12cea3c4c75cef44ab04ad33ef47432907
New trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#Copyright ReportLab Europe Ltd. 2000-2004
 
2
#see license.txt for license details
 
3
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/rl_config.py
 
4
__version__=''' $Id$ '''
 
5
 
 
6
allowTableBoundsErrors = 1 # set to 0 to die on too large elements in tables in debug (recommend 1 for production use)
 
7
shapeChecking =             1
 
8
defaultEncoding =           'WinAnsiEncoding'       # 'WinAnsi' or 'MacRoman'
 
9
pageCompression =           1                       # default page compression mode
 
10
defaultPageSize =           'A4'                    #default page size
 
11
defaultImageCaching =       0                       #set to zero to remove those annoying cached images
 
12
ZLIB_WARNINGS =             1
 
13
warnOnMissingFontGlyphs =   0                       #if 1, warns of each missing glyph
 
14
verbose =                   0
 
15
showBoundary =              0                       # turns on and off boundary behaviour in Drawing
 
16
emptyTableAction=           'error'                 # one of 'error', 'indicate', 'ignore'
 
17
invariant=                  0                       #produces repeatable,identical PDFs with same timestamp info (for regression testing)
 
18
eps_preview_transparent=    None                    #set to white etc
 
19
overlapAttachedSpace=       1                       #if set non false then adajacent flowable space after
 
20
                                                    #and space before are merged (max space is used).
 
21
_FUZZ=                      1e-6                    #fuzz for layout arithmetic
 
22
 
 
23
# places to look for T1Font information
 
24
T1SearchPath =  (
 
25
                'c:/Program Files/Adobe/Acrobat 6.0/Resource/Font', #Win32, Acrobat 6
 
26
                'c:/Program Files/Adobe/Acrobat 5.0/Resource/Font',     #Win32, Acrobat 5
 
27
                'c:/Program Files/Adobe/Acrobat 4.0/Resource/Font', #Win32, Acrobat 4
 
28
                '%(disk)s/Applications/Python %(sys_version)s/reportlab/fonts', #Mac?
 
29
                '/usr/lib/Acrobat5/Resource/Font',      #Linux, Acrobat 5?
 
30
                '/usr/lib/Acrobat4/Resource/Font',      #Linux, Acrobat 4
 
31
                '/usr/local/Acrobat6/Resource/Font',    #Linux, Acrobat 5?
 
32
                '/usr/local/Acrobat5/Resource/Font',    #Linux, Acrobat 5?
 
33
                '/usr/local/Acrobat4/Resource/Font',    #Linux, Acrobat 4
 
34
                '%(REPORTLAB_DIR)s/fonts',              #special
 
35
                '%(REPORTLAB_DIR)s/../fonts',           #special
 
36
                '%(REPORTLAB_DIR)s/../../fonts',        #special
 
37
                '%(HOME)s/fonts',                       #special
 
38
                 )
 
39
 
 
40
# places to look for TT Font information
 
41
TTFSearchPath = (
 
42
                'c:/winnt/fonts',
 
43
                'c:/windows/fonts',
 
44
                '/usr/lib/X11/fonts/TrueType/',
 
45
                '%(REPORTLAB_DIR)s/fonts',      #special
 
46
                '%(REPORTLAB_DIR)s/../fonts',   #special
 
47
                '%(REPORTLAB_DIR)s/../../fonts',#special
 
48
                '%(HOME)s/fonts',               #special
 
49
                )
 
50
 
 
51
# places to look for CMap files - should ideally merge with above
 
52
CMapSearchPath = ('/usr/lib/Acrobat6/Resource/CMap',
 
53
                  '/usr/lib/Acrobat5/Resource/CMap',
 
54
                  '/usr/lib/Acrobat4/Resource/CMap',
 
55
                  '/usr/local/Acrobat6/Resource/CMap',
 
56
                  '/usr/local/Acrobat5/Resource/CMap',
 
57
                  '/usr/local/Acrobat4/Resource/CMap',
 
58
                  'C:\\Program Files\\Adobe\\Acrobat\\Resource\\CMap',
 
59
                  'C:\\Program Files\\Adobe\\Acrobat 6.0\\Resource\\CMap',
 
60
                  'C:\\Program Files\\Adobe\\Acrobat 5.0\\Resource\\CMap',
 
61
                  'C:\\Program Files\\Adobe\\Acrobat 4.0\\Resource\\CMap'
 
62
                  '%(REPORTLAB_DIR)s/fonts/CMap',       #special
 
63
                  '%(REPORTLAB_DIR)s/../fonts/CMap',    #special
 
64
                  '%(REPORTLAB_DIR)s/../../fonts/CMap', #special
 
65
                  '%(HOME)s/fonts/CMap',                #special
 
66
                  )
 
67
 
 
68
#### Normally don't need to edit below here ####
 
69
try:
 
70
    from local_rl_config import *
 
71
except:
 
72
    pass
 
73
 
 
74
_SAVED = {}
 
75
sys_version=None
 
76
 
 
77
def _setOpt(name, value, conv=None):
 
78
    '''set a module level value from environ/default'''
 
79
    from os import environ
 
80
    ename = 'RL_'+name
 
81
    if environ.has_key(ename):
 
82
        value = environ[ename]
 
83
    if conv: value = conv(value)
 
84
    globals()[name] = value
 
85
 
 
86
def _startUp():
 
87
    '''This function allows easy resetting to the global defaults
 
88
    If the environment contains 'RL_xxx' then we use the value
 
89
    else we use the given default'''
 
90
    V = ('T1SearchPath','CMapSearchPath', 'TTFSearchPath',
 
91
                'shapeChecking', 'defaultEncoding',
 
92
                'pageCompression', 'defaultPageSize', 'defaultImageCaching',
 
93
                'ZLIB_WARNINGS', 'warnOnMissingFontGlyphs', 'verbose', 'emptyTableAction',
 
94
                'invariant','eps_preview_transparent',
 
95
                )
 
96
    import os, sys, string
 
97
    global sys_version, _unset_
 
98
    sys_version = string.split(sys.version)[0]      #strip off the other garbage
 
99
    from reportlab.lib import pagesizes
 
100
    from reportlab.lib.utils import rl_isdir
 
101
 
 
102
    if _SAVED=={}:
 
103
        _unset_ = getattr(sys,'_rl_config__unset_',None)
 
104
        if _unset_ is None:
 
105
            class _unset_: pass
 
106
            sys._rl_config__unset_ = _unset_ = _unset_()
 
107
        for k in V:
 
108
            _SAVED[k] = globals()[k]
 
109
 
 
110
    #places to search for Type 1 Font files
 
111
    import reportlab
 
112
    D = {'REPORTLAB_DIR': os.path.abspath(os.path.dirname(reportlab.__file__)),
 
113
        'HOME': os.environ.get('HOME',os.getcwd()),
 
114
        'disk': string.split(os.getcwd(), ':')[0],
 
115
        'sys_version': sys_version,
 
116
        }
 
117
 
 
118
    for name in ('T1SearchPath','TTFSearchPath','CMapSearchPath'):
 
119
        P=[]
 
120
        for p in _SAVED[name]:
 
121
            d = string.replace(p % D,'/',os.sep)
 
122
            if rl_isdir(d): P.append(d)
 
123
        _setOpt(name,P)
 
124
 
 
125
    for k in V[3:]:
 
126
        v = _SAVED[k]
 
127
        if type(v)==type(1): conv = int
 
128
        elif k=='defaultPageSize': conv = lambda v,M=pagesizes: getattr(M,v)
 
129
        else: conv = None
 
130
        _setOpt(k,v,conv)
 
131
 
 
132
_startUp()