53 self._dbh = dbh |
53 self._dbh = dbh |
54 self._directory = None |
54 self._directory = None |
55 self._mbfmt = None |
55 self._mbfmt = None |
56 self._mid = 0 |
56 self._mid = 0 |
57 |
57 |
58 for key in kwargs.iterkeys(): |
58 for key in kwargs.keys(): |
59 if key not in self.__class__._kwargs: |
59 if key not in self.__class__._kwargs: |
60 raise ValueError('unrecognized keyword: %r' % key) |
60 raise ValueError('unrecognized keyword: %r' % key) |
61 mid = kwargs.get('mid') |
61 mid = kwargs.get('mid') |
62 if mid: |
62 if mid: |
63 assert isinstance(mid, (int, long)) |
63 assert isinstance(mid, int) |
64 self._load_by_mid(mid) |
64 self._load_by_mid(mid) |
65 else: |
65 else: |
66 args = kwargs.get('mbfmt'), kwargs.get('directory') |
66 args = kwargs.get('mbfmt'), kwargs.get('directory') |
67 assert all(isinstance(arg, basestring) for arg in args) |
67 assert all(isinstance(arg, str) for arg in args) |
68 if args[0].lower() not in _format_info: |
68 if args[0].lower() not in _format_info: |
69 raise MLErr(_(u"Unsupported mailbox format: '%s'") % args[0], |
69 raise MLErr(_("Unsupported mailbox format: '%s'") % args[0], |
70 MAILLOCATION_INIT) |
70 MAILLOCATION_INIT) |
71 directory = args[1].strip() |
71 directory = args[1].strip() |
72 if not directory: |
72 if not directory: |
73 raise MLErr(_(u"Empty directory name"), MAILLOCATION_INIT) |
73 raise MLErr(_("Empty directory name"), MAILLOCATION_INIT) |
74 if len(directory) > 20: |
74 if len(directory) > 20: |
75 raise MLErr(_(u"Directory name is too long: '%s'") % directory, |
75 raise MLErr(_("Directory name is too long: '%s'") % directory, |
76 MAILLOCATION_INIT) |
76 MAILLOCATION_INIT) |
77 self._load_by_names(args[0].lower(), directory) |
77 self._load_by_names(args[0].lower(), directory) |
78 |
78 |
79 def __str__(self): |
79 def __str__(self): |
80 return u'%s:~/%s' % (self._mbfmt, self._directory) |
80 return '%s:~/%s' % (self._mbfmt, self._directory) |
81 |
81 |
82 @property |
82 @property |
83 def directory(self): |
83 def directory(self): |
84 """The mail_location's directory name.""" |
84 """The mail_location's directory name.""" |
85 return self._directory |
85 return self._directory |