VirtualMailManager/__init__.py
author Pascal Volk <neverseen@users.sourceforge.net>
Wed, 13 Jan 2010 00:08:44 +0000
branchv0.6.x
changeset 166 b152ad5c7071
parent 162 0ac9ef587769
child 174 974bafa59330
permissions -rw-r--r--
vmm.cfg: dealt with the most overdue section/option renaming. Added new options. Details: old new ------------------------------------------------------------ domdir.mode -> domain.directory_mode domdir.delete -> domain.delete_directory domdir.base -> misc.base_dir domdir -> _section domdir deleted_ maildir.mode -> account.directory_mode maildir.diskusage -> account.disk_usage maildir.delete -> account.delete_directory misc.forcedel -> domain.force_del misc.passwdscheme -> misc.password_scheme misc.dovecotvers -> misc.dovecot_vers services.smtp -> account.smtp services.pop3 -> account.pop3 services.imap -> account.imap services.sieve -> account.sieve services -> _section services deleted_ _NEW_.random_password -> account.random_password _NEW_.password_len -> account.password_len _NEW_.auto_postmaster -> domain.auto_postmaster

# -*- coding: UTF-8 -*-
# Copyright (c) 2007 - 2010, Pascal Volk
# See COPYING for distribution information.
# package initialization code
#

import os
import re
import locale

from constants.VERSION import *
import constants.ERROR as ERR

# 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:
    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