katana.py 文件源码

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

项目:warriorframework 作者: warriorframework 项目源码 文件源码
def saveFile(filename, subdirs, filetype):
    dir_path = getDirectoryPath(subdirs)
    xmldom = parseString("".join(request.body))
    if filename != "":
        cfg = readconfig()
        xmldir = cfg[filetype]
        indented_xml = "".join(xmldom.toprettyxml(newl='\n'))
        corrected_xml = remove_extra_newlines_char_xml(indented_xml)
        print corrected_xml
        with open(xmldir + dir_path + os.sep + filename, "w") as f:
            f.write(corrected_xml)
        output = {"success": True,
                  "path": filename}
    else:
        output = {"success": False,
                  "error": "Save called without a filename or content!"}

    return output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号