HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/celery/utils/__pycache__/graph.cpython-39.pyc
a

X>hQ#�@sndZddlmZddlmZddlmZmZdZGdd�d�Z	Gdd	�d	e
�ZGd
d�d�ZGdd
�d
�Z
dS)z Dependency graph implementation.�)�Counter)�dedent)�bytes_to_str�safe_str)�DOT�
CycleError�DependencyGraph�GraphFormatterc@s6eZdZdZed�ZdZdZdZdZ	ddd	�Z
d
ZdS)rz$Constants related to the dot format.z=
        {IN}{type} {id} {{
        {INp}graph [{attrs}]
    z{name}={value}z{INp}"{0}" [{attrs}]z {INp}"{0}" {dir} "{1}" [{attrs}]z, z--z->)�graph�digraphz{IN}}}N)�__name__�
__module__�__qualname__�__doc__r�HEAD�ATTR�NODE�EDGE�ATTRSEP�DIRS�TAIL�rr�</usr/local/lib/python3.9/site-packages/celery/utils/graph.pyr
s
rc@seZdZdZdS)rz)A cycle was detected in an acyclic graph.N)rr
rrrrrrrsrc@s�eZdZdZd+dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
d,dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZeZZd%d&�Zd-d)d*�ZdS).ra6A directed acyclic graph of objects and their dependencies.

    Supports a robust topological sort
    to detect the order in which they must be handled.

    Takes an optional iterator of ``(obj, dependencies)``
    tuples to build the graph from.

    Warning:
        Does not support cycle detection.
    NcCs(|pt�|_i|_|dur$|�|�dS�N)r	�	formatter�adjacent�update)�self�itrrrr�__init__*szDependencyGraph.__init__cCs|j�|g�dS)zAdd an object to the graph.N)r�
setdefault�r�objrrr�add_arc0szDependencyGraph.add_arccCs||�|�dS)z]Add an edge from object ``A`` to object ``B``.

        I.e. ``A`` depends on ``B``.
        N)�append)r�A�Brrr�add_edge4szDependencyGraph.add_edgecCs|j�|j�dS)zAdd nodes from another graph.N)rr)rr
rrr�connect;szDependencyGraph.connectc	Cs~t�}|��}dd�|D�}|D]}|�|�q |D]6}||}||D] }||}||krH|�||�qHq4dd�|��D�S)z�Sort the graph topologically.

        Returns:
            List: of objects in the order in which they must be handled.
        cSsi|]}|D]
}||�qqSrr)�.0�	component�noderrr�
<dictcomp>Hsz+DependencyGraph.topsort.<locals>.<dictcomp>cSsg|]}|d�qS)rr)r)�trrr�
<listcomp>S�z+DependencyGraph.topsort.<locals>.<listcomp>)r�	_tarjan72r#r'�_khan62)	rr
�
componentsZNCr*r+Znode_c�	successorZsuccessor_crrr�topsort?s�zDependencyGraph.topsortcCsNzt||�g}Wnty&YdS0||D]}|�|�|��q0t|�S)z5Return the valency (degree) of a vertex in the graph.r)�len�KeyErrorr$�
valency_of�sum)rr"�lr+rrrr7UszDependencyGraph.valency_ofcCsHt|�}|D]\}}|�|�q|D]\}}|D]}|�||�q0q$dS)z=Update graph with data from a list of ``(obj, deps)`` tuples.N)�listr#r')rrZtupsr"�_�deps�deprrrr_szDependencyGraph.updatecCsdd�|��D�S)z8Return generator that yields for all edges in the graph.css|]\}}|r|VqdSrr)r)r"Zadjrrr�	<genexpr>jr/z(DependencyGraph.edges.<locals>.<genexpr>)�items�rrrr�edgeshszDependencyGraph.edgescs�t��g}|D]"}||D]}�|d7<qq�fdd�|D�}|r�|��}|�|�||D]*}�|d8<�|dkrb|�|�qbqD|��|S)z�Perform Khan's simple topological sort algorithm from '62.

        See https://en.wikipedia.org/wiki/Topological_sorting
        �csg|]}�|s|�qSrr)r)r+��countrrr.wr/z+DependencyGraph._khan62.<locals>.<listcomp>r)r�popr$�reverse)r�resultr+r3�readyrrCrr1ls
zDependencyGraph._khan62cs:ggi��������fdd���D]}�|�q(�S)z�Perform Tarjan's algorithm to find strongly connected components.

        See Also:
            :wikipedia:`Tarjan%27s_strongly_connected_components_algorithm`
        cs�|�vrdSt��}|�|<t��}��|��|D]"}�|�t�|�|��|<q6|�|kr�t�|d��}g�|d�<��|�|D]}t���|<q�dSr)r5r$�min�tuple)r+�numZ	stack_posr3r*�item��lowrGr�stack�visitrrrP�s

