python tool: refactor
This commit is contained in:
parent
897e6f587c
commit
77fa0992a8
|
@ -36,7 +36,6 @@ def editnote(note):
|
||||||
|
|
||||||
if newcontent != content:
|
if newcontent != content:
|
||||||
|
|
||||||
listnotes()
|
|
||||||
subprocess.call(settings["commands"]["diff"] + ["data/backupnote.md", "data/note.md"])
|
subprocess.call(settings["commands"]["diff"] + ["data/backupnote.md", "data/note.md"])
|
||||||
|
|
||||||
note["content"] = newcontent
|
note["content"] = newcontent
|
||||||
|
@ -53,7 +52,6 @@ def editnote(note):
|
||||||
else:
|
else:
|
||||||
writetextfile("data/local.json", json.dumps(data))
|
writetextfile("data/local.json", json.dumps(data))
|
||||||
else:
|
else:
|
||||||
listnotes()
|
|
||||||
print("no change")
|
print("no change")
|
||||||
|
|
||||||
settings = json.loads(readtextfile("settings.json"))
|
settings = json.loads(readtextfile("settings.json"))
|
||||||
|
@ -80,7 +78,7 @@ while not (command == "quit" or command == "exit" or command == "q"):
|
||||||
index = int(command)
|
index = int(command)
|
||||||
note = data[index]
|
note = data[index]
|
||||||
except:
|
except:
|
||||||
note = next((x for x in data if x["title"] == command), None)
|
note = next((note for note in data if note["title"] == command), None)
|
||||||
|
|
||||||
if note:
|
if note:
|
||||||
editnote(note)
|
editnote(note)
|
||||||
|
@ -96,7 +94,5 @@ while not (command == "quit" or command == "exit" or command == "q"):
|
||||||
}
|
}
|
||||||
data.insert(0, note)
|
data.insert(0, note)
|
||||||
editnote(note)
|
editnote(note)
|
||||||
else:
|
|
||||||
listnotes()
|
|
||||||
|
|
||||||
command = input("> ")
|
command = input("> ")
|
||||||
|
|
Loading…
Reference in New Issue