# HG changeset patch # User Pascal Volk # Date 1280288639 0 # Node ID 94bd10e237e5588e9da53a1b96612babf7be8eef # Parent 883d5cd664989fbeb73956a13b644a594e482d94 VMM/…: More PEP-8 fixes; eliminated __names. VMM/emailaddress: Fixed™ methods __eq__ and __ne__. (I'm not pylint's nanny.) diff -r 883d5cd66498 -r 94bd10e237e5 VirtualMailManager/alias.py --- a/VirtualMailManager/alias.py Wed Jul 28 02:52:08 2010 +0000 +++ b/VirtualMailManager/alias.py Wed Jul 28 03:43:59 2010 +0000 @@ -35,9 +35,9 @@ self._addr.domainname, NO_SUCH_DOMAIN) self._dests = [] - self.__load_dests() + self._load_dests() - def __load_dests(self): + def _load_dests(self): """Loads all known destination addresses into the _dests list.""" dbc = self._dbh.cursor() dbc.execute('SELECT destination FROM alias WHERE gid = %s AND ' @@ -47,7 +47,7 @@ self._dests.extend(EmailAddress(dest[0]) for dest in dests) dbc.close() - def __check_expansion(self, count_new): + def _check_expansion(self, count_new): """Checks the current expansion limit of the alias.""" postconf = Postconf(cfg_dget('bin.postconf')) limit = long(postconf.read('virtual_alias_expansion_limit')) @@ -72,7 +72,7 @@ 'limit': limit, 'count_new': count_new}, ALIAS_EXCEEDS_EXPANSION_LIMIT) - def __delete(self, destination=None): + def _delete(self, destination=None): """Deletes a destination from the alias, if ``destination`` is not ``None``. If ``destination`` is None, the alias with all its destination addresses will be deleted. @@ -123,7 +123,7 @@ warnings.extend(duplicates) if not destinations: return destinations - self.__check_expansion(len(destinations)) + self._check_expansion(len(destinations)) dbc = self._dbh.cursor() dbc.executemany("INSERT INTO alias VALUES (%d, '%s', %%s)" % (self._gid, self._addr.localpart), @@ -143,7 +143,7 @@ raise AErr(_(u"The address '%(addr)s' isn't a destination of " u"the alias '%(alias)s'.") % {'addr': self._addr, 'alias': destination}, NO_SUCH_ALIAS) - self.__delete(destination) + self._delete(destination) self._dests.remove(destination) def get_destinations(self): @@ -158,7 +158,7 @@ if not self._dests: raise AErr(_(u"The alias '%s' doesn't exist.") % self._addr, NO_SUCH_ALIAS) - self.__delete() + self._delete() del self._dests[:] del _, cfg_dget diff -r 883d5cd66498 -r 94bd10e237e5 VirtualMailManager/cli/config.py --- a/VirtualMailManager/cli/config.py Wed Jul 28 02:52:08 2010 +0000 +++ b/VirtualMailManager/cli/config.py Wed Jul 28 03:43:59 2010 +0000 @@ -57,7 +57,7 @@ break print if self._modified: - self.__save_changes() + self._save_changes() def set(self, option, value): """Set the value of an option. @@ -81,9 +81,9 @@ if not RawConfigParser.has_section(self, section): self.add_section(section) RawConfigParser.set(self, section, option_, val) - self.__save_changes() + self._save_changes() - def __save_changes(self): + def _save_changes(self): """Writes changes to the configuration file.""" copy2(self._cfg_filename, self._cfg_filename + '.bak') self._cfg_file = open(self._cfg_filename, 'w') diff -r 883d5cd66498 -r 94bd10e237e5 VirtualMailManager/config.py --- a/VirtualMailManager/config.py Wed Jul 28 02:52:08 2010 +0000 +++ b/VirtualMailManager/config.py Wed Jul 28 03:43:59 2010 +0000 @@ -370,7 +370,7 @@ """ # TODO: There are only two settings w/o defaults. # So there is no need for cStringIO - if not self.__chk_cfg(): + if not self._chk_cfg(): errmsg = StringIO() errmsg.write(_(u'Missing options, which have no default value.\n')) errmsg.write(_(u'Using configuration file: %s\n') % @@ -392,7 +392,7 @@ to Unicode.""" return get_unicode(self.get(section, option)) - def __chk_cfg(self): + def _chk_cfg(self): """Checks all section's options for settings w/o a default value. diff -r 883d5cd66498 -r 94bd10e237e5 VirtualMailManager/emailaddress.py --- a/VirtualMailManager/emailaddress.py Wed Jul 28 02:52:08 2010 +0000 +++ b/VirtualMailManager/emailaddress.py Wed Jul 28 03:43:59 2010 +0000 @@ -42,14 +42,14 @@ def __eq__(self, other): if isinstance(other, self.__class__): - return self._localpart == other.localpart and \ - self._domainname == other.domainname + return self._localpart == other._localpart and \ + self._domainname == other._domainname return NotImplemented def __ne__(self, other): if isinstance(other, self.__class__): - return self._localpart != other.localpart or \ - self._domainname != other.domainname + return self._localpart != other._localpart or \ + self._domainname != other._domainname return NotImplemented def __hash__(self): diff -r 883d5cd66498 -r 94bd10e237e5 VirtualMailManager/mailbox.py --- a/VirtualMailManager/mailbox.py Wed Jul 28 02:52:08 2010 +0000 +++ b/VirtualMailManager/mailbox.py Wed Jul 28 03:43:59 2010 +0000 @@ -275,18 +275,15 @@ __slots__ = () -def __get_mailbox_class(mbfmt): +def new(account): + """Create a new Mailbox instance for the given Account.""" + mbfmt = account.mail_location.mbformat if mbfmt == 'maildir': - return Maildir + return Maildir(account) elif mbfmt == 'mdbox': - return MultiDbox + return MultiDbox(account) elif mbfmt == 'sdbox': - return SingleDbox + return SingleDbox(account) raise ValueError('unsupported mailbox format: %r' % mbfmt) - -def new(account): - """Create a new Mailbox instance for the given Account.""" - return __get_mailbox_class(account.mail_location.mbformat)(account) - del cfg_dget diff -r 883d5cd66498 -r 94bd10e237e5 VirtualMailManager/relocated.py --- a/VirtualMailManager/relocated.py Wed Jul 28 02:52:08 2010 +0000 +++ b/VirtualMailManager/relocated.py Wed Jul 28 03:43:59 2010 +0000 @@ -39,13 +39,13 @@ self._addr.domainname, NO_SUCH_DOMAIN) self._dest = None - self.__load() + self._load() def __nonzero__(self): """Returns `True` if the Relocated is known, `False` if it's new.""" return self._dest is not None - def __load(self): + def _load(self): """Loads the destination address from the database into the `_dest` attribute.