Base.py long lines style
This patch changes long lines (>80 chars) to lines <80 chars. The patch only changes the style.
This commit is contained in:
parent
23f67019cc
commit
8504cdc6b8
@ -397,7 +397,8 @@ class BaseFolder:
|
|||||||
|
|
||||||
def get_min_uid_file(self):
|
def get_min_uid_file(self):
|
||||||
startuiddir = os.path.join(self.config.getmetadatadir(),
|
startuiddir = os.path.join(self.config.getmetadatadir(),
|
||||||
'Repository-' + self.repository.name, 'StartUID')
|
'Repository-' + self.repository.name,
|
||||||
|
'StartUID')
|
||||||
if not os.path.exists(startuiddir):
|
if not os.path.exists(startuiddir):
|
||||||
os.mkdir(startuiddir, 0o700)
|
os.mkdir(startuiddir, 0o700)
|
||||||
return os.path.join(startuiddir, self.getfolderbasename())
|
return os.path.join(startuiddir, self.getfolderbasename())
|
||||||
@ -594,8 +595,8 @@ class BaseFolder:
|
|||||||
def addmessageheader(self, content, linebreak, headername, headervalue):
|
def addmessageheader(self, content, linebreak, headername, headervalue):
|
||||||
"""Adds new header to the provided message.
|
"""Adds new header to the provided message.
|
||||||
|
|
||||||
WARNING: This function is a bit tricky, and modifying it in the wrong way,
|
WARNING: This function is a bit tricky, and modifying it in the wrong
|
||||||
may easily lead to data-loss.
|
way, may easily lead to data-loss.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- content: message content, headers and body as a single string
|
- content: message content, headers and body as a single string
|
||||||
@ -605,8 +606,8 @@ class BaseFolder:
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
The following documentation will not get displayed correctly after being
|
The following documentation will not get displayed correctly after
|
||||||
processed by Sphinx. View the source of this method to read it.
|
being processed by Sphinx. View the source of this method to read it.
|
||||||
|
|
||||||
This has to deal with strange corner cases where the header is
|
This has to deal with strange corner cases where the header is
|
||||||
missing or empty. Here are illustrations for all the cases,
|
missing or empty. Here are illustrations for all the cases,
|
||||||
@ -659,7 +660,8 @@ class BaseFolder:
|
|||||||
self.ui.debug('', 'addmessageheader: headers were missing')
|
self.ui.debug('', 'addmessageheader: headers were missing')
|
||||||
else:
|
else:
|
||||||
self.ui.debug('',
|
self.ui.debug('',
|
||||||
'addmessageheader: headers end at position %d' % insertionpoint)
|
'addmessageheader: headers end at position %d' %
|
||||||
|
insertionpoint)
|
||||||
mark = '==>EOH<=='
|
mark = '==>EOH<=='
|
||||||
contextstart = max(0, insertionpoint - 100)
|
contextstart = max(0, insertionpoint - 100)
|
||||||
contextend = min(len(content), insertionpoint + 100)
|
contextend = min(len(content), insertionpoint + 100)
|
||||||
@ -693,9 +695,11 @@ class BaseFolder:
|
|||||||
self.ui.debug('',
|
self.ui.debug('',
|
||||||
'addmessageheader: insertionpoint = %d' % insertionpoint)
|
'addmessageheader: insertionpoint = %d' % insertionpoint)
|
||||||
headers = content[0:insertionpoint]
|
headers = content[0:insertionpoint]
|
||||||
self.ui.debug('', 'addmessageheader: headers = %s' % repr(headers))
|
self.ui.debug('',
|
||||||
|
'addmessageheader: headers = %s' % repr(headers))
|
||||||
new_header = prefix + ("%s: %s" % (headername, headervalue)) + suffix
|
new_header = prefix + ("%s: %s" % (headername, headervalue)) + suffix
|
||||||
self.ui.debug('', 'addmessageheader: new_header = %s' % repr(new_header))
|
self.ui.debug('',
|
||||||
|
'addmessageheader: new_header = %s' % repr(new_header))
|
||||||
return headers + new_header + content[insertionpoint:]
|
return headers + new_header + content[insertionpoint:]
|
||||||
|
|
||||||
def __find_eoh(self, content):
|
def __find_eoh(self, content):
|
||||||
@ -746,7 +750,8 @@ class BaseFolder:
|
|||||||
- contents: message itself
|
- contents: message itself
|
||||||
- name: name of the header to be searched
|
- name: name of the header to be searched
|
||||||
|
|
||||||
Returns: list of header values or empty list if no such header was found.
|
Returns: list of header values or empty list if no such header was
|
||||||
|
found.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.ui.debug('', 'getmessageheaderlist: called to get %s' % name)
|
self.ui.debug('', 'getmessageheaderlist: called to get %s' % name)
|
||||||
@ -769,7 +774,8 @@ class BaseFolder:
|
|||||||
|
|
||||||
if type(header_list) != type([]):
|
if type(header_list) != type([]):
|
||||||
header_list = [header_list]
|
header_list = [header_list]
|
||||||
self.ui.debug('', 'deletemessageheaders: called to delete %s' % header_list)
|
self.ui.debug('',
|
||||||
|
'deletemessageheaders: called to delete %s' % header_list)
|
||||||
|
|
||||||
if not len(header_list):
|
if not len(header_list):
|
||||||
return content
|
return content
|
||||||
@ -783,7 +789,8 @@ class BaseFolder:
|
|||||||
for h in headers.split('\n'):
|
for h in headers.split('\n'):
|
||||||
keep_it = True
|
keep_it = True
|
||||||
for trim_h in header_list:
|
for trim_h in header_list:
|
||||||
if len(h) > len(trim_h) and h[0:len(trim_h) + 1] == (trim_h + ":"):
|
if len(h) > len(trim_h) \
|
||||||
|
and h[0:len(trim_h) + 1] == (trim_h + ":"):
|
||||||
keep_it = False
|
keep_it = False
|
||||||
break
|
break
|
||||||
if keep_it:
|
if keep_it:
|
||||||
@ -873,9 +880,10 @@ class BaseFolder:
|
|||||||
# IMAP servers ...
|
# IMAP servers ...
|
||||||
self.deletemessage(uid)
|
self.deletemessage(uid)
|
||||||
else:
|
else:
|
||||||
raise OfflineImapError("Trying to save msg (uid %d) on folder "
|
msg = "Trying to save msg (uid %d) on folder " \
|
||||||
"%s returned invalid uid %d" % (uid, dstfolder.getvisiblename(),
|
"%s returned invalid uid %d" % \
|
||||||
new_uid), OfflineImapError.ERROR.MESSAGE)
|
(uid, dstfolder.getvisiblename(), new_uid)
|
||||||
|
raise OfflineImapError(msg, OfflineImapError.ERROR.MESSAGE)
|
||||||
except KeyboardInterrupt: # Bubble up CTRL-C.
|
except KeyboardInterrupt: # Bubble up CTRL-C.
|
||||||
raise
|
raise
|
||||||
except OfflineImapError as e:
|
except OfflineImapError as e:
|
||||||
@ -884,7 +892,8 @@ class BaseFolder:
|
|||||||
self.ui.error(e, exc_info()[2])
|
self.ui.error(e, exc_info()[2])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.ui.error(e, exc_info()[2],
|
self.ui.error(e, exc_info()[2],
|
||||||
msg="Copying message %s [acc: %s]" % (uid, self.accountname))
|
msg="Copying message %s [acc: %s]" %
|
||||||
|
(uid, self.accountname))
|
||||||
raise # Raise on unknown errors, so we can fix those.
|
raise # Raise on unknown errors, so we can fix those.
|
||||||
|
|
||||||
def __syncmessagesto_copy(self, dstfolder, statusfolder):
|
def __syncmessagesto_copy(self, dstfolder, statusfolder):
|
||||||
@ -929,24 +938,28 @@ class BaseFolder:
|
|||||||
break
|
break
|
||||||
|
|
||||||
if uid == 0:
|
if uid == 0:
|
||||||
self.ui.warn("Assertion that UID != 0 failed; ignoring message.")
|
msg = "Assertion that UID != 0 failed; ignoring message."
|
||||||
|
self.ui.warn(msg)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if uid > 0 and dstfolder.uidexists(uid):
|
if uid > 0 and dstfolder.uidexists(uid):
|
||||||
# dstfolder has message with that UID already, only update status.
|
# dstfolder has message with that UID already,
|
||||||
|
# only update status.
|
||||||
flags = self.getmessageflags(uid)
|
flags = self.getmessageflags(uid)
|
||||||
rtime = self.getmessagetime(uid)
|
rtime = self.getmessagetime(uid)
|
||||||
statusfolder.savemessage(uid, None, flags, rtime)
|
statusfolder.savemessage(uid, None, flags, rtime)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.ui.copyingmessage(uid, num + 1, num_to_copy, self, dstfolder)
|
self.ui.copyingmessage(uid, num + 1, num_to_copy, self,
|
||||||
|
dstfolder)
|
||||||
# Exceptions are caught in copymessageto().
|
# Exceptions are caught in copymessageto().
|
||||||
if self.suggeststhreads():
|
if self.suggeststhreads():
|
||||||
self.waitforthread()
|
self.waitforthread()
|
||||||
thread = threadutil.InstanceLimitedThread(
|
thread = threadutil.InstanceLimitedThread(
|
||||||
self.getinstancelimitnamespace(),
|
self.getinstancelimitnamespace(),
|
||||||
target=self.copymessageto,
|
target=self.copymessageto,
|
||||||
name="Copy message from %s:%s" % (self.repository, self),
|
name="Copy message from %s:%s" % (self.repository,
|
||||||
|
self),
|
||||||
args=(uid, dstfolder, statusfolder)
|
args=(uid, dstfolder, statusfolder)
|
||||||
)
|
)
|
||||||
thread.start()
|
thread.start()
|
||||||
@ -1015,9 +1028,10 @@ class BaseFolder:
|
|||||||
# skip them.
|
# skip them.
|
||||||
skipped_keywords = list(selfkeywords - knownkeywords)
|
skipped_keywords = list(selfkeywords - knownkeywords)
|
||||||
selfkeywords &= knownkeywords
|
selfkeywords &= knownkeywords
|
||||||
self.ui.warn("Unknown keywords skipped: %s\n"
|
msg = "Unknown keywords skipped: %s\n" \
|
||||||
"You may want to change your configuration to include "
|
"You may want to change your configuration to include " \
|
||||||
"those\n" % skipped_keywords)
|
"those\n" % skipped_keywords
|
||||||
|
self.ui.warn(msg)
|
||||||
|
|
||||||
keywordletterset = set([keywordmap[keyw] for keyw in selfkeywords])
|
keywordletterset = set([keywordmap[keyw] for keyw in selfkeywords])
|
||||||
|
|
||||||
@ -1130,11 +1144,11 @@ class BaseFolder:
|
|||||||
except OfflineImapError as e:
|
except OfflineImapError as e:
|
||||||
if e.severity > OfflineImapError.ERROR.FOLDER:
|
if e.severity > OfflineImapError.ERROR.FOLDER:
|
||||||
raise
|
raise
|
||||||
self.ui.error(e, exc_info()[2], "while syncing %s [account %s]" %
|
msg = "while syncing %s [account %s]" % (self, self.accountname)
|
||||||
(self, self.accountname))
|
self.ui.error(e, exc_info()[2], msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.ui.error(e, exc_info()[2], "while syncing %s [account %s]" %
|
msg = "while syncing %s [account %s]" % (self, self.accountname)
|
||||||
(self, self.accountname))
|
self.ui.error(e, exc_info()[2], msg)
|
||||||
raise # Raise unknown Exceptions so we can fix them.
|
raise # Raise unknown Exceptions so we can fix them.
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
Loading…
Reference in New Issue
Block a user