IMAP.py renamed variables

This patch renames some variables to avoid warnings like:

'e' doesn't conform to snake_case naming style (invalid-name)
This commit is contained in:
Rodolfo García Peñas (kix) 2020-11-01 12:40:48 +01:00
parent 316fcfbbee
commit f8a5b0b295

View File

@ -142,10 +142,10 @@ class IMAPRepository(BaseRepository):
host = self.getconf('remotehosteval') host = self.getconf('remotehosteval')
try: try:
host = self.localeval.eval(host) host = self.localeval.eval(host)
except Exception as e: except Exception as exc:
raise OfflineImapError( raise OfflineImapError(
"remotehosteval option for repository " "remotehosteval option for repository "
"'%s' failed:\n%s" % (self, e), "'%s' failed:\n%s" % (self, exc),
OfflineImapError.ERROR.REPO, OfflineImapError.ERROR.REPO,
exc_info()[2]) exc_info()[2])
if host: if host:
@ -190,11 +190,11 @@ class IMAPRepository(BaseRepository):
mechs = self.getconflist('auth_mechanisms', r',\s*', mechs = self.getconflist('auth_mechanisms', r',\s*',
default) default)
for m in mechs: for mech in mechs:
if m not in supported: if mech not in supported:
raise OfflineImapError("Repository %s: " % self + raise OfflineImapError("Repository %s: " % self +
"unknown authentication mechanism '%s'" "unknown authentication mechanism '%s'"
% m, OfflineImapError.ERROR.REPO) % mech, OfflineImapError.ERROR.REPO)
self.ui.debug('imap', "Using authentication mechanisms %s" % mechs) self.ui.debug('imap', "Using authentication mechanisms %s" % mechs)
return mechs return mechs
@ -572,9 +572,10 @@ class IMAPRepository(BaseRepository):
# 3. Read password from file specified in Repository 'remotepassfile'. # 3. Read password from file specified in Repository 'remotepassfile'.
passfile = self.getconf('remotepassfile', None) passfile = self.getconf('remotepassfile', None)
if passfile is not None: if passfile is not None:
fd = open(os.path.expanduser(passfile), 'r', encoding='utf-8') file_desc = open(os.path.expanduser(passfile), 'r',
password = fd.readline().strip() encoding='utf-8')
fd.close() password = file_desc.readline().strip()
file_desc.close()
return password.encode('UTF-8') return password.encode('UTF-8')
# 4. Read password from ~/.netrc. # 4. Read password from ~/.netrc.
try: try:
@ -647,16 +648,16 @@ class IMAPRepository(BaseRepository):
finally: finally:
self.imapserver.releaseconnection(imapobj) self.imapserver.releaseconnection(imapobj)
for s in listresult: for fldr in listresult:
if s is None or (isinstance(s, str) and s == ''): if fldr is None or (isinstance(fldr, str) and fldr == ''):
# Bug in imaplib: empty strings in results from # Bug in imaplib: empty strings in results from
# literals. TODO: still relevant? # literals. TODO: still relevant?
continue continue
try: try:
flags, delim, name = imaputil.imapsplit(s) flags, delim, name = imaputil.imapsplit(fldr)
except ValueError: except ValueError:
self.ui.error( self.ui.error(
"could not correctly parse server response; got: %s" % s) "could not correctly parse server response; got: %s" % fldr)
raise raise
flaglist = [x.lower() for x in imaputil.flagsplit(flags)] flaglist = [x.lower() for x in imaputil.flagsplit(flags)]
if '\\noselect' in flaglist: if '\\noselect' in flaglist:
@ -671,11 +672,11 @@ class IMAPRepository(BaseRepository):
try: try:
imapobj.select(imaputil.utf8_IMAP(foldername), imapobj.select(imaputil.utf8_IMAP(foldername),
readonly=True) readonly=True)
except OfflineImapError as e: except OfflineImapError as exc:
# couldn't select this folderinclude, so ignore folder. # couldn't select this folderinclude, so ignore folder.
if e.severity > OfflineImapError.ERROR.FOLDER: if exc.severity > OfflineImapError.ERROR.FOLDER:
raise raise
self.ui.error(e, exc_info()[2], self.ui.error(exc, exc_info()[2],
'Invalid folderinclude:') 'Invalid folderinclude:')
continue continue
retval.append(self.getfoldertype()( retval.append(self.getfoldertype()(
@ -757,8 +758,8 @@ class IMAPRepository(BaseRepository):
for folder_path in folder_paths: for folder_path in folder_paths:
try: try:
self.makefolder_single(folder_path) self.makefolder_single(folder_path)
except OfflineImapError as e: except OfflineImapError as exc:
if '[ALREADYEXISTS]' not in e.reason: if '[ALREADYEXISTS]' not in exc.reason:
raise raise
def makefolder_single(self, foldername): def makefolder_single(self, foldername):