aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/testing/yatest_common/yatest/common/misc.py
blob: 20d3725ac95bca91d020bceeef3659a1b7d0bfc7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import functools


def first(it):
    for d in it:
        if d:
            return d


def lazy(func):
    res = []

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        if not res:
            res.append(func(*args, **kwargs))
        return res[0]

    return wrapper