|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/ftputil/__pycache__/ |
U
O��g� � @ sJ d Z ddlZddlZddlZdgZdd� Zejddfdddd�d d�ZdS )
zO
Session factory factory (the two "factory" are intentional :-) ) for ftputil.
� N�session_factoryc C sZ |dkrt jjs|dkrV| �d�}d}|�� D ]}|�� �� dkr.d}q.|rV| �d� dS )z�
If the requested encoding is UTF-8 and the server supports the `UTF8`
feature, send "OPTS UTF8 ON".
See https://datatracker.ietf.org/doc/html/rfc2640.html .
N)zUTF-8�UTF8zutf-8�utf8ZFEATFz UTF8TzOPTS UTF8 ON)�ftputil�
path_encoding�RUNNING_UNDER_PY39_AND_UPZsendcmd�
splitlines�upper�rstrip)�session�encodingZfeat_outputZserver_supports_opts_utf8_on�line� r �</opt/cppython/lib/python3.8/site-packages/ftputil/session.py�_maybe_send_opts_utf8_on s �
r � T)�encrypt_data_channelr �debug_levelc sr t � t�std� �����dk r:t� tj�s:td� ����G � �����fdd�d� �}�dk rntjjsn�|_ |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 NzP`encoding` is only supported for `ftplib.FTP` and subclasses, but base class is c s, e Zd ZdZ� ������fdd�Z� ZS )z session_factory.<locals>.SessionzE
Session factory class created by `session_factory`.
c s� �d k r t jjr t� j�d� n
t� �� | �|�� �d k rH| ��� | �||� �d k rf| ��� �r|t �d�r|| �
� t| �� d S )N)r �prot_p)r r r �super�__init__�connect�set_debuglevel�loginZset_pasv�hasattrr r )�self�host�user�password)� __class__�
base_classr r r �port�use_passive_moder r r s ��
z)session_factory.<locals>.Session.__init__)�__name__�
__module__�__qualname__�__doc__r �
__classcell__r �r r r r r! r"