From 39e4c22ecc5bd89a127b1ce148b6e00ba70e9080 Mon Sep 17 00:00:00 2001 From: Sean Whalen <44679+seanthegeek@users.noreply.github.com> Date: Sat, 2 Nov 2024 10:23:23 -0400 Subject: [PATCH 1/4] Fix syntax --- parsedmarc/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index b9d5eca4..c27320e1 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -1439,14 +1439,14 @@ def get_dmarc_reports_from_mailbox(connection: MailboxConnection, _since = 1440 # default one day if re.match(r'\d+[mhd]$', since): s = re.split(r'(\d+)', since) - if s[2] == 'm': - _since = int(s[1]) - elif s[2] == 'h': - _since = int(s[1])*60 - elif s[2] == 'd': - _since = int(s[1])*60*24 - elif s[2] == 'w': - _since = int(s[1])*60*24*7 + if s[2] == 'm': + _since = int(s[1]) + elif s[2] == 'h': + _since = int(s[1])*60 + elif s[2] == 'd': + _since = int(s[1])*60*24 + elif s[2] == 'w': + _since = int(s[1])*60*24*7 else: logger.warning("Incorrect format for \'since\' option. \ Provided value:{0}, Expected values:(5m|3h|2d|1w). \ From be38e83761a17bbfaa22c25ec0f6abedf64b7653 Mon Sep 17 00:00:00 2001 From: Sean Whalen <44679+seanthegeek@users.noreply.github.com> Date: Sat, 2 Nov 2024 10:28:11 -0400 Subject: [PATCH 2/4] Code cleanup --- parsedmarc/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index c27320e1..d8d64dbd 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -1439,13 +1439,13 @@ def get_dmarc_reports_from_mailbox(connection: MailboxConnection, _since = 1440 # default one day if re.match(r'\d+[mhd]$', since): s = re.split(r'(\d+)', since) - if s[2] == 'm': + if s[2] == 'm': _since = int(s[1]) - elif s[2] == 'h': + elif s[2] == 'h': _since = int(s[1])*60 - elif s[2] == 'd': + elif s[2] == 'd': _since = int(s[1])*60*24 - elif s[2] == 'w': + elif s[2] == 'w': _since = int(s[1])*60*24*7 else: logger.warning("Incorrect format for \'since\' option. \ From 6d467c93f925a9c558072b4934d7a61b74136769 Mon Sep 17 00:00:00 2001 From: Sean Whalen <44679+seanthegeek@users.noreply.github.com> Date: Sat, 2 Nov 2024 10:35:22 -0400 Subject: [PATCH 3/4] Update __init__.py Add reference to https://www.rfc-editor.org/rfc/rfc3501#page-52 --- parsedmarc/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index d8d64dbd..a861a1e8 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -1450,7 +1450,9 @@ def get_dmarc_reports_from_mailbox(connection: MailboxConnection, else: logger.warning("Incorrect format for \'since\' option. \ Provided value:{0}, Expected values:(5m|3h|2d|1w). \ - Ignoring option, fetching messages for last 24hrs" + Ignoring option, fetching messages for last 24hrs" \ + "SMTP does not support a time or timezone in since." + "See https://www.rfc-editor.org/rfc/rfc3501#page-52" .format(since)) if isinstance(connection, IMAPConnection): From 7ba433cddba60a29e5032cb32157c62c72870c60 Mon Sep 17 00:00:00 2001 From: Sean Whalen <44679+seanthegeek@users.noreply.github.com> Date: Sat, 2 Nov 2024 10:39:05 -0400 Subject: [PATCH 4/4] Fix code style --- parsedmarc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index a861a1e8..2b4e63c2 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -1451,7 +1451,7 @@ def get_dmarc_reports_from_mailbox(connection: MailboxConnection, logger.warning("Incorrect format for \'since\' option. \ Provided value:{0}, Expected values:(5m|3h|2d|1w). \ Ignoring option, fetching messages for last 24hrs" \ - "SMTP does not support a time or timezone in since." + "SMTP does not support a time or timezone in since." \ "See https://www.rfc-editor.org/rfc/rfc3501#page-52" .format(since))