VirtualMailManager/maillocation.py
branchv0.6.x
changeset 295 18086c6a2521
parent 267 084300a00ee1
child 302 32b4a39b5640
equal deleted inserted replaced
294:7d1bafc6fa30 295:18086c6a2521
    12 
    12 
    13 from VirtualMailManager.pycompat import any
    13 from VirtualMailManager.pycompat import any
    14 
    14 
    15 
    15 
    16 __all__ = ('MailLocation', 'known_format',
    16 __all__ = ('MailLocation', 'known_format',
    17            'MAILDIR_ID', 'MBOX_ID', 'MDBOX_ID', 'SDBOX_ID')
    17            'ID_MAILDIR', 'ID_MBOX', 'ID_MDBOX', 'ID_SDBOX')
    18 
    18 
    19 MAILDIR_ID = 0x1
    19 ID_MAILDIR = 0x1
    20 MBOX_ID = 0x2
    20 ID_MBOX = 0x2
    21 MDBOX_ID = 0x3
    21 ID_MDBOX = 0x3
    22 SDBOX_ID = 0x4
    22 ID_SDBOX = 0x4
    23 MAILDIR_NAME = 'Maildir'
       
    24 MBOX_NAME = 'mail'
       
    25 MDBOX_NAME = 'mdbox'
       
    26 SDBOX_NAME = 'dbox'
       
    27 
    23 
    28 _storage = {
    24 _storage = {
    29     MAILDIR_ID: dict(dovecot_version=0x10000f00, postfix=True,
    25     ID_MAILDIR: dict(dovecot_version=0x10000f00, postfix=True,
    30                      prefix='maildir:', directory=MAILDIR_NAME,
    26                      prefix='maildir:', directory='Maildir', mid=ID_MAILDIR),
    31                      mid=MAILDIR_ID),
    27     ID_MBOX: dict(dovecot_version=0x10000f00, postfix=True, prefix='mbox:',
    32     MBOX_ID: dict(dovecot_version=0x10000f00, postfix=True, prefix='mbox:',
    28                   directory='mail', mid=ID_MBOX),
    33                   directory=MBOX_NAME, mid=MBOX_ID),
    29     ID_MDBOX: dict(dovecot_version=0x20000a01, postfix=False,
    34     MDBOX_ID: dict(dovecot_version='0x20000a01', postfix=False,
    30                    prefix='mdbox:', directory='mdbox', mid=ID_MDBOX),
    35                    prefix='mdbox:', directory=MDBOX_NAME, mid=MDBOX_ID),
    31     ID_SDBOX: dict(dovecot_version=0x10000f00, postfix=False, prefix='dbox:',
    36     SDBOX_ID: dict(dovecot_version=0x10000f00, postfix=False, prefix='dbox:',
    32                    directory='dbox', mid=ID_SDBOX),
    37                    directory=SDBOX_NAME, mid=SDBOX_ID),
       
    38 }
    33 }
    39 
    34 
    40 _format_id = {
    35 _format_id = {
    41     'maildir': MAILDIR_ID,
    36     'maildir': ID_MAILDIR,
    42     'mbox': MBOX_ID,
    37     'mbox': ID_MBOX,
    43     'mdbox': MDBOX_ID,
    38     'mdbox': ID_MDBOX,
    44     'dbox': SDBOX_ID,
    39     'dbox': ID_SDBOX,
    45 }
    40 }
    46 
    41 
    47 
    42 
    48 class MailLocation(object):
    43 class MailLocation(object):
    49     """A small class for mail_location relevant information."""
    44     """A small class for mail_location relevant information."""
    54 
    49 
    55         Either a mid or the format must be specified.
    50         Either a mid or the format must be specified.
    56 
    51 
    57         Keyword arguments:
    52         Keyword arguments:
    58         mid -- the id of a mail_location (int)
    53         mid -- the id of a mail_location (int)
    59           one of the maillocation constants: `MAILDIR_ID`, `MBOX_ID`,
    54           one of the maillocation constants: `ID_MAILDIR`, `ID_MBOX`,
    60           `MDBOX_ID` and `SDBOX_ID`
    55           `ID_MDBOX` and `ID_SDBOX`
    61         format -- the mailbox format of the mail_location. One out of:
    56         format -- the mailbox format of the mail_location. One out of:
    62         ``maildir``, ``mbox``, ``dbox`` and ``mdbox``.
    57         ``maildir``, ``mbox``, ``dbox`` and ``mdbox``.
    63         """
    58         """
    64         assert any((mid, format))
    59         assert any((mid, format))
    65         if mid:
    60         if mid: