o
    .j                     @  sb   d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZ G dd	 d	ed
ZdS )a  
HTTP factories create HTTP protools based on defined set of arguments.

We define the :class:`HTTPProtocol` interface to allow interchange
HTTP versions and protocol implementations. But constructors of
the class is not part of the interface. Every implementation
can use a different options to init instances.

Factories unify access to the creation of the protocol instances,
so that clients and servers can swap protocol implementations,
delegating the initialization to factories.
    )annotationsN)ABCMeta)Any   )HTTPOverQUICProtocolHTTPOverTCPProtocolHTTPProtocolc                   @  s   e Zd Ze	ddd
dZdS )HTTPProtocolFactoryNtype_protocoltype[HTTPProtocol]implementation
str | Nonekwargsr   return*HTTPOverQUICProtocol | HTTPOverTCPProtocolc           
   
   K  s   | t ksJ dtdd }ddd t| |dD }d| }|r/|d|  7 }zt|| d	}W n t	yQ } zt
|  d
| d|d}~ww t|dd }|sct
|  d| d }	|	di |S )z;Create a new state-machine that target given protocol type.zAHTTPProtocol is ambiguous and cannot be requested in the factory..r    c                 s  s    | ]	}|  r|V  qd S N)isdigit).0c r   _/home/thesage/.local/lib/python3.10/site-packages/urllib3/contrib/hface/protocols/_factories.py	<genexpr>6   s    
z*HTTPProtocolFactory.new.<locals>.<genexpr>z.protocols.httpz._z.contrib.hfacez$ cannot be loaded. Tried to import 'z'.Nc                 S  s   t | tot| ttfS r   )
isinstancetype
issubclassr   r   )er   r   r   <lambda>K   s   
z)HTTPProtocolFactory.new.<locals>.<lambda>z cannot be loaded. No compatible implementation available. Make sure your implementation inherit either from HTTPOverQUICProtocol or HTTPOverTCPProtocol.r   r   )r   __name__splitjoinstrreplacelower	importlibimport_moduleImportErrorNotImplementedErrorinspect
getmemberspop)
r
   r   r   package_nameversion_targetmodule_exprhttp_moduler   implementationsimplementation_targetr   r   r   new)   sD   





zHTTPProtocolFactory.newr   )r
   r   r   r   r   r   r   r   )r   
__module____qualname__staticmethodr2   r   r   r   r   r	   (   s    r	   )	metaclass)__doc__
__future__r   r%   r)   abcr   typingr   
_protocolsr   r   r   r	   r   r   r   r   <module>   s   