HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/samba/__pycache__/graph.cpython-310.pyc
o

�/ao�@s8ddlmZddlZddlmZmZdZdd�ZdAdd	�ZdBdd�Z	gdd
dfdd�Z
												dCdd�Zejej
fejejejejejd�ejej
fejejejejejd�e�d�e�d�fejddd�e�d�e�d�e�d�e�d�e�d�e�d�e�d�fejejd�e�d �e�d!�fejddd�ejddd�ejddd�ejddd�ejddd�ejddd�ejddd�ejddd�fejejd�d"d#d#d#d#d#d�d$�Zd%d&d'd(d)d*d+�d,d)d-d.d)d/d+�d0�Zd1d2�Zd3d4�Z						dDd5d6�ZdEd8d9�Zd:d;�Z								<	=	>	dFd?d@�ZdS)G�)�colourN)�cycle�groupby�
cCs�t|�dkr|S|�dd�}g}|�d�D]F}t|�dkrTd|dd�vr.|�dd�\}}nt|�d}t|�|}|d	|�||d	�}}|�|d�t|�dks|r[|�|�qd
�|�S)z�Break DNs over multiple lines, for better shaped and arguably more
    readable nodes. We try to split after commas, and if necessary
    after hyphens or failing that in arbitrary places.��,z,
�
��-��Nz\n)�len�replace�split�append�join)�s�pieces�p�q�n�b�r�-/usr/lib/python3/dist-packages/samba/graph.py�reformat_graph_labels"�
�
rFcCs |�dd�}|rt|�}d|S)z%Escape a string as graphvis requires.�"z%s)rr)r�reformatrrr�quote_graph_label4sr�,...c
s�tdd�|D��}g}t|�dkr�d�t|���}z	t�fdd�|D��}t|�dks0d|vr1n�d8�qWn
tyD||fYSw�d7�|d}�t|�kri|�d	kri�d7��t|�kri|�d	ksY�t|�krt||fS|�||�d
�f�|��D]\}}	|	d
��|||<q�|r�|��D]}	d|	vr�nq�tdd�|��D��}|�d
�|��D]}	|	�d�s�||fSq�tdd�|��D��}|�d�||fS)a~Replace the common suffix (in practice, the base DN) of a number of
    vertices with a short string (default ",..."). If this seems
    pointless because the replaced string is very short or the results
    seem strange, the original vertices are retained.

    :param vertices: a sequence of vertices to shorten
    :param suffix: the replacement string [",..."]
    :param aggressive: replace certain common non-suffix strings

    :return: tuple of (rename map, replacements)

    The rename map is a dictionary mapping the old vertex names to
    their shortened versions. If no changes are made, replacements
    will be empty.
    css�|]}||fVqdS�Nr��.0�vrrr�	<genexpr>N��z'shorten_vertex_names.<locals>.<genexpr>r���Tc3s�|]}|�VqdSrr�r!�x��irrr#Xr$�*rrN�,CN=Servers,cs�&�|]\}}||�ddd�fVqdS)r+z,**,rN�r�r!�kr"rrrr#y���)z**z
CN=Servers�CN=NTDS Settings,csr,)r1z*,rNr-r.rrrr#�r0)r*zCN=NTDS Settings)	�dictr
�list�values�set�
IndexErrorr�items�
startswith)
�vertices�suffix�
aggressive�vmap�replacements�vlist�cr'r/r"rr(r�shorten_vertex_names>sZ�����

��
r@�key_rc	Cs�g}g}g}g}g}	t|�D]r\}
}|\}}
}d||
f}t|�}d|}|r<|	�|�|�|�|�d|||
f�q|�|�d|}d|}|	�|�|�d|�|�d||f�|�d||f�|�d	|||
f�|�d
|||f�|�d�qd}|r�tt|��D]0\}
}|	�d
|
�|\}}|ddkr�|ddkr�|dd�}|dd�}|d|
||f7}q�g}|	r�|D]
}|�d||	df�q�dd�|�d�|�d�|�|d�|�d�|	�f}|S)a�Generate a dot file snippet that acts as a legend for a graph.

    :param key_items: sequence of items (is_vertex, style, label)
    :param nodes_above: list of vertices (pushes key into right position)
    :param elision: tuple (short, full) indicating suffix replacement
    :param prefix: string used to generate key node names ["key_"]
    :param width: default width of node lines

    Each item in key_items is a tuple of (is_vertex, style, label).
    is_vertex is a boolean indicating whether the item is a vertex
    (True) or edge (False). Style is a dot style string for the edge
    or vertex. label is the text associated with the key item.
    z%s%d_z%s_labelz%s[label="%s"; %s]z%se1z%se2zsubgraph cluster_%s {z,%s[label=src; color="#000000"; group="%s_g"]z-%s[label=dest; color="#000000"; group="%s_g"]z!%s -> %s [constraint = false; %s]z8%s[shape=plaintext; style=solid; width=%f; label="%s\r"]�}�z	elision%drrrNuO
