util.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:game 作者: chrisnorman7 项目源码 文件源码
def dump_object(obj):
    """Get this object as a dict."""
    def should_dump(self, attr, value):
        """Decide if the attribute should be dumped or not."""
        column = self.__table__.c[attr.name]
        default = column.default
        if default is not None:
            return not value == default.arg
        elif self.__table__.c[attr.name].nullable and value is None:
            return False
        else:
            return True
    d = asdict(obj, filter=partial(should_dump, obj))
    if isinstance(
        obj,
        db.SpacialObject
    ) and 'type' in d:  # obj.type is not None
        d['type'] = d['type'].name
    return d
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号