mbnames: add info output messages in dry run mode
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
520e99d8b6
commit
41764a0ec6
@ -81,8 +81,9 @@ class _IntermediateMbnames(object):
|
|||||||
"""mbnames data for one account."""
|
"""mbnames data for one account."""
|
||||||
|
|
||||||
def __init__(self, accountname, folder_root, mbnamesdir, folderfilter,
|
def __init__(self, accountname, folder_root, mbnamesdir, folderfilter,
|
||||||
dry_run):
|
dry_run, ui):
|
||||||
|
|
||||||
|
self.ui = ui
|
||||||
self._foldernames = []
|
self._foldernames = []
|
||||||
self._accountname = accountname
|
self._accountname = accountname
|
||||||
self._folder_root = folder_root
|
self._folder_root = folder_root
|
||||||
@ -109,7 +110,9 @@ class _IntermediateMbnames(object):
|
|||||||
'localfolders': self._folder_root,
|
'localfolders': self._folder_root,
|
||||||
})
|
})
|
||||||
|
|
||||||
if not self._dryrun:
|
if self._dryrun:
|
||||||
|
self.ui.info("mbnames would write %s"% self._path)
|
||||||
|
else:
|
||||||
with open(self._path, "wt") as intermediateFD:
|
with open(self._path, "wt") as intermediateFD:
|
||||||
json.dump(itemlist, intermediateFD)
|
json.dump(itemlist, intermediateFD)
|
||||||
|
|
||||||
@ -122,7 +125,7 @@ class _Mbnames(object):
|
|||||||
self._dryrun = dry_run
|
self._dryrun = dry_run
|
||||||
|
|
||||||
self._enabled = None
|
self._enabled = None
|
||||||
# Keys: accountname, values: _IntermediateMbnames instance
|
# Keys: accountname, values: _IntermediateMbnames instance.
|
||||||
self._intermediates = {}
|
self._intermediates = {}
|
||||||
self._incremental = None
|
self._incremental = None
|
||||||
self._mbnamesdir = None
|
self._mbnamesdir = None
|
||||||
@ -173,7 +176,7 @@ class _Mbnames(object):
|
|||||||
|
|
||||||
def _removeIntermediateFile(self, path):
|
def _removeIntermediateFile(self, path):
|
||||||
if self._dryrun:
|
if self._dryrun:
|
||||||
self.ui.info("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)
|
||||||
@ -188,6 +191,7 @@ class _Mbnames(object):
|
|||||||
self._mbnamesdir,
|
self._mbnamesdir,
|
||||||
self._folderfilter,
|
self._folderfilter,
|
||||||
self._dryrun,
|
self._dryrun,
|
||||||
|
self.ui,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._intermediates[accountname].add(foldername)
|
self._intermediates[accountname].add(foldername)
|
||||||
@ -240,7 +244,9 @@ class _Mbnames(object):
|
|||||||
itemlist.sort(key=self._func_sortkey)
|
itemlist.sort(key=self._func_sortkey)
|
||||||
itemlist = [self._peritem % d for d in itemlist]
|
itemlist = [self._peritem % d for d in itemlist]
|
||||||
|
|
||||||
if not self._dryrun:
|
if self._dryrun:
|
||||||
|
self.ui.info("mbnames would write %s"% self._path)
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
with open(self._path, 'wt') as mbnamesFile:
|
with open(self._path, 'wt') as mbnamesFile:
|
||||||
mbnamesFile.write(self._header)
|
mbnamesFile.write(self._header)
|
||||||
|
Loading…
Reference in New Issue
Block a user