elision%d[shape=plaintext; style=solid; label="\“%s”  means  “%s”\r"]
z"%s" -> %s [style=invis]z�subgraph cluster_key {
label="Key";
subgraph cluster_key_nodes {
label="";
color = "invis";
%s
}
subgraph cluster_key_edges {
label="";
color = "invis";
%s
{%s}
}
%s
}
%s
%s [style=invis; weight=9]
z;
r� z -> )�	enumeraterr�reversedr)�	key_items�nodes_above�elisions�prefix�width�
edge_lines�
edge_names�vertex_lines�vertex_names�order_linesr)�item�	is_vertex�style�label�tag�name�e1�e2�elision_str�elision�short�long�above_linesrrrrr�compile_graph_key�sz


�

��
���
���r^Tc!	s$g}|j}|durtdd�|D��tdd�|D��B}|rNttdd�|D��tdd�|D��Bt|�B�}t|�\�}�fdd�|D�}�fd	d�|D�}nd}|
durVd
}
|r]d}d}nd
}d}|d�|d||
f�|durx|d|f�|dt�|dt�d}d}g}t|�D]z\}}t||�}|�|�g}|
r�|
|r�|
|}||kr�|dur�|d�|}t|�}|r�|d|�|d7}|d�|d�|d|�|r�||r�|�||�|r�||r�|�dt||��|�r|d|d�|�f�q�|d|f�q�|�r|d�t|�D]f\}}|\}}|du�r#d}|du�r*d }t||�}t||�}g}|�rFt||�}|�d!|�|�rT|�dt||��|	�r^|�|	|�|�rp|d"|||d�|�f��q|d#|||f��q|�r�t|||d$�} || �|d%�d&�|�S)'a�Generate a Graphviz representation of a list of vertices and edges.

    :param vertices: list of vertex names (optional).
    :param edges:    list of (vertex, vertex) pairs
    :param directed: bool: whether the graph is directed
    :param title: optional title for the graph
    :param reformat_labels: whether to wrap long vertex labels
    :param vertex_colors: if not None, a sequence of colours for the vertices
    :param edge_colors: if not None, colours for the edges
    :param edge_labels: if not None, labels for the edges
    :param vertex_styles: if not None, DOT style strings for vertices
    :param edge_styles: if not None, DOT style strings for edges
    :param graph_name: if not None, name of graph
    :param shorten_names: if True, remove common DN suffixes
    :param key: (is_vertex, style, description) tuples
    :param vertex_clusters: list of subgraph cluster names

    Colour, style, and label lists must be the same length as the
    corresponding list of edges or vertices (or None).

    Colours can be HTML RGB strings ("#FF0000") or common names
    ("red"), or some other formats you don't want to think about.

    If `vertices` is None, only the vertices mentioned in the edges
    are shown, and their appearance can be modified using the
    vertex_colors and vertex_styles arguments. Vertices appearing in
    the edges but not in the `vertices` list will be shown but their
    styles can not be modified.
    Ncs��|]}|dVqdS�rNrr&rrrr#r$zdot_graph.<locals>.<genexpr>csr_�rNrr&rrrr#r$csr_r`rr&rrrr#r$csr_rarr&rrrr#r$c�g|]}�|�qSrrr&�r<rr�
<listcomp>�zdot_graph.<locals>.<listcomp>c� g|]\}}�|�|f�qSrr�r!�arrcrrrd� �A_samba_tool_production�digraphz->�graphz--z/* generated by samba */z%s %s {zlabel="%s";z
fontsize=%s;
z'node[fontname=Helvetica; fontsize=%s];
rrBzsubgraph cluster_%d {rzstyle = "rounded,dotted";z'node [style="filled"; fillcolor=white];z
label = "%s";z
color="%s"z
"%s" [%s];z, z"%s";zMissing source valuezMissing destination valuez
label="%s"z"%s" %s "%s" [%s];z
"%s" %s "%s";)rHrIz}
r)	rr5r3r@�	FONT_SIZErErrr^)!r9�edges�directed�title�reformat_labels�
vertex_colors�edge_colors�edge_labels�
vertex_styles�edge_styles�
graph_name�
shorten_namesrG�vertex_clusters�out�writer>rI�
graph_type�	connector�prev_cluster�	cluster_n�quoted_verticesr)r"�attrs�clusterr�edgerhrrT�keyrrcr�	dot_graph�s�*$��





