Clean up code for saving story as plaintext

This commit is contained in:
Gnome Ann 2021-09-01 13:49:04 -04:00
parent 543acf9ba4
commit 8ae9304cda
1 changed files with 2 additions and 25 deletions

View File

@ -504,19 +504,7 @@ def download():
save_format = request.args.get("format", "json").strip().lower()
if(save_format == "plaintext"):
ln = len(vars.actions)
if(ln > 0):
chunks = collections.deque()
for key in reversed(vars.actions):
chunk = vars.actions[key]
chunks.appendleft(chunk)
if(ln > 0):
txt = vars.prompt + "".join(chunks)
elif(ln == 0):
txt = vars.prompt
txt = vars.prompt + "".join(vars.actions.values())
save = Response(txt)
save.headers.set('Content-Disposition', 'attachment', filename='%s.txt' % path.basename(vars.savedir))
return(save)
@ -1981,18 +1969,7 @@ def saveRequest(savpath):
"constant": wi["constant"]
})
ln = len(vars.actions)
if(ln > 0):
chunks = collections.deque()
for key in reversed(vars.actions):
chunk = vars.actions[key]
chunks.appendleft(chunk)
if(ln > 0):
txt = vars.prompt + "".join(chunks)
elif(ln == 0):
txt = vars.prompt
txt = vars.prompt + "".join(vars.actions.values())
# Write it
try: