summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-03-05 10:22:52 +0100
committerAnton Khirnov <anton@khirnov.net>2020-03-05 10:24:12 +0100
commitd4b8a1ccacda08c29ad93cdb344c6fc1debcac30 (patch)
tree31b5ec80e45071b092feda3acf9ab233cc38f59c /alot
parent8a6ce8a29d8d61385c4222b9018b936e658cfb24 (diff)
db/utils: move formataddr to helper
It has no relation to database, so helper seems like a better place for it. As there is nothing left in db/utils, it is removed.
Diffstat (limited to 'alot')
-rw-r--r--alot/commands/thread.py2
-rw-r--r--alot/completion/abooks.py2
-rw-r--r--alot/completion/accounts.py2
-rw-r--r--alot/db/message.py1
-rw-r--r--alot/db/utils.py28
-rw-r--r--alot/helper.py13
6 files changed, 16 insertions, 32 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index c5e2747e..83aef9a0 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -26,11 +26,11 @@ from .common import RetagPromptCommand
from .envelope import SendCommand
from ..completion.contacts import ContactsCompleter
from ..completion.path import PathCompleter
-from ..db.utils import formataddr
from ..db.envelope import Envelope
from ..db.attachment import Attachment
from ..db.errors import DatabaseROError
from ..settings.const import settings
+from ..helper import formataddr
from ..helper import parse_mailcap_nametemplate
from ..helper import split_commandstring
from ..utils import argparse as cargparse
diff --git a/alot/completion/abooks.py b/alot/completion/abooks.py
index bc2fa20b..c5bfe3e8 100644
--- a/alot/completion/abooks.py
+++ b/alot/completion/abooks.py
@@ -4,7 +4,7 @@
from .completer import Completer
from ..addressbook import AddressbookError
-from ..db.utils import formataddr
+from ..helper import formataddr
from ..errors import CompletionError
diff --git a/alot/completion/accounts.py b/alot/completion/accounts.py
index 20dbcfa6..3250a7c9 100644
--- a/alot/completion/accounts.py
+++ b/alot/completion/accounts.py
@@ -3,7 +3,7 @@
# For further details see the COPYING file
from alot.settings.const import settings
-from alot.db.utils import formataddr
+from alot.helper import formataddr
from .stringlist import StringlistCompleter
diff --git a/alot/db/message.py b/alot/db/message.py
index 6523f18b..7263c6fe 100644
--- a/alot/db/message.py
+++ b/alot/db/message.py
@@ -11,7 +11,6 @@ from datetime import datetime
from notmuch import NullPointerError
-from . import utils
from .attachment import Attachment
from .. import crypto
from .. import helper
diff --git a/alot/db/utils.py b/alot/db/utils.py
deleted file mode 100644
index 99684afd..00000000
--- a/alot/db/utils.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# encoding=utf-8
-# Copyright (C) 2011-2012 Patrick Totzke <patricktotzke@gmail.com>
-# Copyright © 2017 Dylan Baker <dylan@pnwbakers.com>
-# This file is released under the GNU GPL, version 3 or a later revision.
-# For further details see the COPYING file
-import os
-import email
-import email.charset as charset
-import email.policy
-import email.utils
-import logging
-
-from ..settings.const import settings
-
-charset.add_charset('utf-8', charset.QP, charset.QP, 'utf-8')
-
-def formataddr(pair):
- """ this is the inverse of email.utils.parseaddr:
- other than email.utils.formataddr, this
- - *will not* re-encode unicode strings, and
- - *will* re-introduce quotes around real names containing commas
- """
- name, address = pair
- if not name:
- return address
- elif ',' in name:
- name = "\"" + name + "\""
- return "{0} <{1}>".format(name, address)
diff --git a/alot/helper.py b/alot/helper.py
index aab3242e..1d541d76 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -602,3 +602,16 @@ def get_xdg_env(env_name, fallback):
""" Used for XDG_* env variables to return fallback if unset *or* empty """
env = os.environ.get(env_name)
return env if env else fallback
+
+def formataddr(pair):
+ """ this is the inverse of email.utils.parseaddr:
+ other than email.utils.formataddr, this
+ - *will not* re-encode unicode strings, and
+ - *will* re-introduce quotes around real names containing commas
+ """
+ name, address = pair
+ if not name:
+ return address
+ elif ',' in name:
+ name = "\"" + name + "\""
+ return "{0} <{1}>".format(name, address)