diff --git a/setup.py b/setup.py index 2911246..6f733bc 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ except ImportError: setup( name="syndicate-py", - version="0.7.1", + version="0.7.2", author="Tony Garnock-Jones", author_email="tonyg@leastfixedpoint.com", license="GNU General Public License v3 or later (GPLv3+)", diff --git a/syndicate/__init__.py b/syndicate/__init__.py index a548f3c..6ca6ac2 100644 --- a/syndicate/__init__.py +++ b/syndicate/__init__.py @@ -3,4 +3,45 @@ __path__ = __import__('pkgutil').extend_path(__path__, __name__) # This is 'import *' in order to effectively re-export preserves as part of this module's API. from preserves import * +def __setup(): + from .actor import _active, Turn + from .metapy import staticproperty + from types import FunctionType + import sys + + class turn: + @staticproperty + def active(): + return _active.turn + + @staticproperty + def log(): + return _active.turn.log + + def run(facet, action): + Turn.run(facet, action) + + def external(facet, action, loop=None): + Turn.external(facet, action, loop=loop) + + def active_facet(): + return _active.turn._facet + + def install_definition(name, definition): + def handler(*args, **kwargs): + return definition(_active.turn, *args, **kwargs) + 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() + from . import relay diff --git a/syndicate/turn.py b/syndicate/turn.py deleted file mode 100644 index 96af4bd..0000000 --- a/syndicate/turn.py +++ /dev/null @@ -1,32 +0,0 @@ -from .actor import Turn - -def __setup(): - from .actor import _active - from types import FunctionType - import sys - - mod = sys.modules[__name__] - - def install_definition(name, definition): - def handler(*args, **kwargs): - return definition(_active.turn, *args, **kwargs) - setattr(mod, name, handler) - - for (name, definition) in Turn.__dict__.items(): - if name[0] == '_': - continue - elif type(definition) == FunctionType: - install_definition(name, definition) - else: - pass - -__setup() - -def run(facet, action): - Turn.run(facet, action) - -def external(facet, action, loop=None): - Turn.external(facet, action, loop=loop) - -def active_facet(): - return Turn.active._facet