%PDF- %PDF-
Mini Shell

Mini Shell

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

o

?�^)#�@s�ddlmZddlZddlZddlZddlZddlZgd�Zgd�Zgd�Z	dZ
dd�Zejd	kr6d
d�Z
ndd�Z
ed
fdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)$�)�deepcopyN)�address�netmask�	broadcast�network�metric�gateway�pointtopoint�media�mtu�hostname�
leasehours�	leasetime�vendor�client�bootfile�server�hwaddr�provider�frame�netnum�endpoint�local�ttl)zpre-up�upzpost-up�downzpre-downz	post-down)�
bridge_ageing�bridge_bridgeprio�	bridge_fd�
bridge_gcinit�bridge_hello�
bridge_maxage�bridge_maxwait�
bridge_stpicCs�t|�}t|t�rt|t�r|�|�|S|��D];\}}||vrPt||t�r7t|t�r7t|||�||<qt||t�rOt|t�rOtt|||��||<q|||<q|S�N)r�
isinstance�list�extend�items�dict�
dict_merge�set)�onto�source�target�key�value�r1�//usr/lib/python3/dist-packages/probert/utils.pyr*s
�
r*)r�cCs>i}|jD]}|j�|�}t|t�r|�dd�}|||<q|S�Nzutf-8�replace)�
attributes�getr%�bytes�decode��device�rr/�valr1r1r2�udev_get_attributes1s


r>cCs@i}|jjD]}|j�|�}t|t�r|�dd�}|||<q|Sr4)r6�available_attributesr7r%r8r9r:r1r1r2r>:s

�cs(dd�tt��fdd�|D�|��D�S)Ncss"�|]\}}dd�||�VqdS)cs�fdd�|D�S)Nc3s �|]\}}|�kr|VqdSr$r1)�.0�pred�item��ir1r2�	<genexpr>Fs�z:partitionn2.<locals>.<genexpr>.<lambda>.<locals>.<genexpr>r1)rE�teer1rDr2�<lambda>Fsz'partitionn2.<locals>.<genexpr>.<lambda>Nr1)rA�x�tr1r1r2rFFs��zpartitionn2.<locals>.<genexpr>c3s�|]	}�|�|fVqdSr$r1)rArC��	predicater1r2rFGs��)�	enumerate�	itertoolsrG�r(rL�nr1rKr2�partitionn2Es���rQcs>|���t��fdd�dd�}dd�|D�}|\\}}||fS)z{Unpack a partition into a tuple of (first partition, second partition)

    param: partition iterator from partitionn2
    cs��|�dkS)Nr)�index)rI�r(r1r2rHUsz#partition_to_pair.<locals>.<lambda>r@rOcS�g|]}t|��qSr1)r&)rA�pr1r1r2�
<listcomp>W�z%partition_to_pair.<locals>.<listcomp>)�splitrQ)�input�
partitions�datar/r0r1rSr2�partition_to_pairNs
�
r\cCsdd�|�d�D�S)NcSs&g|]}t|�r|�d�d���qS)�;r)�lenrX�strip)rArIr1r1r2rV^s�z3disentagle_data_from_whitespace.<locals>.<listcomp>�
)rX)r[r1r1r2�disentagle_data_from_whitespace\sracCszi}i}t|�D]+}t|�dkrqt|�\}}|dkr'|�|d|di�qd�|�}|�||i�q|�d|i�|S)zuTransform lease string into dictionary of attributes

    params: lease: string if a dhcp lease structure { to }
    r�option�� �options)rar^r\�update�join)�lease�
lease_dictre�liner/r0r1r1r2�
dictify_leasebs
rkcCsdd�t�d|�dd��D�S)z�Parses dhclient leases file data, returning dictionary of leases

    :param leasesdata: string of lease data read from leases file
    cSrTr1)rk)rArhr1r1r2rV}rWz.parse_dhclient_leases_file.<locals>.<listcomp>z
{([^{}]*)}�"�)�re�findallr5)�	leasedatar1r1r2�parse_dhclient_leases_filexs�rqcCsNi}|�d�D]}|�d�st|�dkrq|�d�}|d||d��<q|S)z6Parses systemd/networkd/netif lease data, returns dictr`�#rc�=r)rX�
startswithr^�lower)rprhrj�keyvaluer1r1r2�parse_networkd_lease_file�s
rwcCs*ddg}|D]}tj�|�r|SqdS)Nz
/var/lib/dhcpz/var/lib/dhclient)�os�path�exists)�supported_dirs�dr1r1r2�get_dhclient_d�s�r}c
Cs d}|}|��D�]�}|��}|�d�rq|�d�}|d}|dkr,tj�||d�}q|dkrktj�||d�}t�|�D]+}	t|	d��}
|
�	���}Wd�n1sVwYt
||tj�tj�|	���q>q|d	kr�|dd�D]}||vri||<d
||d	<quq|dkr�|dd�\}}
}||vr�i||<n
d
||vr�t
d��|
||d
<|||d<|}q|dkr�|d||d<q|tvr�|d|||<q|tvr�|||vr�g|||<|||�d�|dd���q|�d��rJd||v�ri||d<|dk�r'g||dd<|dd�D]}||dd�|��qq|dk�rIg||dd<|dd�D]}||dd�|��q:q|�d��r�d||v�r]i||d<|tv�rs|�dd�}|d||d|<q|dk�r�g||dd<|dd�D]}||dd�|��q�q|dk�r�|d��dk�r�|d||dd<q|dk�r�d ||dv�r�i||dd <|d||dd |d<q|d!k�r�d"||dv�r�i||dd"<|d||dd"|d<q|��D]}d	||v�rd#||d	<�q�dS)$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
    Nrrrdrzsource-directoryrcr-r<�autoT�iface��familyz!Cannot define %s interface again.�method�	hwaddresszdns-�dnsz
dns-search�searchzdns-nameservers�nameservers�bridge_�bridgerm�bridge_ports�ports�	bridge_hw�macr@�bridge_pathcost�pathcost�bridge_portprio�portprioF)�
splitlinesr_rtrXrxryrg�glob�open�read�parse_etc_network_interfaces�dirname�abspath�	Exception�NET_CONFIG_OPTIONS�NET_CONFIG_COMMANDS�append�NET_CONFIG_BRIDGE_OPTIONSr5ru�keys)�ifaces�contentsry�currif�src_dirrjrXrb�src_path�src_file�fp�src_datarr�r��domainr�
bridge_optionr1r1r2r��s�

����
"
�
�

�

���r�cCsftj�dtj�|��}tj�|d�}t|��}t|�����t}Wd�|S1s,wY|S)zA /sys/class/block/<device>/size and return integer value in bytes�/sys/class/block�sizeN)	rxryrg�basenamer��intr�r_�SECTOR_SIZE_BYTES)r;�
device_dir�
blockdev_sizer|r�r1r1r2�read_sys_block_size_bytes�s

��r�cCs*tj�dtj�|��}t�tj�|d��S)Nr��slaves)rxryrgr��listdir)r;r�r1r1r2�read_sys_block_slaves�sr�ccs(�|jdd�D]
}d|vrq|VqdS)N�block)�	subsystem�MAJOR)�list_devices)�contextr;r1r1r2�sane_block_devices�s��r�)�copyrr�rNrxrn�pyudevr�r�r�r�r*�__version_info__r>r�rQr\rarkrqrwr}r�r�r�r�r1r1r1r2�<module>s2

				S


Zerion Mini Shell 1.0