summaryrefslogtreecommitdiff
path: root/alot/account.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-02-19 14:50:46 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-02-19 14:50:46 +0000
commit0b93dad9845a9a55821e1fdbb3ccafb97f265127 (patch)
treeb8af57b4b051995f362ac692a1b571bcad861339 /alot/account.py
parentc09ee71c43e15a21eebcf971516a42723259ee4e (diff)
remove unused AccountManager class
Diffstat (limited to 'alot/account.py')
-rw-r--r--alot/account.py118
1 files changed, 0 insertions, 118 deletions
diff --git a/alot/account.py b/alot/account.py
index 6caa30ac..8ea22760 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -194,124 +194,6 @@ class SendmailAccount(Account):
return d
-class AccountManager(object):
- """
- creates and organizes multiple :class:`Accounts <Account>` that were
- defined in the "account" sections of a given
- :class:`~alot.settings.AlotConfigParser`.
- """
- allowed = ['realname',
- 'address',
- 'aliases',
- 'gpg_key',
- 'signature',
- 'signature_filename',
- 'signature_as_attachment',
- 'type',
- 'sendmail_command',
- 'abook_command',
- 'abook_regexp',
- 'sent_box',
- 'sent_tags',
- 'draft_box',
- 'draft_tags']
- manditory = ['realname', 'address']
- parse_lists = ['sent_tags', 'draft_tags']
- accountmap = {}
- accounts = []
- ordered_addresses = []
-
- def __init__(self, config):
- """
- :param config: the config object to read account information from
- :type config: :class:`~alot.settings.AlotConfigParser`.
- """
- sections = config.sections()
- accountsections = filter(lambda s: s.startswith('account '), sections)
- for s in accountsections:
- options = filter(lambda x: x in self.allowed, config.options(s))
-
- args = {}
- if 'abook_command' in options:
- cmd = config.get(s, 'abook_command').encode('ascii',
- errors='ignore')
- options.remove('abook_command')
- if 'abook_regexp' in options:
- regexp = config.get(s, 'abook_regexp')
- options.remove('abook_regexp')
- else:
- regexp = None # will use default in constructor
- args['abook'] = MatchSdtoutAddressbook(cmd, match=regexp)
-
- if 'signature_as_attachment' in options:
- value = config.getboolean(s, 'signature_as_attachment')
- args['signature_as_attachment'] = value
- options.remove('signature_as_attachment')
-
- to_set = self.manditory
- for o in options:
- if o not in self.parse_lists:
- args[o] = config.get(s, o)
- else:
- args[o] = config.getstringlist(s, o)
- if o in to_set:
- to_set.remove(o) # removes obligation
- if not to_set: # all manditory fields were present
- sender_type = args.pop('type', 'sendmail')
- if sender_type == 'sendmail':
- cmd = args.pop('sendmail_command', 'sendmail')
- newacc = (SendmailAccount(cmd, **args))
- self.accountmap[newacc.address] = newacc
- self.accounts.append(newacc)
- for alias in newacc.aliases:
- self.accountmap[alias] = newacc
- else:
- logging.info('account section %s lacks %s' % (s, to_set))
-
- def get_accounts(self):
- """
- returns known accounts
-
- :rtype: list of :class:`Account`
- """
- return self.accounts
-
- def get_account_by_address(self, address):
- """
- returns :class:`Account` for a given email address (str)
-
- :param address: address to look up
- :type address: string
- :rtype: :class:`Account` or None
- """
-
- for myad in self.get_addresses():
- if myad in address:
- return self.accountmap[myad]
- return None
-
- def get_main_addresses(self):
- """returns addresses of known accounts without its aliases"""
- return [a.address for a in self.accounts]
-
- def get_addresses(self):
- """returns addresses of known accounts including all their aliases"""
- return self.accountmap.keys()
-
- def get_addressbooks(self, order=[], append_remaining=True):
- """returns list of all defined :class:`AddressBook` objects"""
- abooks = []
- for a in order:
- if a:
- if a.abook:
- abooks.append(a.abook)
- if append_remaining:
- for a in self.accounts:
- if a.abook and a.abook not in abooks:
- abooks.append(a.abook)
- return abooks
-
-
class AddressBook(object):
"""can look up email addresses and realnames for contacts.