home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- from __future__ import with_statement
- from types import GeneratorType
- import collections
- import os.path as os
- import sys
-
- def runfile(filename):
- filename = os.path.expanduser(filename)
-
- try:
- f = _[1]
- contents = f.read()
- runscript(contents, filename)
- finally:
- pass
-
-
-
- def runscript(script, filename):
- script_globals = { }
- exec script in script_globals
-
- try:
- main = script_globals['main']
- except KeyError:
- raise AssertionError('script %r did not define a main() function' % filename)
-
- if not hasattr(main, '__call__'):
- raise AssertionError('script %r main is not callable')
- hasattr(main, '__call__')
- exec 'main()' in script_globals
-
-
- class Trampoline(object):
- running = False
-
- def __init__(self):
- self.queue = collections.deque()
-
-
- def add(self, coroutine):
- self.schedule(coroutine)
-
-
- def run(self):
- result = None
- self.running = True
-
- try:
- while self.running and self.queue:
- func = self.queue.popleft()
- result = func()
- return result
- finally:
- self.running = False
-
-
-
- def stop(self):
- self.running = False
-
-
- def schedule(self, coroutine, stack = (), value = None, *exc):
-
- def resume():
-
- try:
- if exc:
- val = coroutine.throw(value, *exc)
- else:
- val = coroutine.send(value)
- except:
- if stack:
- self.schedule(stack[0], stack[1], *sys.exc_info())
- else:
- raise
-
- print 'val is', val
- if isinstance(val, GeneratorType):
- self.schedule(val, (coroutine, stack))
- elif stack:
- self.schedule(stack[0], stack[1], val)
- elif hasattr(val, 'schedule'):
- print 'stopping', stack
- val.schedule(self)
- self.stop()
- self.schedule(coroutine, stack)
-
-
- self.queue.append(resume)
-
-
-
- def main():
- t = Trampoline()
- sys.path.append('src/tests/scripts')
- import open_im_window
- t.add(open_im_window.main())
- import wx
-
- class MyApp((wx.App,)):
-
- def __init__(self, trampoline):
- self.trampoline = trampoline
- wx.App.__init__(self)
-
-
- def OnInit(self):
- self.trampoline.run()
-
-
- a = MyApp(t)
- a.MainLoop()
-
- if __name__ == '__main__':
- main()
-
-