toolkit/mozapps/installer/informulate.py

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:145992e0def7
1 #!/usr/bin/env python
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
6 import sys
7 import json
8 import buildconfig
9
10
11 def parse_cmdline(args):
12 """Take a list of strings in the format K=V and turn them into a python
13 dictionary"""
14 contents = {}
15 for arg in args:
16 key, s, value = arg.partition("=")
17 if s == '':
18 print "ERROR: Malformed command line key value pairing (%s)" % arg
19 exit(1)
20 contents[key.lower()] = value
21 return contents
22
23
24 def main():
25 if len(sys.argv) < 2:
26 print "ERROR: You must specify an output file"
27 exit(1)
28
29 all_key_value_pairs = {}
30 important_substitutions = [
31 'target_alias', 'target_cpu', 'target_os', 'target_vendor',
32 'host_alias', 'host_cpu', 'host_os', 'host_vendor',
33 'MOZ_UPDATE_CHANNEL', 'MOZ_APP_VENDOR', 'MOZ_APP_NAME',
34 'MOZ_APP_VERSION', 'MOZ_APP_MAXVERSION', 'MOZ_APP_ID',
35 'CC', 'CXX', 'LD', 'AS']
36
37 all_key_value_pairs = dict([(x.lower(), buildconfig.substs[x]) for x in important_substitutions])
38 all_key_value_pairs.update(parse_cmdline(sys.argv[2:]))
39
40 with open(sys.argv[1], "w+") as f:
41 json.dump(all_key_value_pairs, f, indent=2, sort_keys=True)
42 f.write('\n')
43
44
45 if __name__=="__main__":
46 main()

mercurial