Mapytex/mapytex/calculus/core/coroutine.py

34 lines
621 B
Python
Raw Normal View History

2018-01-21 08:26:34 +00:00
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2017 lafrite <lafrite@Poivre>
#
# Distributed under terms of the MIT license.
"""
Coroutine and sink tools
"""
from functools import wraps
__all__ = ["coroutine", "STOOOP", "RESTAAART"]
def coroutine(func):
@wraps(func)
2018-03-13 11:43:48 +00:00
def start(*args, **kwargs):
cr = func(*args, **kwargs)
2018-01-21 08:26:34 +00:00
next(cr)
return cr
return start
class STOOOP(Exception): pass
class RESTAAART(Exception): pass
2018-01-21 08:26:34 +00:00
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del