summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-01-07 14:23:25 -0400
committerKali Kaneko <kali@leap.se>2014-01-08 20:40:42 -0400
commitac87c723f493737941246947b0833394bb186836 (patch)
tree070f9b0951d019e578f1458ef7a6940aa264a845
parentfa62586155db141b9da3e7160343b6546ab384e2 (diff)
move utility to its own
-rw-r--r--mail/src/leap/mail/imap/messages.py11
-rw-r--r--mail/src/leap/mail/utils.py29
2 files changed, 30 insertions, 10 deletions
diff --git a/mail/src/leap/mail/imap/messages.py b/mail/src/leap/mail/imap/messages.py
index 80411f94..bfe913c4 100644
--- a/mail/src/leap/mail/imap/messages.py
+++ b/mail/src/leap/mail/imap/messages.py
@@ -33,6 +33,7 @@ from zope.proxy import sameProxiedObjects
from leap.common.check import leap_assert, leap_assert_type
from leap.common.decorators import memoized_method
from leap.common.mail import get_email_charset
+from leap.mail.utils import first
from leap.mail.decorators import deferred
from leap.mail.imap.index import IndexedDB
from leap.mail.imap.fields import fields, WithMsgFields
@@ -42,16 +43,6 @@ from leap.mail.messageflow import IMessageConsumer, MessageProducer
logger = logging.getLogger(__name__)
-def first(things):
- """
- Return the head of a collection.
- """
- try:
- return things[0]
- except (IndexError, TypeError):
- return None
-
-
class MessageBody(object):
"""
IMessagePart implementor for the main
diff --git a/mail/src/leap/mail/utils.py b/mail/src/leap/mail/utils.py
new file mode 100644
index 00000000..2480efc8
--- /dev/null
+++ b/mail/src/leap/mail/utils.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# utils.py
+# Copyright (C) 2013 LEAP
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Small utilities.
+"""
+
+
+def first(things):
+ """
+ Return the head of a collection.
+ """
+ try:
+ return things[0]
+ except (IndexError, TypeError):
+ return None