Mapytex/mapytex/calculus/core/coroutine.py

40 lines
633 B
Python
Raw Permalink 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"]
2019-05-14 04:55:56 +00:00
2018-01-21 08:26:34 +00:00
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
2019-05-14 04:55:56 +00:00
2018-01-21 08:26:34 +00:00
return start
2019-05-14 04:55:56 +00:00
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