Reformat offlineimap/folder/LocalStatus.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:43:52 +02:00
parent da1788db53
commit cb95bc87b0

View File

@ -30,7 +30,7 @@ class LocalStatusFolder(BaseFolder):
magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT %d" magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT %d"
def __init__(self, name, repository): def __init__(self, name, repository):
self.sep = '.' #needs to be set before super.__init__() self.sep = '.' # needs to be set before super.__init__()
super(LocalStatusFolder, self).__init__(name, repository) super(LocalStatusFolder, self).__init__(name, repository)
self.root = repository.root self.root = repository.root
self.filename = os.path.join(self.getroot(), self.getfolderbasename()) self.filename = os.path.join(self.getroot(), self.getfolderbasename())
@ -68,8 +68,8 @@ class LocalStatusFolder(BaseFolder):
uid = int(uid) uid = int(uid)
flags = set(flags) flags = set(flags)
except ValueError as e: except ValueError as e:
errstr = ("Corrupt line '%s' in cache file '%s'"% errstr = ("Corrupt line '%s' in cache file '%s'" %
(line, self.filename)) (line, self.filename))
self.ui.warn(errstr) self.ui.warn(errstr)
six.reraise(ValueError, ValueError(errstr), exc_info()[2]) six.reraise(ValueError, ValueError(errstr), exc_info()[2])
self.messagelist[uid] = self.msglist_item_initializer(uid) self.messagelist[uid] = self.msglist_item_initializer(uid)
@ -91,8 +91,8 @@ class LocalStatusFolder(BaseFolder):
mtime = int(mtime) mtime = int(mtime)
labels = set([lb.strip() for lb in labels.split(',') if len(lb.strip()) > 0]) labels = set([lb.strip() for lb in labels.split(',') if len(lb.strip()) > 0])
except ValueError as e: except ValueError as e:
errstr = "Corrupt line '%s' in cache file '%s'"% \ errstr = "Corrupt line '%s' in cache file '%s'" % \
(line, self.filename) (line, self.filename)
self.ui.warn(errstr) self.ui.warn(errstr)
six.reraise(ValueError, ValueError(errstr), exc_info()[2]) six.reraise(ValueError, ValueError(errstr), exc_info()[2])
self.messagelist[uid] = self.msglist_item_initializer(uid) self.messagelist[uid] = self.msglist_item_initializer(uid)
@ -100,7 +100,6 @@ class LocalStatusFolder(BaseFolder):
self.messagelist[uid]['mtime'] = mtime self.messagelist[uid]['mtime'] = mtime
self.messagelist[uid]['labels'] = labels self.messagelist[uid]['labels'] = labels
# Interface from BaseFolder # Interface from BaseFolder
def cachemessagelist(self): def cachemessagelist(self):
if self.isnewfolder(): if self.isnewfolder():
@ -120,7 +119,7 @@ class LocalStatusFolder(BaseFolder):
# Convert from format v1. # Convert from format v1.
elif line == (self.magicline % 1): elif line == (self.magicline % 1):
self.ui._msg('Upgrading LocalStatus cache from version 1 ' self.ui._msg('Upgrading LocalStatus cache from version 1 '
'to version 2 for %s:%s'% (self.repository, self)) 'to version 2 for %s:%s' % (self.repository, self))
self.readstatus_v1(cachefd) self.readstatus_v1(cachefd)
cachefd.close() cachefd.close()
self.save() self.save()
@ -142,20 +141,20 @@ class LocalStatusFolder(BaseFolder):
if not line: if not line:
# The status file is empty - should not have happened, # The status file is empty - should not have happened,
# but somehow did. # but somehow did.
errstr = "Cache file '%s' is empty."% self.filename errstr = "Cache file '%s' is empty." % self.filename
self.ui.warn(errstr) self.ui.warn(errstr)
cachefd.close() cachefd.close()
return return
assert(line == (self.magicline % self.cur_version)) assert (line == (self.magicline % self.cur_version))
self.readstatus(cachefd) self.readstatus(cachefd)
cachefd.close() cachefd.close()
def openfiles(self): def openfiles(self):
pass # Closing files is done on a per-transaction basis. pass # Closing files is done on a per-transaction basis.
def closefiles(self): def closefiles(self):
pass # Closing files is done on a per-transaction basis. pass # Closing files is done on a per-transaction basis.
def purge(self): def purge(self):
"""Remove any pre-existing database.""" """Remove any pre-existing database."""
@ -163,8 +162,8 @@ class LocalStatusFolder(BaseFolder):
try: try:
os.unlink(self.filename) os.unlink(self.filename)
except OSError as e: except OSError as e:
self.ui.debug('', "could not remove file %s: %s"% self.ui.debug('', "could not remove file %s: %s" %
(self.filename, e)) (self.filename, e))
def save(self): def save(self):
"""Save changed data to disk. For this backend it is the same as saveall.""" """Save changed data to disk. For this backend it is the same as saveall."""
@ -204,7 +203,7 @@ class LocalStatusFolder(BaseFolder):
# We cannot assign a uid. # We cannot assign a uid.
return uid return uid
if self.uidexists(uid): # already have it if self.uidexists(uid): # already have it
self.savemessageflags(uid, flags) self.savemessageflags(uid, flags)
return uid return uid
@ -276,5 +275,5 @@ class LocalStatusFolder(BaseFolder):
return return
for uid in uidlist: for uid in uidlist:
del(self.messagelist[uid]) del (self.messagelist[uid])
self.save() self.save()