VirtualMailManager/__init__.py
branchv0.6.x
changeset 256 ae80282301a3
parent 254 8aecc83a0d32
child 262 6eea85d8b91d
equal deleted inserted replaced
255:d2ddd4a6528d 256:ae80282301a3
    22 
    22 
    23 __all__ = [
    23 __all__ = [
    24     # version information from VERSION
    24     # version information from VERSION
    25     '__author__', '__date__', '__version__',
    25     '__author__', '__date__', '__version__',
    26     # defined stuff
    26     # defined stuff
    27     'ENCODING', 'exec_ok', 'expand_path', 'get_unicode', 'is_dir',
    27     'ENCODING', 'Configuration', 'exec_ok', 'expand_path', 'get_unicode',
       
    28     'is_dir', 'set_configuration',
    28 ]
    29 ]
    29 
    30 
    30 
    31 
    31 # Try to set all of the locales according to the current
    32 # Try to set all of the locales according to the current
    32 # environment variables and get the character encoding.
    33 # environment variables and get the character encoding.
    34     locale.setlocale(locale.LC_ALL, '')
    35     locale.setlocale(locale.LC_ALL, '')
    35 except locale.Error:
    36 except locale.Error:
    36     locale.setlocale(locale.LC_ALL, 'C')
    37     locale.setlocale(locale.LC_ALL, 'C')
    37 ENCODING = locale.nl_langinfo(locale.CODESET)
    38 ENCODING = locale.nl_langinfo(locale.CODESET)
    38 
    39 
       
    40 Configuration = None
       
    41 
    39 gettext.install('vmm', '/usr/local/share/locale', unicode=1)
    42 gettext.install('vmm', '/usr/local/share/locale', unicode=1)
    40 
    43 
    41 
    44 
    42 _ = lambda msg: msg
    45 _ = lambda msg: msg
       
    46 
       
    47 
       
    48 def set_configuration(cfg_obj):
       
    49     """Assigns the *cfg_obj* to the global `Configuration`.
       
    50     *cfg_obj* has to be a `VirtualMailManager.Config.Config` instance."""
       
    51     from VirtualMailManager.Config import Config
       
    52     assert isinstance(cfg_obj, Config)
       
    53     global Configuration
       
    54     Configuration = cfg_obj
    43 
    55 
    44 
    56 
    45 def get_unicode(string):
    57 def get_unicode(string):
    46     """Converts `string` to `unicode`, if necessary."""
    58     """Converts `string` to `unicode`, if necessary."""
    47     if isinstance(string, unicode):
    59     if isinstance(string, unicode):