PEP8: Fixed all PEP8 related issues.
--- a/VirtualMailManager/account.py Mon Sep 03 22:40:01 2012 +0000
+++ b/VirtualMailManager/account.py Wed Sep 05 21:30:42 2012 +0000
@@ -353,7 +353,8 @@
not self._mail.postfix:
raise AErr(_(u"Invalid transport '%(transport)s' for mailbox "
u"format '%(mbfmt)s'.") %
- {'transport': transport, 'mbfmt': self._mail.mbformat},
+ {'transport': transport,
+ 'mbfmt': self._mail.mbformat},
INVALID_MAIL_LOCATION)
transport = transport.tid
self._update_tables('tid', transport)
--- a/VirtualMailManager/catchall.py Mon Sep 03 22:40:01 2012 +0000
+++ b/VirtualMailManager/catchall.py Wed Sep 05 21:30:42 2012 +0000
@@ -74,8 +74,9 @@
elif dcount > limit:
failed = True
errmsg = _(
-u"""Cannot add %(count_new)i new destination(s) to catch-all alias for
-domain '%(domain)s'. This alias already exceeds its expansion limit (%(count)i/%(limit)i).
+u"""Cannot add %(count_new)i new destination(s) to catch-all alias for domain
+'%(domain)s'. This alias already exceeds its expansion limit \
+(%(count)i/%(limit)i).
So its unusable, all messages addressed to this alias will be bounced.
Hint: Delete some destination addresses.""")
if failed:
--- a/VirtualMailManager/cli/subcommands.py Mon Sep 03 22:40:01 2012 +0000
+++ b/VirtualMailManager/cli/subcommands.py Wed Sep 05 21:30:42 2012 +0000
@@ -539,10 +539,12 @@
"""list all user accounts / search user accounts by pattern"""
return list_addresses(ctx, TYPE_ACCOUNT)
+
def list_aliases(ctx):
"""list all aliases / search aliases by pattern"""
return list_addresses(ctx, TYPE_ALIAS)
+
def list_relocated(ctx):
"""list all relocated records / search relocated records by pattern"""
return list_addresses(ctx, TYPE_RELOCATED)
@@ -644,8 +646,10 @@
if details in (None, 'du'):
info['quota storage'] = _format_quota_usage(info['ql_bytes'],
info['uq_bytes'], True, info['ql_domaindefault'])
- info['quota messages'] = _format_quota_usage(info['ql_messages'],
- info['uq_messages'], domaindefault=info['ql_domaindefault'])
+ info['quota messages'] = \
+ _format_quota_usage(info['ql_messages'],
+ info['uq_messages'],
+ domaindefault=info['ql_domaindefault'])
_print_info(ctx, info, _(u'Account'))
else:
info[0]['quota storage'] = _format_quota_usage(info[0]['ql_bytes'],
@@ -848,7 +852,8 @@
_(u'delete the specified catch-all destination or all '
u'of a domain\'s destinations')),
'catchallinfo': cmd('catchallinfo', 'cai', catchall_info, 'fqdn',
- _(u'show the catch-all destination(s) of the specified domain')),
+ _(u'show the catch-all destination(s) of the '
+ u'specified domain')),
# Domain commands
'domainadd': cmd('domainadd', 'da', domain_add, 'fqdn [transport]',
_(u'create a new domain')),
@@ -872,9 +877,11 @@
'listdomains': cmd('listdomains', 'ld', list_domains, '[pattern]',
_(u'list all domains or search for domains by pattern')),
'listaddresses': cmd('listaddresses', 'll', list_addresses, '[pattern]',
- _(u'list all addresses or search for addresses by pattern')),
+ _(u'list all addresses or search for addresses by '
+ u'pattern')),
'listusers': cmd('listusers', 'lu', list_users, '[pattern]',
- _(u'list all user accounts or search for accounts by pattern')),
+ _(u'list all user accounts or search for accounts by '
+ u'pattern')),
'listaliases': cmd('listaliases', 'la', list_aliases, '[pattern]',
_(u'list all aliases or search for aliases by pattern')),
'listrelocated': cmd('listrelocated', 'lr', list_relocated, '[pattern]',
@@ -990,6 +997,7 @@
txt_wrpr.subsequent_indent = old_si
txt_wrpr.initial_indent = old_ii
+
def _print_list(alist, title):
"""Print a list."""
# TP: used in e.g. 'Existing alias addresses' or 'Existing accounts'
@@ -1064,17 +1072,15 @@
def _print_address_list(which, dids, addresses, matching):
"""Print a list of (matching) addresses."""
- _trans = { TYPE_ACCOUNT : _('user accounts')
- , TYPE_ALIAS : _('aliases')
- , TYPE_RELOCATED : _('relocated users')
- , TYPE_ACCOUNT | TYPE_ALIAS
- : _('user accounts and aliases')
- , TYPE_ACCOUNT | TYPE_RELOCATED
- : _('user accounts and relocated users')
- , TYPE_ALIAS | TYPE_RELOCATED
- : _('aliases and relocated users')
- , TYPE_ACCOUNT | TYPE_ALIAS | TYPE_RELOCATED : _('addresses')
- }
+ _trans = {
+ TYPE_ACCOUNT: _('user accounts'),
+ TYPE_ALIAS: _('aliases'),
+ TYPE_RELOCATED: _('relocated users'),
+ TYPE_ACCOUNT | TYPE_ALIAS: _('user accounts and aliases'),
+ TYPE_ACCOUNT | TYPE_RELOCATED: _('user accounts and relocated users'),
+ TYPE_ALIAS | TYPE_RELOCATED: _('aliases and relocated users'),
+ TYPE_ACCOUNT | TYPE_ALIAS | TYPE_RELOCATED: _('addresses'),
+ }
try:
if matching:
title = _(u'Matching %s') % _trans[which]
@@ -1087,17 +1093,15 @@
if addresses:
if which & (which - 1) == 0:
# only one type is requested, so no type indicator
- _trans = { TYPE_ACCOUNT : ''
- , TYPE_ALIAS : ''
- , TYPE_RELOCATED : ''
- }
+ _trans = {TYPE_ACCOUNT: '', TYPE_ALIAS: '', TYPE_RELOCATED: ''}
else:
# TP: the letters 'u', 'a' and 'r' are abbreviations of user,
# alias and relocated user
- _trans = { TYPE_ACCOUNT : _('u')
- , TYPE_ALIAS : _('a')
- , TYPE_RELOCATED : _('r')
- }
+ _trans = {
+ TYPE_ACCOUNT: _('u'),
+ TYPE_ALIAS: _('a'),
+ TYPE_RELOCATED: _('r'),
+ }
for did in dids:
for addr, atype, aliasdomain in addresses[did]:
if aliasdomain:
--- a/VirtualMailManager/common.py Mon Sep 03 22:40:01 2012 +0000
+++ b/VirtualMailManager/common.py Wed Sep 05 21:30:42 2012 +0000
@@ -187,6 +187,7 @@
_version_cache[version] = version_string
return version_string
+
def format_domain_default(domaindata):
"""Format info output when the value displayed is the domain default."""
# TP: [domain default] indicates that a user's setting is the same as
@@ -218,19 +219,19 @@
type, and boolean indicating whether the address stems from an alias
domain.
"""
- if typelimit == None:
+ if typelimit is None:
typelimit = TYPE_ACCOUNT | TYPE_ALIAS | TYPE_RELOCATED
queries = []
if typelimit & TYPE_ACCOUNT:
queries.append('SELECT gid, local_part, %d AS type FROM users'
% TYPE_ACCOUNT)
if typelimit & TYPE_ALIAS:
- queries.append('SELECT DISTINCT gid, address as local_part, %d AS type '
- 'FROM alias' % TYPE_ALIAS)
+ queries.append('SELECT DISTINCT gid, address as local_part, '
+ '%d AS type FROM alias' % TYPE_ALIAS)
if typelimit & TYPE_RELOCATED:
queries.append('SELECT gid, address as local_part, %d AS type '
'FROM relocated' % TYPE_RELOCATED)
- sql = "SELECT gid, local_part || '@' || domainname AS address, "
+ sql = "SELECT gid, local_part || '@' || domainname AS address, "
sql += 'type, NOT is_primary AS from_aliasdomain FROM ('
sql += ' UNION '.join(queries)
sql += ') a JOIN domain_name USING (gid)'
@@ -241,7 +242,8 @@
if like:
match = 'LIKE'
else:
- if not pattern: continue
+ if not pattern:
+ continue
match = '='
sql += ' %s %s %s %%s' % (nextkw, field, match)
sqlargs.append(pattern)
--- a/VirtualMailManager/config.py Mon Sep 03 22:40:01 2012 +0000
+++ b/VirtualMailManager/config.py Wed Sep 05 21:30:42 2012 +0000
@@ -142,10 +142,10 @@
elif not section in self._cfg:
raise NoSectionError(section)
else:
- return ((k, self._cfg[section][k].default) \
+ return ((k, self._cfg[section][k].default)
for k in self._cfg[section].iterkeys())
# still here? Get defaults and merge defaults with configured setting
- defaults = dict((k, self._cfg[section][k].default) \
+ defaults = dict((k, self._cfg[section][k].default)
for k in self._cfg[section].iterkeys())
defaults.update(sect)
if '__name__' in defaults:
@@ -435,25 +435,25 @@
if not miss_vers:
value = self.get('misc', 'dovecot_version')
if not VERSION_RE.match(value):
- self._missing['misc'] = ['version: ' +\
+ self._missing['misc'] = ['version: ' +
_(u"Not a valid Dovecot version: '%s'") % value]
# section database
db_err = []
value = self.dget('database.module').lower()
if value not in DB_MODULES:
- db_err.append('module: ' + \
+ db_err.append('module: ' +
_(u"Unsupported database module: '%s'") % value)
if value == 'psycopg2':
value = self.dget('database.sslmode')
if value not in DB_SSL_MODES:
- db_err.append('sslmode: ' + \
+ db_err.append('sslmode: ' +
_(u"Unknown pgsql SSL mode: '%s'") % value)
if db_err:
self._missing['database'] = db_err
# section mailbox
value = self.dget('mailbox.format')
if not known_format(value):
- self._missing['mailbox'] = ['format: ' +\
+ self._missing['mailbox'] = ['format: ' +
_(u"Unsupported mailbox format: '%s'") % value]
# section domain
try:
--- a/VirtualMailManager/domain.py Mon Sep 03 22:40:01 2012 +0000
+++ b/VirtualMailManager/domain.py Wed Sep 05 21:30:42 2012 +0000
@@ -462,8 +462,8 @@
"""Returns a list with all catchall e-mail addresses of the domain."""
self._chk_state()
dbc = self._dbh.cursor()
- dbc.execute('SELECT DISTINCT destination FROM catchall WHERE gid = %s ORDER '
- 'BY destination', (self._gid,))
+ dbc.execute('SELECT DISTINCT destination FROM catchall WHERE gid = %s '
+ 'ORDER BY destination', (self._gid,))
addresses = dbc.fetchall()
dbc.close()
return addresses
--- a/VirtualMailManager/handler.py Mon Sep 03 22:40:01 2012 +0000
+++ b/VirtualMailManager/handler.py Wed Sep 05 21:30:42 2012 +0000
@@ -56,6 +56,7 @@
TYPE_RELOCATED: (_(u'a relocated user'), RELOCATED_EXISTS),
}
+
class Handler(object):
"""Wrapper class to simplify the access on all the stuff from
VirtualMailManager"""
@@ -621,7 +622,8 @@
checkp = lpattern
if len(checkp) > 0 and re.search(RE_LOCALPART, checkp):
raise VMMError(_(u"The pattern '%s' contains invalid "
- u"characters.") % pattern, LOCALPART_INVALID)
+ u"characters.") % pattern,
+ LOCALPART_INVALID)
else:
# else just match on domains
# (or should that be local part, I don't know…)
@@ -658,8 +660,8 @@
alias = self._get_alias(aliasaddress)
if not alias:
self._is_other_address(alias.address, TYPE_ALIAS)
- destinations = [DestinationEmailAddress(addr, self._dbh) \
- for addr in targetaddresses]
+ destinations = [DestinationEmailAddress(addr, self._dbh)
+ for addr in targetaddresses]
warnings = []
destinations = alias.add_destinations(destinations, warnings)
if warnings:
@@ -724,8 +726,8 @@
"""Creates a new `CatchallAlias` entry for the given *domain* with
the given *targetaddresses*."""
catchall = self._get_catchall(domain)
- destinations = [DestinationEmailAddress(addr, self._dbh) \
- for addr in targetaddresses]
+ destinations = [DestinationEmailAddress(addr, self._dbh)
+ for addr in targetaddresses]
warnings = []
destinations = catchall.add_destinations(destinations, warnings)
if warnings: