mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 23:41:59 +01:00
imapfetch.py fix
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
c1b717482b
commit
59572444dd
@ -44,17 +44,20 @@ def read_folder_list(conn):
|
|||||||
if isinstance(folder, type(b'')):
|
if isinstance(folder, type(b'')):
|
||||||
folder = folder.decode('utf-8')
|
folder = folder.decode('utf-8')
|
||||||
elif isinstance(folder, type(())):
|
elif isinstance(folder, type(())):
|
||||||
folder = re.sub(r'\{\d+\}$', '', folder[0]) + folder[1]
|
folder = re.sub(r'\{\d+\}$', '', folder[0].decode('utf-8')) + folder[1].decode('utf-8')
|
||||||
|
|
||||||
# The regex should match ' "/" ' and ' "." '
|
# The regex should match ' "/" ' and ' "." '
|
||||||
if folder:
|
if folder:
|
||||||
f = re.split(r' \"[\/\.]\" ', folder)
|
f = re.split(r' \"[\/\.\\]+\" ', folder)
|
||||||
result.append(f[1])
|
result.append(f[1])
|
||||||
|
|
||||||
return [x for x in result if x not in opts['skip_folders']]
|
return [x for x in result if x not in opts['skip_folders']]
|
||||||
|
|
||||||
|
|
||||||
def process_folder(conn, folder):
|
def process_folder(conn, folder):
|
||||||
|
# Space in the folder name must be escaped
|
||||||
|
folder = re.sub(r' ', '\\ ', folder)
|
||||||
|
|
||||||
if opts['verbose']:
|
if opts['verbose']:
|
||||||
print("Processing {}".format(folder))
|
print("Processing {}".format(folder))
|
||||||
|
|
||||||
@ -75,9 +78,10 @@ def process_folder(conn, folder):
|
|||||||
rc, data = conn.fetch(num, '(RFC822)')
|
rc, data = conn.fetch(num, '(RFC822)')
|
||||||
if opts['verbose']:
|
if opts['verbose']:
|
||||||
print(rc, num)
|
print(rc, num)
|
||||||
opts['counter'] += 1
|
if isinstance(data[0], tuple):
|
||||||
with open("{}.eml".format(opts['counter']), "wb") as f:
|
opts['counter'] += 1
|
||||||
f.write(data[0][1])
|
with open("{}.eml".format(opts['counter']), "wb") as f:
|
||||||
|
f.write(data[0][1])
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
Reference in New Issue
Block a user