• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

APSL / django-yubin / 4677611962

pending completion
4677611962

push

github

Dani Sastre
support Django 4.2

152 of 203 branches covered (74.88%)

563 of 739 relevant lines covered (76.18%)

3.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.62
/django_yubin/mailparser_utils.py
1
import base64
4✔
2
import hashlib
4✔
3

4

5
def get_content(attachment):
4✔
6
    return base64.b64decode(attachment['payload'])
×
7

8

9
def get_signature(attachment):
4✔
10
    return hashlib.md5(get_content(attachment)).hexdigest()
×
11

12

13
def get_attachment(mailparser, signature):
4✔
14
    """
15
    Given a msg returns the attachment with the given signature.
16
    """
17
    for attachment in mailparser.attachments:
×
18
        if get_signature(attachment) == signature:
×
19
            return attachment
×
20
    return None
×
21

22

23
def get_address(mailparse_addresses):
4✔
24
    """
25
    Returns 'Foo Bar <foo.bar@baz.com>' or 'foo.bar@baz.com'.
26
    """
27
    addresses = get_addresses(mailparse_addresses)
4✔
28
    return addresses[0] if addresses else None
4✔
29

30

31
def get_addresses(mailparse_addresses):
4✔
32
    """
33
    Returns ['Foo Bar <foo.bar@baz.com>', ...] or ['foo.bar@baz.com', ...].
34
    """
35
    addresses = []
4✔
36
    for address_parts in mailparse_addresses:
4✔
37
        if not address_parts[0] or '@' in address_parts[0]:
4!
38
            addresses.append(address_parts[1])
4✔
39
        else:
40
            addresses.append('{} <{}>'.format(address_parts[0], address_parts[1]))
×
41
    return addresses
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc