File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/jaraco/functools/__pycache__/__init__.cpython-310.pyc
Back
o ;j�J � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl Z d dlmZ d dlm Z d dlZdd� Zdd� Ze�� fd d �Zdd� Zd d� Zdd� Zdd� Ze d�ZdLdd�ZG dd� d�Zdd� Zedd� ej�Zd d� d d!fd"d#�Zd$d%� Zd&d'� Zd(d)� Z dMd*d+�Z!d,d-� Z"d.d/� Z#ddd0�d1d2�Z$d3d4� Z%ej&d5d6� �Z'e'�(ej)j�d7d8� �Z*e%d9�d:d;�Z+d<d=� Z,ej&d>d?� �Z-e-j(dNdBd8��Z*dCdD� Z.e d�ZdOdHdI�Z/dJdK� Z0dS )P� )�annotationsN)�Callable)�TypeVarc G s dd� }t �|| �S )u Compose any number of unary functions into a single unary function. Comparable to `function composition <https://en.wikipedia.org/wiki/Function_composition>`_ in mathematics: ``h = g ∘ f`` implies ``h(x) = g(f(x))``. In Python, ``h = compose(g, f)``. >>> import textwrap >>> expected = str.strip(textwrap.dedent(compose.__doc__)) >>> strip_and_dedent = compose(str.strip, textwrap.dedent) >>> strip_and_dedent(compose.__doc__) == expected True Compose also allows the innermost function to take arbitrary arguments. >>> round_three = lambda x: round(x, ndigits=3) >>> f = compose(round_three, int.__truediv__) >>> [f(3*x, x+1) for x in range(1,10)] [1.5, 2.0, 2.25, 2.4, 2.5, 2.571, 2.625, 2.667, 2.7] c s � �fdd�S )Nc s � �| i |���S �N� ��args�kwargs��f1�f2r �M/opt/saltstack/salt/lib/python3.10/site-packages/jaraco/functools/__init__.py�<lambda>, s z.compose.<locals>.compose_two.<locals>.<lambda>r r r r r �compose_two+ s zcompose.<locals>.compose_two)� functools�reduce)�funcsr r r r �compose s r c s* t �� �� �fdd����fdd��_�S )ad Decorate func so it's only ever called the first time. This decorator can ensure that an expensive or non-idempotent function will not be expensive on subsequent calls and is idempotent. >>> add_three = once(lambda a: a+3) >>> add_three(3) 6 >>> add_three(9) 6 >>> add_three('12') 6 To reset the stored value, simply clear the property ``saved_result``. >>> del add_three.saved_result >>> add_three(9) 12 >>> add_three(8) 12 Or invoke 'reset()' on it. >>> add_three.reset() >>> add_three(-3) 0 >>> add_three(0) 0 c s t �d�s � | i |���_�jS �N�saved_result)�hasattrr r ��func�wrapperr r r Q s zonce.<locals>.wrapperc s t � ��d�S r )�vars�__delitem__r )r r r r W s zonce.<locals>.<lambda>)r �wraps�reset�r r r r �once1 s r c s&