Back to index

enigmail  1.4.3
Functions
buildlist Namespace Reference

Functions

def addEntriesToListFile

Function Documentation

def buildlist.addEntriesToListFile (   listFile,
  entries 
)
Given a file |listFile| containing one entry per line,
add each entry in |entries| to the file, unless it is already
present.

Definition at line 48 of file buildlist.py.

00048 
00049 def addEntriesToListFile(listFile, entries):
00050   """Given a file |listFile| containing one entry per line,
00051   add each entry in |entries| to the file, unless it is already
00052   present."""
00053   lock = lockFile(listFile + ".lck")
00054   try:
00055     if os.path.exists(listFile):
00056       f = open(listFile)
00057       existing = set([x.strip() for x in f.readlines()])
00058       f.close()
00059     else:
00060       existing = set()
00061     f = open(listFile, 'a')
00062     for e in entries:
00063       if e not in existing:
00064         f.write("%s\n" % e)
00065         existing.add(e)
00066     f.close()
00067   finally:
00068     lock = None

Here is the call graph for this function:

Here is the caller graph for this function: