HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/serial/urlhandler/__pycache__/protocol_hwgrep.cpython-38.pyc
U

��WW/�@sfddlZddlZzeWnek
r0eZYnXGdd�dej�Zedkrbed�Zde_e	e�dS)�Nc@s*eZdZdZejjjdd��Zdd�ZdS)�SerialzOJust inherit the native Serial port implementation and patch the port property.cCs@t|t�r,|�d�r,tjj�||�|��ntjj�||�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]n}d|krX|�dd�\}}n|}d}|d	kr�t|�d}|dkr�td
�|���q:|dkr�d}q:td
�|���q:ttj	j
�|��D]V\}	}
}|r�zt�|	�}Wntj
k
r�Yq�Yn
X|��|�r|d8}q�|	St�
d�|���dS)z(extract host and port from an URL stringr�	NrF�&�=��nz9option "n" expects a positive integer larger than 1: {!r}Z	skip_busyTzunknown option: {!r}z#no ports found matching regexp {!r})�lowerr�split�pop�int�
ValueError�format�sortedrZtoolsZ
list_portsZgreprZSerialException�close)
rZurlrZ	test_open�argsZregexp�argZoptionrrZdescZhwid�sr
r
rr
,s<


zSerial.from_urlN)	�__name__�
__module__�__qualname__�__doc__rrr�setterr
r
r
r
rr s
r�__main__zhwgrep://ttyS0)
rZserial.tools.list_portsr�	NameError�strrrrr�printr
r
r
r�<module>s
6