VMM/{Account,Alias,Relocated}: added a address property to the classes
Account, Alias and Relocated.
# -*- coding: UTF-8 -*-# Copyright (c) 2008 - 2010, Pascal Volk# See COPYING for distribution information.""" VirtualMailManager.maillocation Virtual Mail Manager's maillocation module to handle Dovecot's mail_location setting for accounts."""fromVirtualMailManager.pycompatimportany__all__=('MailLocation','known_format','MAILDIR_ID','MBOX_ID','MDBOX_ID','SDBOX_ID')MAILDIR_ID=0x1MBOX_ID=0x2MDBOX_ID=0x3SDBOX_ID=0x4MAILDIR_NAME='Maildir'MBOX_NAME='mail'MDBOX_NAME='mdbox'SDBOX_NAME='dbox'_storage={MAILDIR_ID:dict(dovecot_version=10,postfix=True,prefix='maildir:',directory=MAILDIR_NAME,mid=MAILDIR_ID),MBOX_ID:dict(dovecot_version=10,postfix=True,prefix='mbox:',directory=MBOX_NAME,mid=MBOX_ID),MDBOX_ID:dict(dovecot_version=20,postfix=False,prefix='mdbox:',directory=MDBOX_NAME,mid=MDBOX_ID),SDBOX_ID:dict(dovecot_version=12,postfix=False,prefix='dbox:',directory=SDBOX_NAME,mid=SDBOX_ID),}_format_id={'maildir':MAILDIR_ID,'mbox':MBOX_ID,'mdbox':MDBOX_ID,'dbox':SDBOX_ID,}classMailLocation(object):"""A small class for mail_location relevant information."""__slots__=('_info')def__init__(self,mid=None,format=None):"""Creates a new MailLocation instance. Either a mid or the format must be specified. Keyword arguments: mid -- the id of a mail_location (int) one of the maillocation constants: `MAILDIR_ID`, `MBOX_ID`, `MDBOX_ID` and `SDBOX_ID` format -- the mailbox format of the mail_location. One out of: ``maildir``, ``mbox``, ``dbox`` and ``mdbox``. """assertany((mid,format))ifmid:assertisinstance(mid,(int,long))andmidin_storageself._info=_storage[mid]else:assertisinstance(format,basestring)and \format.lower()in_format_idself._info=_storage[_format_id[format.lower()]]def__str__(self):return'%(prefix)s~/%(directory)s'%self._info@propertydefdirectory(self):"""The mail_location's directory name."""returnself._info['directory']@propertydefdovecot_version(self):"""The required Dovecot version (concatenated major and minor parts) for this mailbox format."""returnself._info['dovecot_version']@propertydefpostfix(self):"""`True` if Postfix supports this mailbox format, else `False`."""returnself._info['postfix']@propertydefprefix(self):"""The prefix of the mail_location."""returnself._info['prefix']@propertydefmail_location(self):"""The mail_location, e.g. ``maildir:~/Maildir``"""returnself.__str__()@propertydefmid(self):"""The mail_location's unique ID."""returnself._info['mid']defknown_format(format):"""Checks if the mailbox *format* is known, returns bool."""returnformat.lower()in_format_id