addon-sdk/source/python-lib/cuddlefish/options_defaults.py
author Phil Ringnalda <philringnalda@gmail.com>
Tue, 19 Nov 2013 14:38:29 -0800
changeset 171124 78fb435aa0d2a1130271ae2016c3c98042c1d887
parent 156486 a5d574cfbeacc7810eabeb56b4166516ef6b1314
child 181178 c8475293c1735965d7f43149af5884989d8600e2
permissions -rw-r--r--
Backed out 4 changesets (bug 672843) for xpcshell bustage Backed out changeset bbb7760083ae (bug 672843) Backed out changeset eaf2fd75d7fc (bug 672843) Backed out changeset eb08cc206b8d (bug 672843) Backed out changeset 6a0e4afd52ab (bug 672843)

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

def parse_options_defaults(options, jetpack_id):
    # this returns a unicode string
    pref_list = []

    for pref in options:
        if ('value' in pref):
            value = pref["value"]

            if isinstance(value, float):
                continue
            elif isinstance(value, bool):
                value = str(pref["value"]).lower()
            elif isinstance(value, str): # presumably ASCII
                value = "\"" + unicode(pref["value"]) + "\""
            elif isinstance(value, unicode):
                value = "\"" + pref["value"] + "\""
            else:
                value = str(pref["value"])

            pref_list.append("pref(\"extensions." + jetpack_id + "." + pref["name"] + "\", " + value + ");")

    return "\n".join(pref_list) + "\n"