Team Ai
Apppublic

Multimedika/Bot_Development

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
utils.py30 linesDownload Raw Back to utils
1from uuid import uuid42 3def pipe(data, *funcs):4    """ Pipe a value through a sequence of functions5 6    I.e. ``pipe(data, f, g, h)`` is equivalent to ``h(g(f(data)))``7 8    We think of the value as progressing through a pipe of several9    transformations, much like pipes in UNIX10 11    ``$ cat data | f | g | h``12 13    >>> double = lambda i: 2 * i14    >>> pipe(3, double, str)15    '6'16 17    See Also:18        compose19        thread_first20        thread_last21    """22    for func in funcs:23        data = func(data)24    return data25 26def generate_uuid(use_hex=False):27    if use_hex:28        return str(uuid4().hex)29    else:30        return str(uuid4())