Skip to content

Commit

Permalink
fix: use namespace for separator
Browse files Browse the repository at this point in the history
  • Loading branch information
gaige committed Sep 2, 2024
1 parent 17d9599 commit 23996fc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
13 changes: 9 additions & 4 deletions parsedmarc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,10 +1416,15 @@ def get_dmarc_reports_from_mailbox(connection: MailboxConnection,
aggregate_report_msg_uids = []
forensic_report_msg_uids = []
smtp_tls_msg_uids = []
aggregate_reports_folder = "{0}/Aggregate".format(archive_folder)
forensic_reports_folder = "{0}/Forensic".format(archive_folder)
smtp_tls_reports_folder = "{0}/SMTP-TLS".format(archive_folder)
invalid_reports_folder = "{0}/Invalid".format(archive_folder)
folder_separator = connection.get_folder_separator()
aggregate_reports_folder = "{0}{1}Aggregate".format(archive_folder,

Check warning on line 1420 in parsedmarc/__init__.py

View check run for this annotation

Codecov / codecov/patch

parsedmarc/__init__.py#L1419-L1420

Added lines #L1419 - L1420 were not covered by tests
folder_separator)
forensic_reports_folder = "{0}{1}Forensic".format(archive_folder,

Check warning on line 1422 in parsedmarc/__init__.py

View check run for this annotation

Codecov / codecov/patch

parsedmarc/__init__.py#L1422

Added line #L1422 was not covered by tests
folder_separator)
smtp_tls_reports_folder = "{0}{1}SMTP-TLS".format(archive_folder,

Check warning on line 1424 in parsedmarc/__init__.py

View check run for this annotation

Codecov / codecov/patch

parsedmarc/__init__.py#L1424

Added line #L1424 was not covered by tests
folder_separator)
invalid_reports_folder = "{0}{1}Invalid".format(archive_folder,

Check warning on line 1426 in parsedmarc/__init__.py

View check run for this annotation

Codecov / codecov/patch

parsedmarc/__init__.py#L1426

Added line #L1426 was not covered by tests
folder_separator)

if results:
aggregate_reports = results["aggregate_reports"].copy()
Expand Down
8 changes: 8 additions & 0 deletions parsedmarc/mail/imap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ def __init__(self,
timeout=timeout,
max_retries=max_retries)

def get_folder_separator(self):
try:
namespaces = self._client.namespace()
personal = namespaces.personal[0]
return personal[1]
except (IndexError, NameError):
return '/'

Check warning on line 35 in parsedmarc/mail/imap.py

View check run for this annotation

Codecov / codecov/patch

parsedmarc/mail/imap.py#L30-L35

Added lines #L30 - L35 were not covered by tests

def create_folder(self, folder_name: str):
self._client.create_folder(folder_name)

Expand Down
3 changes: 3 additions & 0 deletions parsedmarc/mail/mailbox_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class MailboxConnection(ABC):
"""
Interface for a mailbox connection
"""
def get_folder_separator(self):
return "/"

Check warning on line 10 in parsedmarc/mail/mailbox_connection.py

View check run for this annotation

Codecov / codecov/patch

parsedmarc/mail/mailbox_connection.py#L10

Added line #L10 was not covered by tests

def create_folder(self, folder_name: str):
raise NotImplementedError

Expand Down

0 comments on commit 23996fc

Please sign in to comment.