__init__.py 文件源码

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

项目:unsonic 作者: redshodan 项目源码 文件源码
def makeBody(self, attrs, child, status):
        body = ET.Element("subsonic-response")
        attrs_ = {"status": "ok" if status is True else "failed",
                  "xmlns": "http://subsonic.org/restapi",
                  "version": PROTOCOL_VERSION,
                  "unsonic": UNSONIC_PROTOCOL_VERSION}
        attrs_.update(attrs)
        for key, value in attrs_.items():
            body.set(key, value)
        if status is not True and status is not False:
            error = ET.Element("error")
            if isinstance(status[0], tuple):
                error.set("code", status[0][0])
                error.set("message", "%s: %s" % (status[0][1], status[1]))
            else:
                error.set("code", status[0])
                error.set("message", status[1])
            body.append(error)
        if child is not None:
            body.append(child)
        return "%s%s\n" % (XML_HEADER, ET.tostring(body).decode("utf-8"))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号