File: paths.py.in

package info (click to toggle)
mailman 1:2.1.18-2+deb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 38,432 kB
  • sloc: python: 25,570; perl: 2,219; makefile: 1,117; sh: 882; ansic: 319
file content (90 lines) | stat: -rw-r--r-- 3,066 bytes parent folder | download | duplicates (7)
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
# -*- python -*-

# Copyright (C) 1998-2009 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.

# This file becomes paths.py which is installed in may directories.  By
# importing this module, sys.path gets `hacked' so that the $prefix/Mailman
# directory is inserted at the start of that list.  That directory really
# contains the Mailman modules in package form.  This file exports two
# attributes that other modules may use to get the absolute path to the
# installed Mailman distribution.

import os
import sys

# some scripts expect this attribute to be in this module
prefix = '@prefix@'
exec_prefix = '@exec_prefix@'

# work around a bogus autoconf 2.12 bug
if exec_prefix == '${prefix}':
    exec_prefix = prefix

# Check if ja/ko codecs are available before changing path.
try:
    s = unicode('OK', 'iso-2022-jp')
    jaok = True
except LookupError:
    jaok = False

try:
    s = unicode('OK', 'euc-kr')
    kook = True
except LookupError:
    kook = False

# Hack the path to include the parent directory of the $prefix/Mailman package
# directory.
sys.path.insert(0, prefix)

# We also need the pythonlib directory on the path to pick up any overrides of
# standard modules and packages.  Note that these must go at the front of the
# path for this reason.
sys.path.insert(0, os.path.join(prefix, 'pythonlib'))

# Include Python's site-packages directory.
sitedir = os.path.join(sys.prefix, 'lib', 'python'+sys.version[:3],
                       'site-packages')
sys.path.append(sitedir)


# In a normal interactive Python environment, the japanese.pth and korean.pth
# files would be imported automatically.  But because we inhibit the importing
# of the site module, we need to be explicit about importing these codecs.
if not jaok:
    try:
        import japanese
    except ImportError:
        pass
# As of KoreanCodecs 2.0.5, you had to do the second import to get the Korean
# codecs installed, however leave the first import in there in case an upgrade
# changes this.
if not kook:
    try:
        import korean
        import korean.aliases
    except ImportError:
        pass
# Arabic and Hebrew (RFC-1556) encoding aliases. (temporary solution)
import encodings.aliases
encodings.aliases.aliases.update({
    'iso_8859_6_e': 'iso8859_6',
    'iso_8859_6_i': 'iso8859_6',
    'iso_8859_8_e': 'iso8859_8',
    'iso_8859_8_i': 'iso8859_8',
})