michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: def parse_options_defaults(options, preferencesBranch): michael@0: # this returns a unicode string michael@0: pref_list = [] michael@0: michael@0: for pref in options: michael@0: if ('value' in pref): michael@0: value = pref["value"] michael@0: michael@0: if isinstance(value, float): michael@0: continue michael@0: elif isinstance(value, bool): michael@0: value = str(pref["value"]).lower() michael@0: elif isinstance(value, str): # presumably ASCII michael@0: value = "\"" + unicode(pref["value"]) + "\"" michael@0: elif isinstance(value, unicode): michael@0: value = "\"" + pref["value"] + "\"" michael@0: else: michael@0: value = str(pref["value"]) michael@0: michael@0: pref_list.append("pref(\"extensions." + preferencesBranch + "." + pref["name"] + "\", " + value + ");") michael@0: michael@0: return "\n".join(pref_list) + "\n"