Simplify API.

This commit is contained in:
Eadaen1 2020-09-14 23:51:52 +01:00
parent 0e3b34d0cd
commit cf5067dca8
2 changed files with 12 additions and 17 deletions

View file

@ -170,15 +170,6 @@ class History:
def clear(self):
"""Wipes the current session from both the disk and memory."""
self.wipe_disk()
self.wipe_memory()
def wipe_disk(self):
"""Wipes the current session's history from the disk."""
pass
def wipe_memory(self):
"""Reinitialises History object with blank commands."""
pass
def remake_file(self):

View file

@ -327,9 +327,9 @@ class JsonCommandField(cabc.Sequence):
if isinstance(rtn, xlj.LJNode):
rtn = rtn.load()
queue.popleft()
return rtn
else:
return ""
return rtn
def i_am_at_the_front(self):
"""Tests if the command field is at the front of the queue."""
@ -508,14 +508,18 @@ class JsonHistory(History):
while self.gc.is_alive(): # while waiting for gc.
time.sleep(0.1) # don't monopolize the thread (or Python GIL?)
def wipe_disk(self):
def clear(self):
def wipe_disk(hist):
try:
os.remove(self.filename)
os.remove(hist.filename)
except FileNotFoundError:
pass
def wipe_memory(self): # todo is this enough?
self.buffer = []
def wipe_memory(hist): # todo is this enough?
hist.buffer = []
wipe_disk(self)
wipe_memory(self)
def remake_file(self):
meta = dict()