From f8a5b0b2957857723ac3c946cc41ec22344deba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sun, 1 Nov 2020 12:40:48 +0100 Subject: [PATCH] IMAP.py renamed variables This patch renames some variables to avoid warnings like: 'e' doesn't conform to snake_case naming style (invalid-name) --- offlineimap/repository/IMAP.py | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index d9f6c4a..d2f577a 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -142,10 +142,10 @@ class IMAPRepository(BaseRepository): host = self.getconf('remotehosteval') try: host = self.localeval.eval(host) - except Exception as e: + except Exception as exc: raise OfflineImapError( "remotehosteval option for repository " - "'%s' failed:\n%s" % (self, e), + "'%s' failed:\n%s" % (self, exc), OfflineImapError.ERROR.REPO, exc_info()[2]) if host: @@ -190,11 +190,11 @@ class IMAPRepository(BaseRepository): mechs = self.getconflist('auth_mechanisms', r',\s*', default) - for m in mechs: - if m not in supported: + for mech in mechs: + if mech not in supported: raise OfflineImapError("Repository %s: " % self + "unknown authentication mechanism '%s'" - % m, OfflineImapError.ERROR.REPO) + % mech, OfflineImapError.ERROR.REPO) self.ui.debug('imap', "Using authentication mechanisms %s" % mechs) return mechs @@ -572,9 +572,10 @@ class IMAPRepository(BaseRepository): # 3. Read password from file specified in Repository 'remotepassfile'. passfile = self.getconf('remotepassfile', None) if passfile is not None: - fd = open(os.path.expanduser(passfile), 'r', encoding='utf-8') - password = fd.readline().strip() - fd.close() + file_desc = open(os.path.expanduser(passfile), 'r', + encoding='utf-8') + password = file_desc.readline().strip() + file_desc.close() return password.encode('UTF-8') # 4. Read password from ~/.netrc. try: @@ -647,16 +648,16 @@ class IMAPRepository(BaseRepository): finally: self.imapserver.releaseconnection(imapobj) - for s in listresult: - if s is None or (isinstance(s, str) and s == ''): + for fldr in listresult: + if fldr is None or (isinstance(fldr, str) and fldr == ''): # Bug in imaplib: empty strings in results from # literals. TODO: still relevant? continue try: - flags, delim, name = imaputil.imapsplit(s) + flags, delim, name = imaputil.imapsplit(fldr) except ValueError: self.ui.error( - "could not correctly parse server response; got: %s" % s) + "could not correctly parse server response; got: %s" % fldr) raise flaglist = [x.lower() for x in imaputil.flagsplit(flags)] if '\\noselect' in flaglist: @@ -671,11 +672,11 @@ class IMAPRepository(BaseRepository): try: imapobj.select(imaputil.utf8_IMAP(foldername), readonly=True) - except OfflineImapError as e: + except OfflineImapError as exc: # couldn't select this folderinclude, so ignore folder. - if e.severity > OfflineImapError.ERROR.FOLDER: + if exc.severity > OfflineImapError.ERROR.FOLDER: raise - self.ui.error(e, exc_info()[2], + self.ui.error(exc, exc_info()[2], 'Invalid folderinclude:') continue retval.append(self.getfoldertype()( @@ -757,8 +758,8 @@ class IMAPRepository(BaseRepository): for folder_path in folder_paths: try: self.makefolder_single(folder_path) - except OfflineImapError as e: - if '[ALREADYEXISTS]' not in e.reason: + except OfflineImapError as exc: + if '[ALREADYEXISTS]' not in exc.reason: raise def makefolder_single(self, foldername):