%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/probert/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/probert/__pycache__/utils.cpython-35.pyc



��ZXu�@smddlmZddlZddlZddlZddlZddlZddddddd	d
ddd
ddddddddddddgZddddddgZd d!d"d#d$d%d&d'gZ	d(d)�Z
ejd?kr�d+d,�Znd-d,�Ze
d.d/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]�\}}||kr�t||t�r�t|t�r�t|||�||<q�t||t�r�t|t�r�tt|||��||<qH|||<qHW|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
�cCs[i}xN|jD]C}|jj|�}t|t�rI|jdd�}|||<qW|S)Nzutf-8�replace)�
attributes�getr�bytes�decode)�device�rr�valrrr�udev_get_attributes-srcCs^i}xQ|jjD]C}|jj|�}t|t�rL|jdd�}|||<qW|S)Nzutf-8r)rZavailable_attributesrrrr)rrrrrrrr6s�cs6dd�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�partitionn2As	r)cs_|j��td�d�fdd�dd�}dd�|D�}|\\}}||fS)	z{Unpack a partition into a tuple of (first partition, second partition)

    param: partition iterator from partitionn2
    rr%cs�j|�dkS)Nr)�index)r#)rrrr"Qsz#partition_to_pair.<locals>.<lambda>r(rcSsg|]}t|��qSr)r)r�prrr�
<listcomp>Ss	z%partition_to_pair.<locals>.<listcomp>)�splitr))�inputZ
partitions�datarrr)rr�partition_to_pairJs	r0cCsdd�|jd�D�S)NcSs5g|]+}t|�r|jd�dj��qS)�;r)�lenr-�strip)rr#rrrr,Zs	z3disentagle_data_from_whitespace.<locals>.<listcomp>�
)r-)r/rrr�disentagle_data_from_whitespaceXsr5cCs�i}i}x�t|�D]y}t|�dkr4qt|�\}}|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>cCs)dd�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,ys	z.parse_dhclient_leases_file.<locals>.<listcomp>z
{([^{}]*)}�"�)�re�findallr)�	leasedatarrr�parse_dhclient_leases_filets	rDcCsoi}xb|jd�D]Q}|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!rIcCs7ddg}x$|D]}tjj|�r|SqWdS)Nz
/var/lib/dhcpz/var/lib/dhclient)�os�path�exists)Zsupported_dirs�drrr�get_dhclient_d�s

rNcCs"d}|}x�|j�D]�}|j�}|jd�r=q|jd�}|d}|dkr~tjj||d�}q|dkrtjj||d�}x?tj|�D]Y}	t|	d��}
|
j	�j�}WdQRXt
||tjjtjj|	���q�Wq|d	krax�|dd�D]*}||krLi||<d
||d	<q0Wq|dkr�|dd�\}}
}||kr�i||<nd
||kr�t
d��|
||d
<|||d<|}q|dkr|d||d<q|tkr"|d|||<q|tkrw|||krLg|||<|||jdj|dd���q|jd�rNd||kr�i||d<|dkr�g||dd<x�|dd�D]}||ddj|�q�Wq�|dkr�g||dd<x�|dd�D]}||ddj|�q(Wq|jd�rd||kr{i||d<|tkr�|jdd�}|d||d|<q|dkrg||dd<x|dd�D]}||ddj|�q�Wq|dkrB|dj�dkrB|d||dd<q|dkr�d ||dkrti||dd <|d||dd |d<q|d!krd"||dkr�i||dd"<|d||dd"|d<qWx2|j�D]$}d	||kr�d#||d	<q�WdS)$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rZautoT�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_datarOrQrRZdomainrZ
bridge_optionrrrrX�s�
&

	+   "!"rX)rr)�copyrrUr'rJrAZpyudevr\r]r_r
Z__version_info__r�intr)r0r5r>rDrIrNrXrrrr�<module>s0				

Zerion Mini Shell 1.0