VirtualMailManager/__init__.py
changeset 571 a4aead244f75
parent 568 14abdd04ddf5
child 643 df1e3b67882a
child 675 d24f094d1cb5
--- a/VirtualMailManager/__init__.py	Mon Nov 07 03:22:15 2011 +0000
+++ b/VirtualMailManager/__init__.py	Thu Jun 28 19:26:50 2012 +0000
@@ -1,51 +1,35 @@
 # -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
+# Copyright (c) 2007 - 2012, Pascal Volk
 # See COPYING for distribution information.
-# package initialization code
-#
+"""
+    VirtualMailManager
+    ~~~~~~~~~~~~~~~~~~
+
+    VirtualMailManager package initialization code
+"""
 
-import os
-import re
+import gettext
 import locale
+import sys
 
-from constants.VERSION import *
-import constants.ERROR as ERR
+from VirtualMailManager.constants import __author__, __date__, __version__
+
+__all__ = [
+    # version information from VERSION
+    '__author__', '__date__', '__version__',
+    # defined stuff
+    'ENCODING',
+]
+
 
 # Try to set all of the locales according to the current
 # environment variables and get the character encoding.
 try:
     locale.setlocale(locale.LC_ALL, '')
 except locale.Error:
+    sys.stderr.write('warning: unsupported locale setting - '
+                     'that may cause encoding problems.\n\n')
     locale.setlocale(locale.LC_ALL, 'C')
 ENCODING = locale.nl_langinfo(locale.CODESET)
 
-def w_std(*args):
-    """Writes each arg of args, encoded in the current ENCODING, to stdout and
-    appends a newline."""
-    _write = os.sys.stdout.write
-    for arg in args:
-        _write(arg.encode(ENCODING, 'replace'))
-        _write('\n')
-
-def w_err(code, *args):
-    """Writes each arg of args, encoded in the current ENCODING, to stderr and
-    appends a newline.
-    This function additional interrupts the program execution and uses 'code'
-    system exit status."""
-    _write = os.sys.stderr.write
-    for arg in args:
-        _write(arg.encode(ENCODING, 'replace'))
-        _write('\n')
-    os.sys.exit(code)
-
-__all__ = [
-        # imported modules
-        'os', 're', 'locale',
-        # version information from VERSION
-        '__author__', '__date__', '__version__',
-        # error codes
-        'ERR',
-        # defined stuff
-        'ENCODING', 'w_std', 'w_err'
-        ]
-# EOF
+gettext.install('vmm', '/usr/local/share/locale', unicode=1)