Reformat offlineimap/folder/UIDMaps.py

Add some spaces, remove lines,... now format is better (lintian).
This commit is contained in:
Rodolfo García Peñas (kix) 2020-08-29 19:48:04 +02:00
parent eafd9eb51d
commit 3a1b25c204

View File

@ -57,8 +57,8 @@ class MappedIMAPFolder(IMAPFolder):
def _loadmaps(self): def _loadmaps(self):
mapfilename = self._getmapfilename() mapfilename = self._getmapfilename()
mapfilenametmp = "%s.tmp"% mapfilename mapfilenametmp = "%s.tmp" % mapfilename
mapfilenamelock = "%s.lock"% mapfilename mapfilenamelock = "%s.lock" % mapfilename
with self.maplock and open(mapfilenamelock, 'w') as mapfilelock: with self.maplock and open(mapfilenamelock, 'w') as mapfilelock:
try: try:
fnctl.lockf(mapfilelock, fnctl.LOCK_EX) # Blocks until acquired. fnctl.lockf(mapfilelock, fnctl.LOCK_EX) # Blocks until acquired.
@ -83,7 +83,7 @@ class MappedIMAPFolder(IMAPFolder):
except ValueError: except ValueError:
six.reraise(Exception, six.reraise(Exception,
Exception( Exception(
"Corrupt line '%s' in UID mapping file '%s'"% "Corrupt line '%s' in UID mapping file '%s'" %
(line, mapfilename)), (line, mapfilename)),
exc_info()[2]) exc_info()[2])
(str1, str2) = line.split(':') (str1, str2) = line.split(':')
@ -99,8 +99,8 @@ class MappedIMAPFolder(IMAPFolder):
mapfilename = self._getmapfilename() mapfilename = self._getmapfilename()
# Do not use the map file directly to prevent from leaving it truncated. # Do not use the map file directly to prevent from leaving it truncated.
mapfilenametmp = "%s.tmp"% mapfilename mapfilenametmp = "%s.tmp" % mapfilename
mapfilenamelock = "%s.lock"% mapfilename mapfilenamelock = "%s.lock" % mapfilename
with self.maplock and open(mapfilenamelock, 'w') as mapfilelock: with self.maplock and open(mapfilenamelock, 'w') as mapfilelock:
# The "account" lock already prevents from multiple access by # The "account" lock already prevents from multiple access by
# different processes. However, we still need to protect for # different processes. However, we still need to protect for
@ -111,7 +111,7 @@ class MappedIMAPFolder(IMAPFolder):
pass # Windows... pass # Windows...
with open(mapfilenametmp, 'wt') as mapfilefd: with open(mapfilenametmp, 'wt') as mapfilefd:
for (key, value) in list(self.diskl2r.items()): for (key, value) in list(self.diskl2r.items()):
mapfilefd.write("%d:%d\n"% (key, value)) mapfilefd.write("%d:%d\n" % (key, value))
if self.dofsync(): if self.dofsync():
fsync(mapfilefd) fsync(mapfilefd)
# The lock is released when the file descriptor ends. # The lock is released when the file descriptor ends.
@ -142,7 +142,7 @@ class MappedIMAPFolder(IMAPFolder):
for luid in list(self.diskl2r.keys()): for luid in list(self.diskl2r.keys()):
if not luid in reallist: if not luid in reallist:
ruid = self.diskl2r[luid] ruid = self.diskl2r[luid]
#XXX: the following KeyError are sightly unexpected. This # XXX: the following KeyError are sightly unexpected. This
# would require more digging to understand how it's # would require more digging to understand how it's
# possible. # possible.
errorMessage = ("unexpected error: key {} was not found " errorMessage = ("unexpected error: key {} was not found "
@ -268,7 +268,7 @@ class MappedIMAPFolder(IMAPFolder):
newluid = self._mb.savemessage(-1, content, flags, rtime) newluid = self._mb.savemessage(-1, content, flags, rtime)
if newluid < 1: if newluid < 1:
raise OfflineImapError("server of repository '%s' did not return " raise OfflineImapError("server of repository '%s' did not return "
"a valid UID (got '%s') for UID '%s' from '%s'"% ( "a valid UID (got '%s') for UID '%s' from '%s'" % (
self._mb.getname(), newluid, uid, self.getname() self._mb.getname(), newluid, uid, self.getname()
), ),
OfflineImapError.ERROR.MESSAGE OfflineImapError.ERROR.MESSAGE
@ -315,7 +315,7 @@ class MappedIMAPFolder(IMAPFolder):
changing the mappings file.""" changing the mappings file."""
if ruid not in self.r2l: if ruid not in self.r2l:
raise OfflineImapError("Cannot change unknown Maildir UID %s"% raise OfflineImapError("Cannot change unknown Maildir UID %s" %
ruid, OfflineImapError.ERROR.MESSAGE) ruid, OfflineImapError.ERROR.MESSAGE)
if ruid == new_ruid: return # sanity check shortcut if ruid == new_ruid: return # sanity check shortcut
with self.maplock: with self.maplock: