mirror of
https://github.com/pulb/mailnag.git
synced 2026-05-07 01:07:46 +02:00
Parse folders via regex. Fixes #127
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
# MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
import re
|
||||
import poplib
|
||||
import logging
|
||||
import Mailnag.common.imaplib2 as imaplib
|
||||
@@ -105,22 +106,14 @@ class Account:
|
||||
# conn.close() # allowed in SELECTED state only
|
||||
conn.logout()
|
||||
|
||||
separators = [ ' "/" ', ' "." ' ]
|
||||
for d in data:
|
||||
folder = ''
|
||||
for s in separators:
|
||||
if s in d:
|
||||
folder = d.split(s)[-1]
|
||||
break
|
||||
|
||||
if len(folder) == 0:
|
||||
match = re.match('.+\s+("."|"?NIL"?)\s+"?([^".]+)"?$', d)
|
||||
|
||||
if match == None:
|
||||
logging.warning("Folder format not supported.")
|
||||
break
|
||||
|
||||
if (folder[0] == '"') and (folder[-1] == '"'):
|
||||
folder = folder[1:-1]
|
||||
|
||||
lst.append(folder)
|
||||
else:
|
||||
folder = match.group(2)
|
||||
lst.append(folder)
|
||||
|
||||
return lst
|
||||
|
||||
|
||||
Reference in New Issue
Block a user