/usr/lib/python3/dist-packages/afew/utils.py is in afew 1.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # -*- coding: utf-8 -*-
# SPDX-License-Identifier: ISC
# Copyright (c) Justus Winter <4winter@informatik.uni-hamburg.de>
from __future__ import print_function, absolute_import, unicode_literals
import codecs
import re
import sys
import email
from datetime import datetime
def filter_compat(*args):
r'''
Compatibility wrapper for filter builtin.
The semantic of the filter builtin has been changed in
python3.x. This is a temporary workaround to support both python
versions in one code base.
'''
return list(filter(*args))
def get_message_summary(message):
when = datetime.fromtimestamp(float(message.get_date()))
sender = get_sender(message)
subject = message.get_header('Subject')
return '[{date}] {sender} | {subject}'.format(date=when, sender=sender,
subject=subject)
def get_sender(message):
sender = message.get_header('From')
name_match = re.search(r'(.+) <.+@.+\..+>', sender)
if name_match:
sender = name_match.group(1)
return sender
|