HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux mail.btech-izolacje.pl 5.15.0-140-generic #150-Ubuntu SMP Sat Apr 12 06:00:09 UTC 2025 x86_64
User: pewna6876 (1017)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/serial/urlhandler/__pycache__/protocol_hwgrep.cpython-310.pyc
o

��^W�@stddlmZddlZddlZzeWneyeZYnwGdd�dej�Zedkr8ed�Z	de	_
ee	�dSdS)�)�absolute_importNc@s*eZdZdZejjjdd��Zdd�ZdS)�SerialzOJust inherit the native Serial port implementation and patch the port property.cCsBt|t�r|�d�rtjj�||�|��dStjj�||�dS)z%translate port name before storing it�	hwgrep://N)�
isinstance�
basestring�
startswith�serialr�port�__set__�from_url)�self�value�r�C/usr/lib/python3/dist-packages/serial/urlhandler/protocol_hwgrep.pyr	&szSerial.portc
	Cs|���d�r
|dd�}d}d}|�d�}|�d�}|D]6}d|vr,|�dd�\}}n|}d}|d	krFt|�d}|dkrEtd
�|���q|dkrMd}qtd
�|���ttj	j
�|��D]'\}	}
}|rzzt�|	�}Wn
tj
yuYq]w|��|r�|d8}q]|	St�
d�|���)z(extract host and port from an URL stringr�	NrF�&�=��nz9option "n" expects a positive integer larger than 1: {!r}�	skip_busyTzunknown option: {!r}z#no ports found matching regexp {!r})�lowerr�split�pop�int�
ValueError�format�sortedr�tools�
list_ports�grepr�SerialException�close)
r�urlr�	test_open�args�regexp�arg�optionr
r	�desc�hwid�srrrr.s@

��zSerial.from_urlN)	�__name__�
__module__�__qualname__�__doc__rrr	�setterrrrrrr"s

r�__main__zhwgrep://ttyS0)�
__future__rr�serial.tools.list_portsr�	NameError�strrr+r*r	�printrrrr�<module>s�6