-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
76 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[run] | ||
source = src/modules/ | ||
|
||
[report] | ||
omit = mailparser/version.py | ||
|
||
exclude_lines = | ||
pragma: no cover | ||
except OSError | ||
def __repr__ | ||
raise AssertionError | ||
raise NotImplementedError | ||
if __name__ == .__main__.: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,4 +84,6 @@ | |
"body", | ||
"date", | ||
"received", | ||
"to_domains"]) | ||
"timezone", | ||
"to_domains", | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,9 +282,15 @@ def receiveds_parsing(receiveds): | |
|
||
|
||
def convert_mail_date(date): | ||
log.debug("Date to parse: {!r}".format(date)) | ||
d = email.utils.parsedate_tz(date) | ||
log.debug("Date parsed: {!r}".format(d)) | ||
t = email.utils.mktime_tz(d) | ||
return datetime.datetime.utcfromtimestamp(t) | ||
log.debug("Date parsed in timestamp: {!r}".format(t)) | ||
date_utc = datetime.datetime.utcfromtimestamp(t) | ||
timezone = d[9] / 3600 if d[9] else 0 | ||
timezone = "{:+.0f}".format(timezone) | ||
return date_utc, timezone | ||
|
||
|
||
def receiveds_not_parsed(receiveds): | ||
|
@@ -342,7 +348,7 @@ def receiveds_format(receiveds): | |
# "for <[email protected]>; Tue, 7 Mar 2017 14:29:24 -0800", | ||
i["date"] = i["date"].split(";")[-1] | ||
try: | ||
j["date_utc"] = convert_mail_date(i["date"]) | ||
j["date_utc"], _ = convert_mail_date(i["date"]) | ||
except TypeError: | ||
j["date_utc"] = None | ||
|
||
|
@@ -418,22 +424,22 @@ def get_mail_keys(message): | |
return all_parts | ||
|
||
|
||
def safe_print(data): | ||
def safe_print(data): # pragma: no cover | ||
try: | ||
print(data) | ||
except UnicodeEncodeError: | ||
print(data.encode('utf-8')) | ||
|
||
|
||
def print_mail_fingerprints(data): | ||
def print_mail_fingerprints(data): # pragma: no cover | ||
md5, sha1, sha256, sha512 = fingerprints(data) | ||
print("md5:\t{}".format(md5)) | ||
print("sha1:\t{}".format(sha1)) | ||
print("sha256:\t{}".format(sha256)) | ||
print("sha512:\t{}".format(sha512)) | ||
|
||
|
||
def print_attachments(attachments, flag_hash): | ||
def print_attachments(attachments, flag_hash): # pragma: no cover | ||
if flag_hash: | ||
for i in attachments: | ||
if i.get("content_transfer_encoding") == "base64": | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters