Prepare for serialisation - returns a dictionary
322576
def _deflate(cls):
        """"""
        data = {k: v for k, v in vars(cls).items() if not k.startswith("_")}
        return {Constants.CONFIG_KEY: data}
976996
def serialize_dictionary(dictionary):
    
    string_value = {}
    for k, v in list(dictionary.items()):
        if isinstance(v, QUrl):
            string_value[k] = v.toString()
        elif isinstance(v, (QDate, QDateTime)):
            string_value[k] = v.toString(Qt.ISODate)
        elif isinstance(v, datetime):
            string_value[k] = v.isoformat()
        elif isinstance(v, date):
            string_value[k] = v.isoformat()
        elif isinstance(v, dict):
            # Recursive call
            string_value[k] = serialize_dictionary(v)
        else:
            string_value[k] = v
    return string_value
1153719
def to_dict(self):
        
        with self._lock:
            result = {}
            if self._gpayload:
                result.update(self._gpayload)
            if self._tpayload:
                result.update(getattr(self._tpayload, "context", {}))
            return result
1003085
def serialize(self) -> dict:
        
        data = {**self}
        if "attachments" in self:
            data["attachments"] = json.dumps(self["attachments"])
        return data
1198330
def to_dict(self):
        
        cache_info = None
        if self.cache_info:
            cache_info = self.cache_info.to_dict()
        return {
            'cache_info': cache_info,
            'html': self.html,
            'scraped': self.scraped,
            'raw': self.raw
        }
207778
def serialize(cls, conversation):
        
        return {
            'namespace': conversation.namespace,
            'units': sorted(conversation.units),
            'scope': conversation.scope,
        }
806576
def prepare(self, data):
        
        result = {}

        if not self.fields:
            # No fields specified. Serialize everything.
            return data

        for fieldname, lookup in self.fields.items():
            if isinstance(lookup, SubPreparer):
                result[fieldname] = lookup.prepare(data)
            else:
                result[fieldname] = self.lookup_data(lookup, data)

        return result
76308
def _serialize_dict(cls, dict_):
        

        obj_serialized = {}

        for key in dict_.keys():
            item_serialized = cls.serialize(dict_[key])

            if item_serialized is not None:
                key = key.rstrip(cls._SUFFIX_KEY_OVERLAPPING)
                key = key.lstrip(cls._PREFIX_KEY_PROTECTED)
                obj_serialized[key] = item_serialized

        return obj_serialized
1346875
def to_dict(self):
        """"""
        d = {}
        if self.valid_since is not None:
            d['@valid_since'] = datetime_to_str(self.valid_since)
        for attr_list, prefix in [(self.attributes, '@'), (self.children, '')]:
            for attr in attr_list:
                value = getattr(self, attr)
                if isinstance(value, Serializable):
                    value = value.to_dict()
                if value or isinstance(value, (bool, int, long)):
                    d[prefix + attr] = value
        if hasattr(self, 'display') and self.display:
            d['display'] = self.display
        return d
803700
def serialize(dictionary):
    

    data = []
    for key, value in dictionary.items():
        data.append('{0}="{1}"'.format(key, value))
    return ', '.join(data)
1293446
def serialize_detail(self, data):
        
        if data is None:
            return ''

        # Check for a ``Data``-like object. We should assume ``True`` (all
        # data gets prepared) unless it's explicitly marked as not.
        if not getattr(data, 'should_prepare', True):
            prepped_data = data.value
        else:
            prepped_data = self.prepare(data)

        return self.serializer.serialize(prepped_data)
1362200
def serialize(self):
        """"""

        keys = self._all_keys()
        serdata = {}
        for fieldname, value in self._data.items():
            serdata[fieldname] = getattr(type(self), fieldname).python_to_cache(value)
        return json.dumps(serdata)
1343827
def serialize(self, as_dict=False, sort=None):
        
        files = getattr(self, 'files', self.run())

        if as_dict:
            return dict((fn, p.to_dict()) for fn, p in files.items())

        # generate a list
        data = (p.to_dict() for p in files.values())

        if callable(sort):
            return sorted(data, key=sort)

        elif sort is True:
            return sorted(data)

        return list(data)
1214732
def serialize_dict(self, value):
        

        # Check if this is a dict
        if not isinstance(value, dict):
            return value

        # Loop over all the values and serialize them
        return {
            dict_key: self.serialize_value(dict_value)
            for dict_key, dict_value in value.items()
        }
743004
def serialize(self, include_class=True, save_dynamic=False, **kwargs):
        
        json_dict = super(Singleton, self).serialize(
            include_class=include_class,
            save_dynamic=save_dynamic,
            **kwargs
        )
        json_dict['_singleton_id'] = self._singleton_id
        return json_dict
723014
def serialize(self):
        
        return {'day': self.day, 'other': self.other,
                'timeranges': [t.serialize() for t in self.timeranges]}
1163973
def _serialize(self):
        
        result = { a: getattr(self, a) for a in type(self).properties
            if type(self).properties[a].mutable }

        for k, v in result.items():
            if isinstance(v, Base):
                result[k] = v.id

        return result