1
2 """GNUmed site customization file.
3
4 This file sets up the default string encoding for Python.
5
6 Some countries will be able to get by without this file,
7 eg those using the 7-bit US-ASCII character set (without
8 those weird accents and stuff). Most others will need to
9 set the proper value here.
10
11 Most European countries will be OK with 'iso8859-1' or
12 'iso8859-15'. On Linux you can find out a suitable encoding
13 by running "locale charmap". On Windows, tough luck.
14
15 If you need this file you will see an error like this:
16
17 File "/usr/lib/python2.4/site-packages/Gnumed/business/gmPerson.py", line 836, in __normalize
18 normalized = aString.replace(u'ä'.encode('latin-1'), u'(Ä|AE|Ae|A|E)'.encode('latin-1'))
19 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 0: ordinal not in range(128)
20
21 when trying to search for a patient. There is a built-in test below
22 but that approach may not be fool-proof.
23 """
24
25
26
27 __version__ = "$Revision: 1.8 $"
28 __author__ = "Karsten Hilbert <Karsten.Hilbert@gmx.net>"
29 __license__ = "GPL v2 or later (details at http://www.gnu.org)"
30
31 import sys
32
33
34 do_set_encoding = False
35
36
37
38
39 def_encoding = 'iso8859-15'
40
41
42
43
44 if __name__ == '__main__':
45 print "------------------------------------------------"
46 print "This file is not intended to be run standalone."
47 print "It is used in the Python/GNUmed startup process."
48 print "Please consult the Python docs for details."
49 print "------------------------------------------------"
50 sys.exit()
51
52 if do_set_encoding:
53 print "GNUmed startup: Setting Python string encoding to [%s]" % def_encoding
54 try:
55 sys.setdefaultencoding(def_encoding)
56 except LookupError:
57 print "GNUmed startup: Cannot set Python string encoding to invalid value [%s]" % def_encoding
58 print "GNUmed startup: Default Python string encoding is [%s]" % sys.getdefaultencoding()
59 print "GNUmed startup: GNUmed is likely to fail where non-7-bit-ASCII is involved"
60 except AttributeError:
61 print "GNUmed startup: Python string encoding must have been set already ?!?"
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