z(DependencyGraph._tarjan72.<locals>.visitr�rr+rrMrr0�s

zDependencyGraph._tarjan72cs�t��|p|j��fdd�����fdd�}�����|��D]>\}}|sX|�j|�|D] }|�j|����||��q\q@�����dS)z�Convert the graph to DOT format.

        Arguments:
            fh (IO): A file, or a file-like object to write the graph to.
            formatter (celery.utils.graph.GraphFormatter): Custom graph
                formatter to use.
        cstt|��d�dS)N)�file)�printr)�s)�fhrr�P�sz!DependencyGraph.to_dot.<locals>.Pcs.��|��vr*�||������|��dSr)�label�add)Zfunr")rV�draw�seenrr�if_not_seen�sz+DependencyGraph.to_dot.<locals>.if_not_seenN)�setr�headr?�
terminal_noder+�edge�tail)rrUrr[r"r�reqr)rVrYrUrZr�to_dot�s
zDependencyGraph.to_dotcCs|jr|�|�S|Sr)rr!rrr�format�szDependencyGraph.formatcCs
t|j�Sr)�iterrr@rrr�__iter__�szDependencyGraph.__iter__cCs
|j|Sr�rrQrrr�__getitem__�szDependencyGraph.__getitem__cCs
t|j�Sr)r5rr@rrr�__len__�szDependencyGraph.__len__cCs
||jvSrrfr!rrr�__contains__�szDependencyGraph.__contains__cCs
|j��Sr)rr?r@rrr�_iterate_items�szDependencyGraph._iterate_itemscsd��fdd��D��S)N�
c3s|]}��|�VqdSr)�	repr_node)r)�Nr@rrr>�r/z+DependencyGraph.__repr__.<locals>.<genexpr>)�joinr@rr@r�__repr__�szDependencyGraph.__repr__rB�{0}({1})cCs||�||�|��g}||vrr||D]L}|�||�|��}|�d||�|�|�||d��d�dd��q$d�|�S)Nz     rBrk)rcr7r$�extendrl�splitrn)rr"�level�fmt�output�other�drrrrl�s&zDependencyGraph.repr_node)NN)N)rBrp)rr
rrrr#r'r(r4r7rrAr1r0rbrcrergrhrirjr?�	iteritemsrorlrrrrrs*

	 
rc@s�eZdZdZej��Zej��Z	ej
��Zej��Z
ej��ZejZeej�Zddddd�Zddd	d
�Zddd
�Zddd
�ZddiZd/dd�Zdd�Zd0dd�Zdd�Zdd�Zdd �Zd!d"�Z d#d$�Z!d%d&�Z"d'd(�Z#d)d*�Z$d1d+d,�Z%d2d-d.�Z&dS)3r	zFormat dependency graphs.ZboxZveeZfilledZ
HelveticaNeue)�shapeZ	arrowhead�styleZfontnameZ
darkseagreen4�blackgffffff�?)�colorZ
arrowcolorZ	arrowsizeZ
palegreen3Z
palegreen4)Z	fillcolorr|Z
palegreen1Z
palegreen2ZbgcolorZ	mintcreamNr�    cKsr|pd|_||_|pd|_|j|j|_||p0d|_|j||_t|jfi|��|_t|j	|�
|j�d�|_	dS)N�dependenciesrr)�root)�idr�type�_dirs�	direction�IN�INp�dict�scheme�graph_schemerW)rrr�r��indentZinwr�rrrr�s

zGraphFormatter.__init__cCsd|�d�}|j|j||d�S)N�")�name�value)�FMT�_attr)rr�r�rrr�attrszGraphFormatter.attrcsHt�jfi|r"t|fi|pi��n|��}�j��fdd�|��D��S)Nc3s"|]\}}t��||��VqdSr)rr�)r)�k�vr@rrr>sz'GraphFormatter.attrs.<locals>.<genexpr>)r�r��_attrseprnr?)rrwr�rr@r�attrs	s*�zGraphFormatter.attrscKs"|j|j|j|j|�||j�d�S)N)r�r�r�)r��_headr�r�r�r�)rr�rrrr]s�zGraphFormatter.headcCs|�|j�Sr)r��_tailr@rrrr`szGraphFormatter.tailcCs|Srrr!rrrrWszGraphFormatter.labelcKs|�||j|�Sr)�	draw_node�node_scheme�rr"r�rrrr+szGraphFormatter.nodecKs|�||j|�Sr)r��term_schemer�rrrr^szGraphFormatter.terminal_nodecKs|j||fi|��Sr)�	draw_edge)r�a�br�rrrr_!szGraphFormatter.edgecCs|�dd�S)Nzutf-8�ignore)�encode)rrTrrr�_enc$szGraphFormatter._encc
Os$|�|j|it||j|jd����S)N)r�r�)r�rcr�r�r�)rrt�args�kwargsrrrr�'s
��zGraphFormatter.FMTc	Cs.|j|j|�|�|�|�|j|�||j�d�S)N)�dirr�)r��_edgerWr�r��edge_scheme)rr�r�r�r�rrrr�,s�zGraphFormatter.draw_edgecCs |j|j|�|�|�||�d�S)N)r�)r��_noderWr�)rr"r�r�rrrr�2s�zGraphFormatter.draw_node)NNNrr})N)NN)NN)'rr
rrrr�stripr�rr�rr�rr�rr�rr�r�rr�r�r�r�r�r�rr�r�r]r`rWr+r^r_r�r�r�r�rrrrr	�sF





��

�


r	N)r�collectionsr�textwraprZkombu.utils.encodingrr�__all__r�	Exceptionrrr	rrrr�<module>sD