/usr/lib/python2.7/dist-packages/reportlab/rl_config.py is in python-reportlab 3.1.8-3+deb8u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | '''module that aggregates config information'''
__all__=('_reset','register_reset')
def _defaults_init():
'''
create & return defaults for all reportlab settings from
reportlab.rl_settings.py
reportlab.local_rl_settings.py
reportlab_settings.py or ~/.reportlab_settings
latter values override earlier
'''
from reportlab.lib.utils import rl_exec
import os
_DEFAULTS={}
rl_exec('from reportlab.rl_settings import *',_DEFAULTS)
_overrides=_DEFAULTS.copy()
try:
rl_exec('from reportlab.local_rl_settings import *',_overrides)
_DEFAULTS.update(_overrides)
except ImportError:
pass
_overrides=_DEFAULTS.copy()
try:
rl_exec('from reportlab_settings import *',_overrides)
_DEFAULTS.update(_overrides)
except ImportError:
_overrides=_DEFAULTS.copy()
try:
with open(os.path.expanduser(os.path.join('~','.reportlab_settings')),'rb') as f:
rl_exec(f.read(),_overrides)
_DEFAULTS.update(_overrides)
except:
pass
return _DEFAULTS
_DEFAULTS=_defaults_init()
_SAVED = {}
sys_version=None
#this is used to set the options from
def _setOpt(name, value, conv=None):
'''set a module level value from environ/default'''
from os import environ
ename = 'RL_'+name
if ename in environ:
value = environ[ename]
if conv: value = conv(value)
globals()[name] = value
def _startUp():
'''This function allows easy resetting to the global defaults
If the environment contains 'RL_xxx' then we use the value
else we use the given default'''
import os, sys
global sys_version, _unset_
sys_version = sys.version.split()[0] #strip off the other garbage
from reportlab.lib import pagesizes
from reportlab.lib.utils import rl_isdir
if _SAVED=={}:
_unset_ = getattr(sys,'_rl_config__unset_',None)
if _unset_ is None:
class _unset_: pass
sys._rl_config__unset_ = _unset_ = _unset_()
global __all__
A = list(__all__)
for k,v in _DEFAULTS.items():
_SAVED[k] = globals()[k] = v
if k not in __all__:
A.append(k)
__all__ = tuple(A)
#places to search for Type 1 Font files
import reportlab
D = {'REPORTLAB_DIR': os.path.abspath(os.path.dirname(reportlab.__file__)),
'CWD': os.getcwd(),
'disk': os.getcwd().split(':')[0],
'sys_version': sys_version,
'XDG_DATA_HOME': os.environ.get('XDG_DATA_HOME','~/.local/share'),
}
for k in _SAVED:
if k.endswith('SearchPath'):
P=[]
for p in _SAVED[k]:
d = (p % D).replace('/',os.sep)
if '~' in d: d = os.path.expanduser(d)
if rl_isdir(d): P.append(d)
_setOpt(k,os.pathsep.join(P),lambda x:x.split(os.pathsep))
globals()[k] = list(filter(rl_isdir,globals()[k]))
else:
v = _SAVED[k]
if isinstance(v,(int,float)): conv = type(v)
elif k=='defaultPageSize': conv = lambda v,M=pagesizes: getattr(M,v)
else: conv = None
_setOpt(k,v,conv)
_registered_resets=[]
def register_reset(func):
'''register a function to be called by rl_config._reset'''
_registered_resets[:] = [x for x in _registered_resets if x()]
L = [x for x in _registered_resets if x() is func]
if L: return
from weakref import ref
_registered_resets.append(ref(func))
def _reset():
'''attempt to reset reportlab and friends'''
_startUp() #our reset
for f in _registered_resets[:]:
c = f()
if c:
c()
else:
_registered_resets.remove(f)
_startUp()
|