2018-11-20 19:45:27 +00:00
|
|
|
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
2021-08-18 17:35:49 +00:00
|
|
|
|
|
|
|
# This is 'import *' in order to effectively re-export preserves as part of this module's API.
|
|
|
|
from preserves import *
|
2021-08-19 02:59:04 +00:00
|
|
|
|
2021-12-25 22:14:26 +00:00
|
|
|
def __setup():
|
|
|
|
from .actor import _active, Turn
|
|
|
|
from .metapy import staticproperty
|
|
|
|
from types import FunctionType
|
|
|
|
import sys
|
|
|
|
|
|
|
|
class turn:
|
|
|
|
@staticproperty
|
|
|
|
def active():
|
2022-01-11 19:53:59 +00:00
|
|
|
t = getattr(_active, 'turn', False)
|
|
|
|
if t is False:
|
|
|
|
t = _active.turn = None
|
|
|
|
return t
|
2021-12-25 22:14:26 +00:00
|
|
|
|
|
|
|
@staticproperty
|
|
|
|
def log():
|
2022-01-11 19:53:59 +00:00
|
|
|
return turn.active.log
|
2021-12-25 22:14:26 +00:00
|
|
|
|
|
|
|
def run(facet, action):
|
2022-01-12 10:05:10 +00:00
|
|
|
return Turn.run(facet, action)
|
2021-12-25 22:14:26 +00:00
|
|
|
|
|
|
|
def external(facet, action, loop=None):
|
2022-01-12 10:05:10 +00:00
|
|
|
return Turn.external(facet, action, loop=loop)
|
2021-12-25 22:14:26 +00:00
|
|
|
|
|
|
|
def active_facet():
|
2022-01-11 19:53:59 +00:00
|
|
|
return turn.active._facet
|
2021-12-25 22:14:26 +00:00
|
|
|
|
|
|
|
def install_definition(name, definition):
|
|
|
|
def handler(*args, **kwargs):
|
2022-01-11 19:53:59 +00:00
|
|
|
return definition(turn.active, *args, **kwargs)
|
2021-12-25 22:14:26 +00:00
|
|
|
setattr(turn, name, handler)
|
|
|
|
|
|
|
|
for (name, definition) in Turn.__dict__.items():
|
|
|
|
if name[0] == '_':
|
|
|
|
continue
|
|
|
|
elif type(definition) == FunctionType:
|
|
|
|
install_definition(name, definition)
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return turn
|
|
|
|
|
|
|
|
turn = __setup()
|
|
|
|
|
2021-08-19 02:59:04 +00:00
|
|
|
from . import relay
|