/offlineimap/head: changeset 313
Just to be sure, since it could be called by multiple threads, genmbnames will not lock itself.
This commit is contained in:
parent
f652bc5bac
commit
510fa037d8
@ -18,10 +18,12 @@
|
|||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import re # for folderfilter
|
import re # for folderfilter
|
||||||
|
from threading import *
|
||||||
|
|
||||||
boxes = {}
|
boxes = {}
|
||||||
config = None
|
config = None
|
||||||
accounts = None
|
accounts = None
|
||||||
|
mblock = Lock()
|
||||||
|
|
||||||
def init(conf, accts):
|
def init(conf, accts):
|
||||||
global config, accounts
|
global config, accounts
|
||||||
@ -45,25 +47,28 @@ def write():
|
|||||||
def genmbnames():
|
def genmbnames():
|
||||||
"""Takes a configparser object and a boxlist, which is a list of hashes
|
"""Takes a configparser object and a boxlist, which is a list of hashes
|
||||||
containing 'accountname' and 'foldername' keys."""
|
containing 'accountname' and 'foldername' keys."""
|
||||||
localeval = config.getlocaleval()
|
mblock.acquire()
|
||||||
if not config.getboolean("mbnames", "enabled"):
|
try:
|
||||||
return
|
localeval = config.getlocaleval()
|
||||||
file = open(os.path.expanduser(config.get("mbnames", "filename")), "wt")
|
if not config.getboolean("mbnames", "enabled"):
|
||||||
file.write(localeval.eval(config.get("mbnames", "header")))
|
return
|
||||||
folderfilter = lambda accountname, foldername: 1
|
file = open(os.path.expanduser(config.get("mbnames", "filename")), "wt")
|
||||||
if config.has_option("mbnames", "folderfilter"):
|
file.write(localeval.eval(config.get("mbnames", "header")))
|
||||||
folderfilter = localeval.eval(config.get("mbnames", "folderfilter"),
|
folderfilter = lambda accountname, foldername: 1
|
||||||
{'re': re})
|
if config.has_option("mbnames", "folderfilter"):
|
||||||
itemlist = []
|
folderfilter = localeval.eval(config.get("mbnames", "folderfilter"),
|
||||||
for accountname in boxes.keys():
|
{'re': re})
|
||||||
for foldername in boxes[accountname]:
|
itemlist = []
|
||||||
if folderfilter(accountname, foldername):
|
for accountname in boxes.keys():
|
||||||
itemlist.append(config.get("mbnames", "peritem", raw=1) % \
|
for foldername in boxes[accountname]:
|
||||||
{'accountname': accountname,
|
if folderfilter(accountname, foldername):
|
||||||
'foldername': foldername})
|
itemlist.append(config.get("mbnames", "peritem", raw=1) % \
|
||||||
file.write(localeval.eval(config.get("mbnames", "sep")).join(itemlist))
|
{'accountname': accountname,
|
||||||
file.write(localeval.eval(config.get("mbnames", "footer")))
|
'foldername': foldername})
|
||||||
file.close()
|
file.write(localeval.eval(config.get("mbnames", "sep")).join(itemlist))
|
||||||
|
file.write(localeval.eval(config.get("mbnames", "footer")))
|
||||||
|
file.close()
|
||||||
|
finally:
|
||||||
|
mblock.release()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user