The aim of it is to be the quickest way to add to existing notes via SSHh.
Is this code in Python style? Am I missing any methods that would make the code simpler or legible?
#! /usr/bin/python3
#Maintain: [email protected]
#Purpose: A simple way to add entries to existing files
#Usage: Write the name of the file you intend to add to.
#Future: A list of editable files when the program opens
from sys import argv
import datetime
import os,errno
import os.path
import contextlib
script, typed = argv
filename = typed+".txt"
savelocation = os.path.join('/home/user/',filename)
print(savelocation)
print("Aditor: a digital typewriter, Type: d when done")
date = str(datetime.datetime.now().date())
with open("/tmp/tempfile.txt","a+") as target:
target.write("\n")
target.write(date)
while True:
entry=input()
target.write("\n")
if entry in ['done','d']:
break
else:
target.write(entry)
target = open("/tmp/tempfile.txt","r")
f = open(filename, "a")
f.write(target.read())
f.close()
target.close()
print("Entry saved.")
with contextlib.suppress(FileNotFoundError):
os.remove("/tmp/tempfile.txt")
tmuxorscreen. \$\endgroup\$