From c5468ae599e9f008bedb06250537a89a11b960e9 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sun, 5 Feb 2012 11:51:02 +0100 Subject: [PATCH] raise Exception, "text" --> raise Exception("text") To have the code work in python3, we need to convert all occurences of raise Exception, "text" to be proper functions. This style also adheres to PEP8. Signed-off-by: Sebastian Spaeth --- offlineimap/folder/IMAP.py | 4 +++- offlineimap/imaputil.py | 2 +- offlineimap/repository/__init__.py | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 9cdf752..17364d3 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -328,7 +328,9 @@ class IMAPFolder(BaseFolder): self.ui.debug('imap', 'savemessage_searchforheader: matchinguids now ' + \ repr(matchinguids)) if len(matchinguids) != 1 or matchinguids[0] == None: - raise ValueError, "While attempting to find UID for message with header %s, got wrong-sized matchinguids of %s" % (headername, str(matchinguids)) + raise ValueError("While attempting to find UID for message with " + "header %s, got wrong-sized matchinguids of %s" %\ + (headername, str(matchinguids))) matchinguids.sort() return long(matchinguids[0]) diff --git a/offlineimap/imaputil.py b/offlineimap/imaputil.py index 3955683..f9b021c 100644 --- a/offlineimap/imaputil.py +++ b/offlineimap/imaputil.py @@ -58,7 +58,7 @@ def flagsplit(string): ['FLAGS,'(\\Seen Old)','UID', '4807'] """ if string[0] != '(' or string[-1] != ')': - raise ValueError, "Passed string '%s' is not a flag list" % string + raise ValueError("Passed string '%s' is not a flag list" % string) return imapsplit(string[1:-1]) def options2hash(list): diff --git a/offlineimap/repository/__init__.py b/offlineimap/repository/__init__.py index c63f6db..0059bdf 100644 --- a/offlineimap/repository/__init__.py +++ b/offlineimap/repository/__init__.py @@ -47,15 +47,15 @@ class Repository(object): return LocalStatusRepository(name, account) else: - raise ValueError, "Request type %s not supported" % reqtype + raise ValueError("Request type %s not supported" % reqtype) config = account.getconfig() repostype = config.get('Repository ' + name, 'type').strip() try: repo = typemap[repostype] except KeyError: - raise Exception, "'%s' repository not supported for %s repositories."%\ - (repostype, reqtype) + raise ValueError("'%s' repository not supported for %s repositories" + "." % (repostype, reqtype)) return repo(name, account)