VirtualMailManager/mailbox.py
branchv0.7.x
changeset 643 df1e3b67882a
parent 642 4cd9d0a9f42f
child 653 cf07e4468934
equal deleted inserted replaced
642:4cd9d0a9f42f 643:df1e3b67882a
    33         dest.append('&%s-' % mb64.rstrip('\n=').replace('/', ','))
    33         dest.append('&%s-' % mb64.rstrip('\n=').replace('/', ','))
    34         del inp[:]
    34         del inp[:]
    35 
    35 
    36 
    36 
    37 def _mbase64_to_unicode(mb64):
    37 def _mbase64_to_unicode(mb64):
    38     return unicode(a2b_base64(mb64.replace(',', '/') + '==='), 'utf-16be')
    38     return str(a2b_base64(mb64.replace(',', '/') + '==='), 'utf-16be')
    39 
    39 
    40 
    40 
    41 def utf8_to_mutf7(src):
    41 def utf8_to_mutf7(src):
    42     """
    42     """
    43     Converts the international mailbox name `src` into a modified
    43     Converts the international mailbox name `src` into a modified
    84 
    84 
    85 
    85 
    86 class Mailbox(object):
    86 class Mailbox(object):
    87     """Base class of all mailbox classes."""
    87     """Base class of all mailbox classes."""
    88     __slots__ = ('_boxes', '_root', '_sep', '_user')
    88     __slots__ = ('_boxes', '_root', '_sep', '_user')
    89     FILE_MODE = 0600
    89     FILE_MODE = 0o600
    90     _ctrl_chr_re = re.compile('[\x00-\x1F\x7F-\x9F]')
    90     _ctrl_chr_re = re.compile('[\x00-\x1F\x7F-\x9F]')
    91     _box_name_re = re.compile('^[\x20-\x25\x27-\x7E]+$')
    91     _box_name_re = re.compile('^[\x20-\x25\x27-\x7E]+$')
    92 
    92 
    93     def __init__(self, account):
    93     def __init__(self, account):
    94         """
    94         """
   253             cmd_args.append('-s')
   253             cmd_args.append('-s')
   254         cmd_args.extend(mailboxes)
   254         cmd_args.extend(mailboxes)
   255         process = Popen(cmd_args, stderr=PIPE)
   255         process = Popen(cmd_args, stderr=PIPE)
   256         stderr = process.communicate()[1]
   256         stderr = process.communicate()[1]
   257         if process.returncode:
   257         if process.returncode:
   258             e_msg = _(u'Failed to create mailboxes: %r\n') % mailboxes
   258             e_msg = _('Failed to create mailboxes: %r\n') % mailboxes
   259             raise VMMError(e_msg + stderr.strip(), VMM_ERROR)
   259             raise VMMError(e_msg + stderr.strip(), VMM_ERROR)
   260 
   260 
   261     def create(self):
   261     def create(self):
   262         """Create a dbox INBOX"""
   262         """Create a dbox INBOX"""
   263         os.mkdir(self._root, cfg_dget('account.directory_mode'))
   263         os.mkdir(self._root, cfg_dget('account.directory_mode'))