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
评论列表
文章目录