Convert string to dictionary.
541288
def from_string(self, value):
        """"""
        # Remove optional {}
        if value.startswith('{') and value.endswith('}'):
            text = value[1:-1].strip()
        else:
            text = value.strip()
        # Result is a dictionary
        result = {}
        # Convert each pair of <int>:<float> into a key, value pair.
        for val in text.split(','):
            tokens = val.split(':')
            if len(tokens) != 2:
                raise ValueError('invalid entry in dictionary: ' + val)
            result[str(int(tokens[0].strip()))] = float(tokens[1].strip())
        return result
1173565
def _unwrap_dict(dictionary, index_string):
    '''
    
    '''
    index = index_string.split(',')
    for k in index:
        dictionary = dictionary[k]
    return dictionary
549290
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'element') and self.element is not None:
            _dict['element'] = self.element
        return _dict
331116
def pretty_dict_str(d, indent=2):
    """"""
    b = StringIO()
    write_pretty_dict_str(b, d, indent=indent)
    return b.getvalue()
532254
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'class_name') and self.class_name is not None:
            _dict['class'] = self.class_name
        return _dict
986816
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'document_tone') and self.document_tone is not None:
            _dict['document_tone'] = self.document_tone._to_dict()
        if hasattr(self, 'sentences_tone') and self.sentences_tone is not None:
            _dict['sentences_tone'] = [
                x._to_dict() for x in self.sentences_tone
            ]
        return _dict
291783
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'text') and self.text is not None:
            _dict['text'] = self.text
        if hasattr(self, 'entities') and self.entities is not None:
            _dict['entities'] = [x._to_dict() for x in self.entities]
        if hasattr(self, 'keywords') and self.keywords is not None:
            _dict['keywords'] = [x._to_dict() for x in self.keywords]
        return _dict
95534
def string_to_state(s):
    """"""
    s = lexer(s)
    attrs = {}
    while True:
        if s.cur == '>':
            attrs['start'] = True
            s.pos += 1
        elif s.cur == '@':
            attrs['accept'] = True
            s.pos += 1
        else:
            break
    x = parse_symbol(s)
    parse_end(s)
    return x, attrs
1221139
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'values') and self.values is not None:
            _dict['values'] = [x._to_dict() for x in self.values]
        if hasattr(self, 'pagination') and self.pagination is not None:
            _dict['pagination'] = self.pagination._to_dict()
        return _dict
750603
def asDict(self):
        """"""
        return {
            'isError': self.isError,
            'message': self.message,
            'values': self.values,
            'value': self.value,
        }
417458
def to_dict(self, trim=True):
        """"""
        if trim:
            return self._to_trimmed_dict()
        else:
            return dict(zip(DATASET_KEYS, self))
962988
def namespace_to_dict(o):
    """"""
    d = {}
    for k, v in o.__dict__.items():
        if not callable(v):
            d[k] = v
    return d
667500
def _parse_dict_string(self, string, key, default):
        """"""
        try:
            for item in string.split(','):
                k, v = item.rsplit('=', 1)
                if k == key:
                    try:
                        return int(v)
                    except ValueError:
                        return v
            return default
        except Exception:
            self.log.exception("Cannot parse dictionary string: %s" % string)
            return default
186514
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'text') and self.text is not None:
            _dict['text'] = self.text
        if hasattr(self, '_additionalProperties'):
            for _key in self._additionalProperties:
                _value = getattr(self, _key, None)
                if _value is not None:
                    _dict[_key] = _value
        return _dict
47074
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'words') and self.words is not None:
            _dict['words'] = [x._to_dict() for x in self.words]
        return _dict
932272
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'path') and self.path is not None:
            _dict['path'] = self.path
        return _dict
626333
def _stringlist_to_dictionary(input_string):
    '''
    
    '''
    li = str(input_string).split(',')
    ret = {}
    for item in li:
        pair = str(item).replace(' ', '').split('=')
        if len(pair) != 2:
            log.warning('Cannot process stringlist item %s', item)
            continue

        ret[pair[0]] = pair[1]
    return ret