Move load_stack() to StackDisplayWorld.

This commit is contained in:
Simon Forman 2018-07-14 20:47:04 -07:00
parent da03f60dca
commit ebb731126d
2 changed files with 9 additions and 13 deletions

View File

@ -113,12 +113,6 @@ def grand_reset(s, e, d):
return stack, e, d
def load_stack():
if os.path.exists(STACK_FN):
with open(STACK_FN) as f:
return pickle.load(f)
D = initialize()
for func in (
reset_log,
@ -129,12 +123,8 @@ for func in (
):
D[func.__name__] = func
stack = load_stack()
if stack is None:
world = StackDisplayWorld(repo, STACK_FN, REL_STACK_FN, dictionary=D)
else:
world = StackDisplayWorld(repo, STACK_FN, REL_STACK_FN, stack=stack, dictionary=D)
world = StackDisplayWorld(repo, STACK_FN, REL_STACK_FN, dictionary=D)
t = TextViewerWidget(world, **defaults)
log_window = tk.Toplevel()
log_window.protocol("WM_DELETE_WINDOW", log_window.withdraw)

View File

@ -101,10 +101,11 @@ class World(object):
class StackDisplayWorld(World):
def __init__(self, repo, filename, rel_filename, stack=(), dictionary=None, text_widget=None):
def __init__(self, repo, filename, rel_filename, dictionary=None, text_widget=None):
self.filename = filename
stack = self.load_stack() or ()
World.__init__(self, stack, dictionary, text_widget)
self.repo = repo
self.filename = filename
self.relative_STACK_FN = rel_filename
def interpret(self, command):
@ -126,3 +127,8 @@ class StackDisplayWorld(World):
committer='Simon Forman <forman.simon@gmail.com>',
)
print >> sys.stderr, commit_id
def load_stack(self):
if os.path.exists(self.filename):
with open(self.filename) as f:
return pickle.load(f)