imaputil.py: avoid to redefine "string"
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
1339cc8913
commit
11619faf7c
@ -32,29 +32,29 @@ def __debug(*args):
|
|||||||
msg.append(str(arg))
|
msg.append(str(arg))
|
||||||
getglobalui().debug('imap', " ".join(msg))
|
getglobalui().debug('imap', " ".join(msg))
|
||||||
|
|
||||||
def dequote(string):
|
def dequote(s):
|
||||||
"""Takes string which may or may not be quoted and unquotes it.
|
"""Takes string which may or may not be quoted and unquotes it.
|
||||||
|
|
||||||
It only considers double quotes. This function does NOT consider
|
It only considers double quotes. This function does NOT consider
|
||||||
parenthised lists to be quoted."""
|
parenthised lists to be quoted."""
|
||||||
|
|
||||||
if string and string.startswith('"') and string.endswith('"'):
|
if s and s.startswith('"') and s.endswith('"'):
|
||||||
string = string[1:-1] # Strip off the surrounding quotes.
|
s = s[1:-1] # Strip off the surrounding quotes.
|
||||||
string = string.replace('\\"', '"')
|
s = s.replace('\\"', '"')
|
||||||
string = string.replace('\\\\', '\\')
|
s = s.replace('\\\\', '\\')
|
||||||
return string
|
return s
|
||||||
|
|
||||||
def quote(string):
|
def quote(s):
|
||||||
"""Takes an unquoted string and quotes it.
|
"""Takes an unquoted string and quotes it.
|
||||||
|
|
||||||
It only adds double quotes. This function does NOT consider
|
It only adds double quotes. This function does NOT consider
|
||||||
parenthised lists to be quoted."""
|
parenthised lists to be quoted."""
|
||||||
|
|
||||||
string = string.replace('"', '\\"')
|
s = s.replace('"', '\\"')
|
||||||
string = string.replace('\\', '\\\\')
|
s = s.replace('\\', '\\\\')
|
||||||
return '"%s"' % string
|
return '"%s"'% s
|
||||||
|
|
||||||
def flagsplit(string):
|
def flagsplit(s):
|
||||||
"""Converts a string of IMAP flags to a list
|
"""Converts a string of IMAP flags to a list
|
||||||
|
|
||||||
:returns: E.g. '(\\Draft \\Deleted)' returns ['\\Draft','\\Deleted'].
|
:returns: E.g. '(\\Draft \\Deleted)' returns ['\\Draft','\\Deleted'].
|
||||||
@ -62,9 +62,9 @@ def flagsplit(string):
|
|||||||
['FLAGS,'(\\Seen Old)','UID', '4807']
|
['FLAGS,'(\\Seen Old)','UID', '4807']
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if string[0] != '(' or string[-1] != ')':
|
if s[0] != '(' or s[-1] != ')':
|
||||||
raise ValueError("Passed string '%s' is not a flag list" % string)
|
raise ValueError("Passed s '%s' is not a flag list"% s)
|
||||||
return imapsplit(string[1:-1])
|
return imapsplit(s[1:-1])
|
||||||
|
|
||||||
def __options2hash(list):
|
def __options2hash(list):
|
||||||
"""convert list [1,2,3,4,5,6] to {1:2, 3:4, 5:6}"""
|
"""convert list [1,2,3,4,5,6] to {1:2, 3:4, 5:6}"""
|
||||||
@ -234,7 +234,7 @@ def uid_sequence(uidlist):
|
|||||||
return ",".join(retval)
|
return ",".join(retval)
|
||||||
|
|
||||||
|
|
||||||
def __split_quoted(string):
|
def __split_quoted(s):
|
||||||
"""Looks for the ending quote character in the string that starts
|
"""Looks for the ending quote character in the string that starts
|
||||||
with quote character, splitting out quoted component and the
|
with quote character, splitting out quoted component and the
|
||||||
rest of the string (without possible space between these two
|
rest of the string (without possible space between these two
|
||||||
@ -247,15 +247,15 @@ def __split_quoted(string):
|
|||||||
- "\\" => ("\\", )
|
- "\\" => ("\\", )
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(string) == 0:
|
if len(s) == 0:
|
||||||
return ('', '')
|
return ('', '')
|
||||||
|
|
||||||
q = quoted = string[0]
|
q = quoted = s[0]
|
||||||
rest = string[1:]
|
rest = s[1:]
|
||||||
while True:
|
while True:
|
||||||
next_q = rest.find(q)
|
next_q = rest.find(q)
|
||||||
if next_q == -1:
|
if next_q == -1:
|
||||||
raise ValueError("can't find ending quote '%s' in '%s'" % (q, string))
|
raise ValueError("can't find ending quote '%s' in '%s'"% (q, s))
|
||||||
# If quote is preceeded by even number of backslashes,
|
# If quote is preceeded by even number of backslashes,
|
||||||
# then it is the ending quote, otherwise the quote
|
# then it is the ending quote, otherwise the quote
|
||||||
# character is escaped by backslash, so we should
|
# character is escaped by backslash, so we should
|
||||||
|
Loading…
Reference in New Issue
Block a user