addon.py 文件源码

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

项目:mccurse 作者: khardix 项目源码 文件源码
def to_yaml(cls: Type['File'], instance: 'File') -> Mapping:
        """Represent the instance as YAML node.

        Keyword arguments:
            instance: The File to be represented.

        Returns:
            YAML representation of the instance.
        """

        # Dump mod part
        columns = (str(c).split('.')[-1] for c in Mod.__table__.columns)
        yml = {f: getattr(instance.mod, f) for f in columns}

        # Dump the file part
        yml['file'] = attr.asdict(instance)
        for field in ('mod',):
            del yml['file'][field]

        return yml
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号