�
r�)�alternate rows�disconnected�	connected�
transitive�header�reset�'�-�|)�bg�p��������)r�r�r�r��transitive scaler�r�����rCrC)�ansizansi-heatmapzxterm-256colorzxterm-256color-heatmapNu│u─u╭�·r
u←)�vertical�
horizontal�corner�diagonal�missing�right_arrow�|r�0z<-)�utf8�asciicCsvt|�tdd�|D��Btdd�|D��B}|t|�kr)td|t|�tjd�t|�}i}|D]}|di||<q1|D]\}}||�|d�|||<q<t|�D]E}d}	i}
|��D]4\}}|��}||
|<|��D]#\}}
||��D]\}}|
|}|�||�}||kr�|||<d	}	quqkq[|
}|	s�nqQi}|D]}i||<|D]}||�||�}||kr�||||<q�q�|S)
Ncsr_r`r�r!�errrr#�r$z+find_transitive_distance.<locals>.<genexpr>csr_rarr�rrrr#�r$zthere are unknown vertices: %s)�filerrFT)	r5�print�sys�stderrr
�get�ranger7�copy)r9rn�all_vertices�inf�	distancesr"�src�destr)�changed�
new_distances�d�new_d�cost�leaf�cost2�new_cost�old_cost�answer�v2rhrrr�find_transitive_distance�s^��
��������r�csLd�vr�d�t���dt|d�����fdd�}|S�fdd�}|S)Nr�rg�?cs(t|t�sdS�t|���d�S)NrCr)�
isinstance�int�min��link)�mr�scalerr�fs
z"get_transitive_colourer.<locals>.fcs�dS)Nr�rr�)�coloursrrr�s)r
r�)r��
n_verticesr�r)r�r�rr�r�get_transitive_colourer�s	�r�c+s,g}|j}	t|r
dnd}
|
d}|
d}|
d}
|
d}|
d}|
d}t|}t|�d	d
���|durIttdd�|D��td
d�|D��B�}|durqt||d�}g}t||d�D]\}}t���|�	�fdd�|D��q[n	�fdd�|D�}|r�t
tdd�|D��tdd�|D��Bt|�B�}t|ddd�\�}�fdd�|D�}�fdd�|D�}tdtdd�|D���}|�dd�}|�dd�}|�dd�}|�dd�}t
|t|��}d |}d}|	d!|dd t|�||f�t|�D]7\}}t|�|} ||�| d"k�rd#|dd$�||f}!n|}!|	d%|!||�|
|| ||f�|�|7}q�t||�}"t|�D]�\}}||�|"|}#g}$|D]O}%|#�|%�}&|&du�r[|$�d&||f��qD|&d'k�rm|$�d(|�||f��qD|&d"k�r}|$�d)||f��qD||&�}'|&d*k�r�d+}&|$�d,|'|&|f��qD|du�r�||�r�|$�d-||||f�|	d.�|||d�|$�|f��q4t��}(|�r�|	d�t|�D]\})}*|	d/|(|)||(|*|f��q�|�r|	d�|	d0||||f�|	d1|(||f�|	d2||f�|	d3|d4�|f�|	d5|||f�d6�|�S)7Nr�r�r�r�r�r�r�r�r�r�csr_r`rr&rrrr#$r$z"distance_matrix.<locals>.<genexpr>csr_rarr&rrrr#$r$�r�c3��|]}�VqdSrrr&�r?rrr#-��c�g|]}t���qSr��nextr ��colour_cyclerrrd/rez#distance_matrix.<locals>.<listcomp>csr_r`rr&rrrr#2r$csr_rarr&rrrr#3r$�+T�r;crbrrr&rcrrrd7recrfrrrgrcrrrd8ri�cs��|]}t|�VqdSr�r
r rrrr#:r$r�rCr�r�r�rDz%*s %s  %sdestination%srz%s%ssource%si�����%s %s%s%s%s%s %s%s�%s%sr�%s%s%s%sz%s1%s�	�>�%s%s%s�%s %s %s�%s%*s%s %s%s�'%s%s%s' stands for '%s%s%s'zQData can get from %ssource%s to %sdestination%s in the indicated number of steps.z+%s%s%s means zero steps (it is the same DC)z%s1%s means a direct linkzL%s2%s means a transitive link involving two steps (i.e. one intermediate DC)rz;%s%s%s means there is no connection, even through other DCsr)r�CHARSETS�COLOUR_SETSrr��sortedr5rr��extendr3r@�maxr�r
rEr�rrF)+r9rnr�rrx�generate_key�grouping_function�row_comments�linesr{�charsetr�r�r�r�r�r�r��colour_listr/r"r>r=�vlen�c_header�	c_disconn�c_conn�c_reset�colour_transitive�vspace�	verticalsr)�j�start�connections�links�rowr�r��ct�	example_c�
substitute�originalr�r?r�r<r�distance_matrix
s�(���
�
�
�	






�����
��
r�rDcCs |dkrd}d|d||S)NrrCrDr)�char�digits�paddingrrr�pad_char�srcCs<i}|��D]\}}|��D]\}}||�|i�|<qq|Sr)r7�
setdefault)r��m2�k1r��k2�distrrr�transpose_dict_matrix�s�r	r�source�destinationc6sZg}|j}
|rt|�}|dk}t|rdnd}t|d|�}|d||}t|d||d�}t|d|�}t|d|�}td	|�}|d
}td|�}t|}t|�dd
���t|���}|dur�|j	|d�g}t
||d�D]\}}t���|��fdd�|D��qpn	�fdd�|D�}|r�t
|ddd�\�}i}|��D]\}} t�fdd�| ��D��|�|<q�|}t|���}tdt|
�tdd�|D���}!|�dd�}"|�dd�}#|�dd�}$|�dd�}%|dur�t|�}t||�}&d|!}'d}(|
d|'|t|�d|"|
|%f�t|�D]>\})}t|�|)}*||)�|*dk�r0d|'dt|	��|"|	|%f}+n|'}+|
d |+|(|%�|||*||%f�|(d!�|f7}(�q
d!d||%f},d"}-t|�D]�\})}||}.||)�g}/|D]Z}0|0|.v�r}|/�d#|#||%f��qj||0k�r�|/�d|%�||%f��qj|.|0}1|1d$|k�r�|&|1�}2|/�d#|2||%f�d}-�qj|1d%k�r�|$}2n|&|1�}2|/�d&|2||1|,f��qj|du�r�||)�r�|/�d'|%|||)f�|
d(�|!||%d�|/�|%f��qZ|-�s�|�r�|
d�|-�r|
d)|&d$|�||%d$|df�|�r(t��}3t|�D]\}4}5|
d*|3|4|%|3|5|%f��qd+�|�S),Nrr�r�r�r�r�r�r�r�r�rDr�r�r�c3r�rrr&r�rrr#�r�zfull_matrix.<locals>.<genexpr>cr�rr�r r�rrrd�rezfull_matrix.<locals>.<listcomp>r�Tr�c3s �|]\}}�||fVqdSrrr.rcrrr#�s�r�csr�rr�r rrrr#�r$r�rCr�r�r�z%s %s %s%s%sr�r�r�Fr�rrz%s%*s%sr�r�z'%s%s%s' means greater than %d r�r)rr	r�rr�rr�r3�keys�sortrr�r�r@r7r2r�r
r�rErrF)6�rowsr�rrxr�r�r��colour_scaler�ylabel�xlabel�	transposer�r{�use_paddingr�r�r�r�r�r��toobigr��emptyr�r9r�r/r"r=�rows2�vert�rr�r�r�r�r�r�r�r�r)r�r��end_cell�overflowr�r�r�r�r�r�r�r�rr�r�full_matrix�s�
�

�
�$
�
��	



�

���
r)F)rF)FNTNNNNNNFNN)FNFFNN)rD)FNFFNNNrr
rT)�sambarr��	itertoolsrrrmrrr@r^r��
DARK_WHITE�BLACK�RED�GREEN�DARK_YELLOW�	UNDERLINE�C_NORMAL�REV_RED�	REV_GREEN�REV_DARK_YELLOW�xterm_256_colourr�r�r�r�r�rr	rrrrr�<module>s�


J
�`
�
�
	�	��������?���4
�
	