Given an OptionTree, convert it into the equivalent dictionary format.
512459
def tree_to_dict(cls, tree):
        
        specs = {}
        for k in tree.keys():
            spec_key = '.'.join(k)
            specs[spec_key] = {}
            for grp in tree[k].groups:
                kwargs = tree[k].groups[grp].kwargs
                if kwargs:
                    specs[spec_key][grp] = kwargs
        return specs
180104
def _options(self, **kwargs):
        
        def _format_fq(d):
            for k,v in d.items():
                if isinstance(v, list):
                    d[k] = ' '.join(map(lambda x: '"' + x + '"', v))
                else:
                    d[k] = '"' + v + '"'
            values = []
            for k,v in d.items():
                value = '%s:(%s)' % (k,v)
                values.append(value)
            values = ' AND '.join(values)
            return values
        
        kwargs = self._utf8_encode(kwargs)
        kwargs = self._bool_encode(kwargs)
        
        values = ''
        
        for k, v in kwargs.items():
            if k is 'fq' and isinstance(v, dict):
                v = _format_fq(v)
            elif isinstance(v, list):
                v = ','.join(v)
            values += '%s=%s&' % (k, v)
        
        return values
214224
def _from_dict(cls, _dict):
        """"""
        args = {}
        xtra = _dict.copy()
        if 'generic' in _dict:
            args['generic'] = [
                DialogNodeOutputGeneric._from_dict(x)
                for x in (_dict.get('generic'))
            ]
            del xtra['generic']
        if 'modifiers' in _dict:
            args['modifiers'] = DialogNodeOutputModifiers._from_dict(
                _dict.get('modifiers'))
            del xtra['modifiers']
        args.update(xtra)
        return cls(**args)
1022355
def _format_subtree(self, subtree):
        """"""
        subtree['children'] = list(subtree['children'].values())
        for child in subtree['children']:
            self._format_subtree(child)
        return subtree
1235325
def template_to_dict_alt(tree, title):
    
    box = []
    part = []

    for item in tree.iter():

        if item.tag == 'part':
            if part:
                box.append(part)
            part = []

        if item.tag == 'name' or item.tag == 'value':
            for attr in item.keys():
                part.append({attr: item.get(attr)})

            if item.text:
                part.append(item.text.strip())

            if item.tail:
                part.append(item.tail.strip())

    if part:
        box.append(part)

    return {title.strip(): box}
875582
def define_options(self, names, parser_options=None):
        """"""
        def copy_option(options, name):
            return {k: v for k, v in options[name].items()}
        if parser_options is None:
            parser_options = {}
        options = {}
        for name in names:
            try:
                option = copy_option(parser_options, name)
            except KeyError:
                option = copy_option(shared_options, name)
            try:
                options.update({option['clarg']: option})
            except TypeError:
                options.update({option['clarg'][0]: option})
        return options
381033
def _asdict(self):
    """"""
    # Start with any default values we have, and override with loaded values,
    # and then override with flag values.
    retval = {key: self._declarations[key].default_value for
              key in self._declarations if self._declarations[key].has_default}
    retval.update(self._loaded_values)
    # Only update keys that are declared so we don't allow injecting
    # un-declared keys via commandline flags.
    for key, value in self._modules['six'].iteritems(self._flag_values):
      if key in self._declarations:
        retval[key] = value
    return retval
1069105
def _repack_options(options):
    '''
    
    '''
    return dict(
        [
            (six.text_type(x), _normalize(y))
            for x, y in six.iteritems(salt.utils.data.repack_dictlist(options))
        ]
    )
562733
def _default_dict(self):
        """"""
        options = {}
        for attr, _, _, default, multi, _ in self._optiondict.values():
            if multi and default is None:
                options[attr] = []
            else:
                options[attr] = default
        return options
517621
def from_dict(cls, async):
        """"""
        async_options = decode_async_options(async)

        target, args, kwargs = async_options.pop('job')

        return cls(target, args, kwargs, **async_options)
264129
def dicttotext(d, sort=False, max = 0):
    """"""
    if sort:
        f = lambda x: sorted(x, key=lambda y: -1 * y[1])
    else:
        f = lambda x: x

    output = ""
    for i, (key, value) in enumerate(f(d.items())):
        output += key + "\t" + str(value) + "\n"
        if max != 0 and i >= max:
            break
    return output
899626
def as_dict(self):
        
        out = dict({})
        for key in self.keys():
            if self._has_delimiter(key):
                pk, ck = key.split(self._delimiter, 1)
                if self._has_delimiter(ck):
                    ck = ck.split(self._delimiter, 1)[0]
                if isinstance(self._values[pk], FlatDict) and pk not in out:
                    out[pk] = dict()
                if isinstance(self._values[pk][ck], FlatDict):
                    out[pk][ck] = self._values[pk][ck].as_dict()
                else:
                    out[pk][ck] = self._values[pk][ck]
            else:
                out[key] = self._values[key]
        return out
56949
private void convertOptions() throws TreeException {
	options = new Properties();
	ParseTreeNode optionList = parserTree.getChild("GrammarOptions").getChild(
		"GrammarOptionList");
	for (ParseTreeNode option : optionList.getChildren("GrammarOption")) {
	    String name = option.getChild("PropertyIdentifier").getText();
	    String value = option.getChild("Literal").getText();
	    if (value.startsWith("'") || value.startsWith("\"")) {
		value = value.substring(1, value.length() - 1);
	    }
	    options.put(name, value);
	}
	// normalizeToBNF = Boolean.valueOf(options.getProperty(
	// "grammar.normalize_to_bnf", "true"));
    }
834559
def from_dict(cls, d):
        """"""
        return cls(
            d['rargname'],
            d['value'],
            list(d.get('properties', {}).items()),
            d.get('optional', False)
        )
1327579
def parse_options(s):
    
    options = {}
    for option in s.split(':'):
        if '=' in option:
            key, val = option.split('=')
            options[str(key).strip()] = val.strip()
    return options
1192398
def as_dict(self) -> Dict[str, Any]:
        
        return dict((opt.name, opt.value()) for name, opt in self._options.items())
1328091
def merge_options_to_dict(options):
    
    merged_options = {}
    for obj in options:
        if isinstance(obj,dict):
            new_opts = obj
        else:
            new_opts = {obj.key: obj.kwargs}

        merged_options = merge_option_dicts(merged_options, new_opts)
    return merged_options