diff --git a/joy/gui/main.py b/joy/gui/main.py index 82d0c3f..5dc8ac4 100755 --- a/joy/gui/main.py +++ b/joy/gui/main.py @@ -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) diff --git a/joy/gui/world.py b/joy/gui/world.py index 9c42246..1c87106 100644 --- a/joy/gui/world.py +++ b/joy/gui/world.py @@ -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 ', ) 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)