1 # -*- coding: UTF-8 -*- |
1 # -*- coding: UTF-8 -*- |
2 # Copyright (c) 2007 - 2009, VEB IT |
2 # Copyright (c) 2007 - 2009, VEB IT |
3 # See COPYING for distribution information. |
3 # See COPYING for distribution information. |
4 # package placeholder |
4 # package initialization code |
5 # |
5 # |
|
6 |
|
7 import os |
|
8 import re |
|
9 import locale |
|
10 |
|
11 from constants.VERSION import * |
|
12 import constants.ERROR as ERR |
|
13 |
|
14 # Set all of the locales according to the current environment variables |
|
15 # and get the character encoding. |
|
16 locale.setlocale(locale.LC_ALL, '') |
|
17 ENCODING = locale.nl_langinfo(locale.CODESET) |
|
18 |
|
19 def w_std(*args): |
|
20 """Writes each arg of args, encoded in the current ENCODING, to stdout and |
|
21 appends a newline.""" |
|
22 for arg in args: |
|
23 os.sys.stdout.write(arg.encode(ENCODING, 'replace')) |
|
24 os.sys.stdout.write('\n') |
|
25 |
|
26 def w_err(code, *args): |
|
27 """Writes each arg of args, encoded in the current ENCODING, to stderr and |
|
28 appends a newline. |
|
29 This function additional interrupts the program execution and uses 'code' |
|
30 system exit status.""" |
|
31 for arg in args: |
|
32 os.sys.stderr.write(arg.encode(ENCODING, 'replace')) |
|
33 os.sys.stderr.write('\n') |
|
34 os.sys.exit(code) |
|
35 |
|
36 __all__ = [ |
|
37 # imported modules |
|
38 'os', 're', 'locale', |
|
39 # version information from VERSION |
|
40 '__author__', '__date__', '__version__', |
|
41 # error codes |
|
42 'ERR', |
|
43 # defined stuff |
|
44 'ENCODING', 'w_std', 'w_err' |
|
45 ] |
6 # EOF |
46 # EOF |