File: oflpy.py

package info (click to toggle)
offlineimap 4.0.14
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 880 kB
  • ctags: 680
  • sloc: python: 4,370; makefile: 88; sh: 62
file content (57 lines) | stat: -rw-r--r-- 1,419 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""oflpy.py - for offlineimaprc use"""
__revision__ = '1.0'

import re

# --------------------------------
folder_s = """\.\.\/|,\ |\/\.|\*|\ \&-\ |\'|\.|\)|\("""
folder_re = re.compile( folder_s )

def getfoldername(foldername):
    """substitute for a possibly-buggy IMAP folder name"""
    return folder_re.sub('_', foldername)

def test_gfn():
    """test: substitute for a possibly-buggy IMAP folder name"""
    from namet import bad_folders

    for f_name in bad_folders:
        #print f_name, '\t\t', getfoldername(f_name)
        print getfoldername(f_name)

# --------------------------------
filter_s = """^Public Folders|^Calendar|^Contacts|^Tasks|^Drafts|^Journal|^[a-zA-Z0-9 _\-/!]+/\.$"""
filter_s = """^Public Folders|^Calendar|^Contacts|^Tasks|^Drafts|^Journal"""
filter_re = re.compile( filter_s )

def filterfolders(foldername):
    """test for, and filter out some IMAP folders"""
    res = filter_re.match(foldername)

    if res:
        return None
    else:
        return foldername


def test_ff():
    """test: test for, and filter out some IMAP folders"""
    from namet2 import some_bad

    for f_name in some_bad:
        #print f_name, '\t\t', getfoldername(f_name)
        print filterfolders(f_name)

#test_gfn()
#
#test_ff()

# Then in .offlineimaprc:
# 
#[general]
# pythonfile = ~/.offlineimap.py
#
#[Repository Remote]
# nametrans = getfoldername
#
# folderfilter = filterfolders