Reformat offlineimap/ui/Machine.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:56:37 +02:00
parent 9aa2344fd4
commit d31c5891ba

View File

@ -24,6 +24,7 @@ from offlineimap.ui.UIBase import UIBase
protocol = '7.2.0' protocol = '7.2.0'
class MachineLogFormatter(logging.Formatter): class MachineLogFormatter(logging.Formatter):
"""urlencodes any outputted line, to avoid multi-line output""" """urlencodes any outputted line, to avoid multi-line output"""
@ -44,8 +45,8 @@ class MachineLogFormatter(logging.Formatter):
command = "" command = ""
whoami = currentThread().getName() whoami = currentThread().getName()
prefix = "%s:%s"% (command, urlencode([('', whoami)])[1:]) prefix = "%s:%s" % (command, urlencode([('', whoami)])[1:])
return "%s:%s:%s"% (severity, prefix, urlencode([('', line)])[1:]) return "%s:%s:%s" % (severity, prefix, urlencode([('', line)])[1:])
class MachineUI(UIBase): class MachineUI(UIBase):
@ -63,11 +64,11 @@ class MachineUI(UIBase):
# - msg: the message itself # - msg: the message itself
def _printData(s, handler, command, msg): def _printData(s, handler, command, msg):
handler(msg, handler(msg,
extra = { extra={
'machineui': { 'machineui': {
'command': command, 'command': command,
'id': currentThread().getName(), 'id': currentThread().getName(),
} }
}) })
def _msg(s, msg): def _msg(s, msg):
@ -95,74 +96,74 @@ class MachineUI(UIBase):
s._printData(s.logger.info, 'acctdone', accountname) s._printData(s.logger.info, 'acctdone', accountname)
def validityproblem(s, folder): def validityproblem(s, folder):
s._printData(s.logger.warning, 'validityproblem', "%s\n%s\n%s\n%s"% s._printData(s.logger.warning, 'validityproblem', "%s\n%s\n%s\n%s" %
(folder.getname(), folder.getrepository().getname(), (folder.getname(), folder.getrepository().getname(),
folder.get_saveduidvalidity(), folder.get_uidvalidity())) folder.get_saveduidvalidity(), folder.get_uidvalidity()))
def connecting(s, reposname, hostname, port): def connecting(s, reposname, hostname, port):
s._printData(s.logger.info, 'connecting', "%s\n%s\n%s"% (hostname, s._printData(s.logger.info, 'connecting', "%s\n%s\n%s" % (hostname,
str(port), reposname)) str(port), reposname))
def syncfolders(s, srcrepos, destrepos): def syncfolders(s, srcrepos, destrepos):
s._printData(s.logger.info, 'syncfolders', "%s\n%s"% (s.getnicename(srcrepos), s._printData(s.logger.info, 'syncfolders', "%s\n%s" % (s.getnicename(srcrepos),
s.getnicename(destrepos))) s.getnicename(destrepos)))
def syncingfolder(s, srcrepos, srcfolder, destrepos, destfolder): def syncingfolder(s, srcrepos, srcfolder, destrepos, destfolder):
s._printData(s.logger.info, 'syncingfolder', "%s\n%s\n%s\n%s\n"% s._printData(s.logger.info, 'syncingfolder', "%s\n%s\n%s\n%s\n" %
(s.getnicename(srcrepos), srcfolder.getname(), (s.getnicename(srcrepos), srcfolder.getname(),
s.getnicename(destrepos), destfolder.getname())) s.getnicename(destrepos), destfolder.getname()))
def loadmessagelist(s, repos, folder): def loadmessagelist(s, repos, folder):
s._printData(s.logger.info, 'loadmessagelist', "%s\n%s"% (s.getnicename(repos), s._printData(s.logger.info, 'loadmessagelist', "%s\n%s" % (s.getnicename(repos),
folder.getvisiblename())) folder.getvisiblename()))
def messagelistloaded(s, repos, folder, count): def messagelistloaded(s, repos, folder, count):
s._printData(s.logger.info, 'messagelistloaded', "%s\n%s\n%d"% s._printData(s.logger.info, 'messagelistloaded', "%s\n%s\n%d" %
(s.getnicename(repos), folder.getname(), count)) (s.getnicename(repos), folder.getname(), count))
def syncingmessages(s, sr, sf, dr, df): def syncingmessages(s, sr, sf, dr, df):
s._printData(s.logger.info, 'syncingmessages', "%s\n%s\n%s\n%s\n"% s._printData(s.logger.info, 'syncingmessages', "%s\n%s\n%s\n%s\n" %
(s.getnicename(sr), sf.getname(), s.getnicename(dr), (s.getnicename(sr), sf.getname(), s.getnicename(dr),
df.getname())) df.getname()))
def ignorecopyingmessage(s, uid, srcfolder, destfolder): def ignorecopyingmessage(s, uid, srcfolder, destfolder):
s._printData(s.logger.info, 'ignorecopyingmessage', "%d\n%s\n%s\n%s[%s]"% s._printData(s.logger.info, 'ignorecopyingmessage', "%d\n%s\n%s\n%s[%s]" %
(uid, s.getnicename(srcfolder), srcfolder.getname(), (uid, s.getnicename(srcfolder), srcfolder.getname(),
s.getnicename(destfolder), destfolder)) s.getnicename(destfolder), destfolder))
def copyingmessage(s, uid, num, num_to_copy, srcfolder, destfolder): def copyingmessage(s, uid, num, num_to_copy, srcfolder, destfolder):
s._printData(s.logger.info, 'copyingmessage', "%d\n%s\n%s\n%s[%s]"% s._printData(s.logger.info, 'copyingmessage', "%d\n%s\n%s\n%s[%s]" %
(uid, s.getnicename(srcfolder), srcfolder.getname(), (uid, s.getnicename(srcfolder), srcfolder.getname(),
s.getnicename(destfolder), destfolder)) s.getnicename(destfolder), destfolder))
def folderlist(s, list): def folderlist(s, list):
return ("\f".join(["%s\t%s"% (s.getnicename(x), x.getname()) for x in list])) return ("\f".join(["%s\t%s" % (s.getnicename(x), x.getname()) for x in list]))
def uidlist(s, list): def uidlist(s, list):
return ("\f".join([str(u) for u in list])) return ("\f".join([str(u) for u in list]))
def deletingmessages(s, uidlist, destlist): def deletingmessages(s, uidlist, destlist):
ds = s.folderlist(destlist) ds = s.folderlist(destlist)
s._printData(s.logger.info, 'deletingmessages', "%s\n%s"% (s.uidlist(uidlist), ds)) s._printData(s.logger.info, 'deletingmessages', "%s\n%s" % (s.uidlist(uidlist), ds))
def addingflags(s, uidlist, flags, dest): def addingflags(s, uidlist, flags, dest):
s._printData(s.logger.info, "addingflags", "%s\n%s\n%s"% (s.uidlist(uidlist), s._printData(s.logger.info, "addingflags", "%s\n%s\n%s" % (s.uidlist(uidlist),
"\f".join(flags), "\f".join(flags),
dest)) dest))
def deletingflags(s, uidlist, flags, dest): def deletingflags(s, uidlist, flags, dest):
s._printData(s.logger.info, 'deletingflags', "%s\n%s\n%s"% (s.uidlist(uidlist), s._printData(s.logger.info, 'deletingflags', "%s\n%s\n%s" % (s.uidlist(uidlist),
"\f".join(flags), "\f".join(flags),
dest)) dest))
def threadException(s, thread): def threadException(s, thread):
s._printData(s.logger.warning, 'threadException', "%s\n%s"% s._printData(s.logger.warning, 'threadException', "%s\n%s" %
(thread.getName(), s.getThreadExceptionString(thread))) (thread.getName(), s.getThreadExceptionString(thread)))
s.delThreadDebugLog(thread) s.delThreadDebugLog(thread)
s.terminate(100) s.terminate(100)
def terminate(s, exitstatus=0, errortitle='', errormsg=''): def terminate(s, exitstatus=0, errortitle='', errormsg=''):
s._printData(s.logger.info, 'terminate', "%d\n%s\n%s"% (exitstatus, errortitle, errormsg)) s._printData(s.logger.info, 'terminate', "%d\n%s\n%s" % (exitstatus, errortitle, errormsg))
sys.exit(exitstatus) sys.exit(exitstatus)
def mainException(s): def mainException(s):
@ -173,19 +174,18 @@ class MachineUI(UIBase):
UIBase.threadExited(s, thread) UIBase.threadExited(s, thread)
def sleeping(s, sleepsecs, remainingsecs): def sleeping(s, sleepsecs, remainingsecs):
s._printData(s.logger.info, 'sleeping', "%d\n%d"% (sleepsecs, remainingsecs)) s._printData(s.logger.info, 'sleeping', "%d\n%d" % (sleepsecs, remainingsecs))
if sleepsecs > 0: if sleepsecs > 0:
time.sleep(sleepsecs) time.sleep(sleepsecs)
return 0 return 0
def getpass(s, username, config, errmsg=None): def getpass(s, username, config, errmsg=None):
if errmsg: if errmsg:
s._printData(s.logger.warning, s._printData(s.logger.warning,
'getpasserror', "%s\n%s"% (username, errmsg), 'getpasserror', "%s\n%s" % (username, errmsg),
False) False)
s._log_con_handler.acquire() # lock the console output s._log_con_handler.acquire() # lock the console output
try: try:
s._printData(s.logger.info, 'getpass', username) s._printData(s.logger.info, 'getpass', username)
return (sys.stdin.readline()[:-1]) return (sys.stdin.readline()[:-1])