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 0202d21
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
16 changes: 12 additions & 4 deletions parsedmarc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,10 +1416,18 @@ 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)
aggregate_reports_folder = "{0}{1}Aggregate".format(archive_folder,

Check warning on line 1419 in parsedmarc/__init__.py

View check run for this annotation

Codecov / codecov/patch

parsedmarc/__init__.py#L1419

Added line #L1419 was not covered by tests
connection.
get_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
connection.
get_folder_separator())
smtp_tls_reports_folder = "{0}{1}SMTP-TLS".format(archive_folder,

Check warning on line 1425 in parsedmarc/__init__.py

View check run for this annotation

Codecov / codecov/patch

parsedmarc/__init__.py#L1425

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

Check warning on line 1428 in parsedmarc/__init__.py

View check run for this annotation

Codecov / codecov/patch

parsedmarc/__init__.py#L1428

Added line #L1428 was not covered by tests
connection.
get_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 0202d21

Please sign in to comment.