Move load_stack() to StackDisplayWorld.
This commit is contained in:
parent
da03f60dca
commit
ebb731126d
|
|
@ -113,12 +113,6 @@ def grand_reset(s, e, d):
|
||||||
return stack, 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()
|
D = initialize()
|
||||||
for func in (
|
for func in (
|
||||||
reset_log,
|
reset_log,
|
||||||
|
|
@ -129,12 +123,8 @@ for func in (
|
||||||
):
|
):
|
||||||
D[func.__name__] = func
|
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)
|
t = TextViewerWidget(world, **defaults)
|
||||||
log_window = tk.Toplevel()
|
log_window = tk.Toplevel()
|
||||||
log_window.protocol("WM_DELETE_WINDOW", log_window.withdraw)
|
log_window.protocol("WM_DELETE_WINDOW", log_window.withdraw)
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,11 @@ class World(object):
|
||||||
class StackDisplayWorld(World):
|
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)
|
World.__init__(self, stack, dictionary, text_widget)
|
||||||
self.repo = repo
|
self.repo = repo
|
||||||
self.filename = filename
|
|
||||||
self.relative_STACK_FN = rel_filename
|
self.relative_STACK_FN = rel_filename
|
||||||
|
|
||||||
def interpret(self, command):
|
def interpret(self, command):
|
||||||
|
|
@ -126,3 +127,8 @@ class StackDisplayWorld(World):
|
||||||
committer='Simon Forman <forman.simon@gmail.com>',
|
committer='Simon Forman <forman.simon@gmail.com>',
|
||||||
)
|
)
|
||||||
print >> sys.stderr, commit_id
|
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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue