Bug 865244 - Implement AudioContext.destination.maxChannelCount. r=ehsan
[gecko.git] / config / buildlist.py
blob3ddf22f33294bf99f5388803a3b2b647b7841e2e
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> ...]
9 '''
10 from __future__ import print_function
12 import sys
13 import os
14 from utils import lockFile
16 def addEntriesToListFile(listFile, entries):
17 """Given a file |listFile| containing one entry per line,
18 add each entry in |entries| to the file, unless it is already
19 present."""
20 lock = lockFile(listFile + ".lck")
21 try:
22 if os.path.exists(listFile):
23 f = open(listFile)
24 existing = set(x.strip() for x in f.readlines())
25 f.close()
26 else:
27 existing = set()
28 f = open(listFile, 'a')
29 for e in entries:
30 if e not in existing:
31 f.write("{0}\n".format(e))
32 existing.add(e)
33 f.close()
34 finally:
35 lock = None
37 if __name__ == '__main__':
38 if len(sys.argv) < 3:
39 print("Usage: buildlist.py <list file> <entry> [<entry> ...]",
40 file=sys.stderr)
41 sys.exit(1)
42 addEntriesToListFile(sys.argv[1], sys.argv[2:])