1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
'''A generic script to add entries to a file
6
if the entry does not already exist.
8
Usage: buildlist.py <filename> <entry> [<entry> ...]
13
from utils import lockFile
15
def addEntriesToListFile(listFile, entries):
16
"""Given a file |listFile| containing one entry per line,
17
add each entry in |entries| to the file, unless it is already
19
lock = lockFile(listFile + ".lck")
21
if os.path.exists(listFile):
23
existing = set([x.strip() for x in f.readlines()])
27
f = open(listFile, 'a')
36
if __name__ == '__main__':
38
print >>sys.stderr, "Usage: buildlist.py <list file> <entry> [<entry> ...]"
40
addEntriesToListFile(sys.argv[1], sys.argv[2:])