
    O|b                     J    d Z ddlZddlZdgZej
                  ddfdddddZy)zO
Session factory factory (the two "factory" are intentional :-) ) for ftputil.
    Nsession_factory   T)encrypt_data_channelencodingdebug_levelc                    t         t              st        d       (t         t        j
                        st        d        G  fdd       }!t        j                  j                  s|_	        |S )a  
    Create and return a session factory according to the keyword arguments.

    base_class: Base class to use for the session class (e. g. `ftplib.FTP_TLS`
    or `M2Crypto.ftpslib.FTP_TLS`, the default is `ftplib.FTP`).

    port: Port number (integer) for the command channel (default 21). If you
    don't know what "command channel" means, use the default or use what the
    provider gave you as "the FTP port".

    use_passive_mode: If `True`, explicitly use passive mode. If `False`,
    explicitly don't use passive mode. If `None` (default), let the
    `base_class` decide whether it wants to use active or passive mode.

    encrypt_data_channel: If `True` (the default), call the `prot_p` method of
    the base class if it has the method. If `False` or `None` (`None` is the
    default), don't call the method.

    encoding: Encoding (str) to use for directory and file paths, or `None`.
    Unicode (`str`) paths will be encoded with this encoding. Bytes paths are
    assumed to be in this encoding. The default (equivalent to passing `None`)
    is to use the default encoding of the `base_class` argument. Note that this
    encoding has changed from Python 3.8 to 3.9.

    In Python 3.8 and lower, the default path encoding is "latin-1"; in Python
    3.9, the default path encoding is "utf-8". Therefore, if you want an
    encoding that's independent of the Python version, pass an explicit
    `encoding`.

    Using a non-`None` `encoding` is only supported if `base_class` is
    `ftplib.FTP` or a subclass of it.

    debug_level: Debug level (integer) to be set on a session instance. The
    default is `None`, meaning no debugging output.

    This function should work for the base classes `ftplib.FTP`,
    `ftplib.FTP_TLS`. Other base classes should work if they use the same API
    as `ftplib.FTP`.

    Usage example:

      my_session_factory = session_factory(
                             base_class=ftplib.FTP_TLS,
                             use_passive_mode=True,
                             encrypt_data_channel=True)
      with ftputil.FTPHost(host, user, password,
                           session_factory=my_session_factory) as host:
        ...
    z%`base_class` must be a class, but is zP`encoding` is only supported for `ftplib.FTP` and subclasses, but base class is c                   0     e Zd ZdZ fdZ xZS ) session_factory.<locals>.SessionzE
        Session factory class created by `session_factory`.
        c                 P   +t         j                  j                  rt        |          nt        |           | j                  |	       | j                         | j                  ||       
| j                  
       rt        d      r| j                          y y y )N)r   prot_p)ftputilpath_encodingRUNNING_UNDER_PY39_AND_UPsuper__init__connectset_debuglevelloginset_pasvhasattrr   )selfhostuserpassword	__class__
base_classr   r   r   portuse_passive_modes       /lib/python3.12/site-packages/ftputil/session.pyr   z)session_factory.<locals>.Session.__init__j   s    $''AA ( 3 "LLt$&##K0JJtX&  +./#
H(E )F#    )__name__
__module____qualname____doc__r   __classcell__)r   r   r   r   r   r   r   s   @r   Sessionr
   V   s    	&	 	r    r&   )

isinstancetype
ValueError
issubclassftplibFTPr   r   r   r   )r   r   r   r   r   r   r&   s   `````` r   r   r      s    t j$'@OPPz*fjj'I!!+0
 	

$ $* $L 	g&;&;&U&U#Nr    )r$   r+   ftputil.toolr   __all__r,   r    r    r   <module>r0      sB   
   
 zz	j
 jr    