client_api.py 文件源码

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

项目:solaris-ips 作者: oracle 项目源码 文件源码
def __prepare_json(status, op=None, schema=None, data=None, errors=None):
        """Prepare json structure for returning."""

        ret_json = {"status": status}

        if errors:
                if not isinstance(errors, list):
                        ret_json["errors"] = [errors]
                else:
                        ret_json["errors"] = errors
        if data:
                ret_json["data"] = data
        if op:
                op_schema = _get_pkg_output_schema(op)
                try:
                        jsonschema.validate(ret_json, op_schema)
                except jsonschema.ValidationError as e:
                        newret_json = {"status": EXIT_OOPS,
                            "errors": [{"reason": str(e)}]}
                        return newret_json
        if schema:
                ret_json["schema"] = schema

        return ret_json
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号