Reformat offlineimap/mbnames.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 20:22:14 +02:00
parent 9c865afbf0
commit 973e3324ff

View File

@ -21,12 +21,12 @@ import json
from threading import Lock from threading import Lock
from os import listdir, makedirs, path, unlink from os import listdir, makedirs, path, unlink
from sys import exc_info from sys import exc_info
try: try:
from configparser import NoSectionError from configparser import NoSectionError
except ImportError: # Py3. except ImportError: # Py3.
from configparser import NoSectionError from configparser import NoSectionError
_mbLock = Lock() _mbLock = Lock()
_mbnames = None _mbnames = None
@ -93,7 +93,7 @@ class _IntermediateMbnames(object):
self._accountname = accountname self._accountname = accountname
self._folder_root = folder_root self._folder_root = folder_root
self._folderfilter = folderfilter self._folderfilter = folderfilter
self._path = path.join(mbnamesdir, "%s.json"% accountname) self._path = path.join(mbnamesdir, "%s.json" % accountname)
self._dryrun = dry_run self._dryrun = dry_run
def add(self, foldername): def add(self, foldername):
@ -117,7 +117,7 @@ class _IntermediateMbnames(object):
}) })
if self._dryrun: if self._dryrun:
self.ui.info("mbnames would write %s"% self._path) self.ui.info("mbnames would write %s" % self._path)
else: else:
with open( with open(
self._path, "w", encoding='utf-8') as intermediateFD: self._path, "w", encoding='utf-8') as intermediateFD:
@ -183,10 +183,10 @@ class _Mbnames(object):
def _removeIntermediateFile(self, path): def _removeIntermediateFile(self, path):
if self._dryrun: if self._dryrun:
self.ui.info("mbnames would remove %s"% path) self.ui.info("mbnames would remove %s" % path)
else: else:
unlink(path) unlink(path)
self.ui.info("removed %s"% path) self.ui.info("removed %s" % path)
def addAccountFolder(self, accountname, folder_root, foldername): def addAccountFolder(self, accountname, folder_root, foldername):
"""Add foldername entry for an account.""" """Add foldername entry for an account."""
@ -240,12 +240,12 @@ class _Mbnames(object):
itemlist.append(item) itemlist.append(item)
except (OSError, IOError) as e: except (OSError, IOError) as e:
self.ui.error("could not read intermediate mbnames file '%s':" self.ui.error("could not read intermediate mbnames file '%s':"
"%s"% (intermediateFile, str(e))) "%s" % (intermediateFile, str(e)))
except Exception as e: except Exception as e:
self.ui.error( self.ui.error(
e, e,
exc_info()[2], exc_info()[2],
("intermediate mbnames file %s not properly read"% ("intermediate mbnames file %s not properly read" %
intermediateFile) intermediateFile)
) )
@ -253,7 +253,7 @@ class _Mbnames(object):
itemlist = [self._peritem % d for d in itemlist] itemlist = [self._peritem % d for d in itemlist]
if self._dryrun: if self._dryrun:
self.ui.info("mbnames would write %s"% self._path) self.ui.info("mbnames would write %s" % self._path)
else: else:
try: try:
with open( with open(
@ -265,7 +265,7 @@ class _Mbnames(object):
self.ui.error( self.ui.error(
e, e,
exc_info()[2], exc_info()[2],
"mbnames file %s not properly written"% self._path "mbnames file %s not properly written" % self._path
) )
def writeIntermediateFile(self, accountname): def writeIntermediateFile(self, accountname):
@ -275,5 +275,5 @@ class _Mbnames(object):
self.ui.error( self.ui.error(
e, e,
exc_info()[2], exc_info()[2],
"intermediate mbnames file %s not properly written"% self._path "intermediate mbnames file %s not properly written" % self._path
) )