toolkit/mozapps/installer/informulate.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/.
     6 import sys
     7 import json
     8 import buildconfig
    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
    24 def main():
    25     if len(sys.argv) < 2:
    26         print "ERROR: You must specify an output file"
    27         exit(1)
    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']
    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:]))
    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')
    45 if __name__=="__main__":
    46     main()

mercurial