From bfff00e395f74d2aae05cf94624cc6287349f11b Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Mon, 7 Apr 2008 20:16:29 +0000 Subject: [PATCH] Code structuring: made a separate group of IMAP functions. No code changes, just moved functions around. --- archivemail.py | 127 ++++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 60 deletions(-) diff --git a/archivemail.py b/archivemail.py index 55c3934..45a0cdc 100755 --- a/archivemail.py +++ b/archivemail.py @@ -1482,6 +1482,73 @@ def _archive_imap(mailbox_name, final_archive_name): if not options.quiet: stats.display() + +############### IMAP functions ############### + + +def parse_imap_url(url): + """Parse IMAP URL and return username, password (if appliciable), servername + and foldername.""" + + def split_qstr(string, delim): + """Split string once at delim, keeping quoted substring intact. + Strip and unescape quotes where necessary.""" + rm = re.match(r'"(.+?(?"."|NIL)', response[0]) + if not m: + unexpected_error("imap_getdelim(): cannot parse '%s'" % response[0]) + delim = m.group('delim').strip('"') + vprint("Found mailbox hierarchy delimiter: '%s'" % delim) + if delim == "NIL": + return None + return delim + + ############### misc functions ############### @@ -1543,66 +1610,6 @@ def nice_size_str(size): if kb >= 1.0: return str(round(kb)) + 'kB' return str(size) + 'B' -def parse_imap_url(url): - """Parse IMAP URL and return username, password (if appliciable), servername - and foldername.""" - - def split_qstr(string, delim): - """Split string once at delim, keeping quoted substring intact. - Strip and unescape quotes where necessary.""" - rm = re.match(r'"(.+?(?"."|NIL)', response[0]) - if not m: - unexpected_error("imap_getdelim(): cannot parse '%s'" % response[0]) - delim = m.group('delim').strip('"') - vprint("Found mailbox hierarchy delimiter: '%s'" % delim) - if delim == "NIL": - return None - return delim def get_filename(msg): """If the given rfc822.Message can be identified with a file (no mbox),