�
lMg� � � � d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlZddl m
Z
ddlmZ ej d� Z G d� de
� Zd � Zd
� Zy)� N)�S_ISDIR�S_ISLNK� )�AbstractFileSystem��infer_storage_optionszfsspec.sftpc � � � e Zd ZdZdZ� fd�Zd� Zed� � Ze d� � Z
dd�Zdd�Zd � Z
d
� Ze dd�� Zdd�Zdd
�Zd� Zdd�Zd� Zd� Z� xZS )�SFTPFileSystemz�Files over SFTP/SSH
Peer-to-peer filesystem over SSH using paramiko.
Note: if using this with the ``open`` or ``open_files``, with full URLs,
there is no way to tell if a path is relative, so all paths are assumed
to be absolute.
)�sftp�sshc � �� | j ryt �| � di |�� |j dd� | _ || _ || _ | j � y)a�
Parameters
----------
host: str
Hostname or IP as a string
temppath: str
Location on the server to put files, when within a transaction
ssh_kwargs: dict
Parameters passed on to connection. See details in
https://docs.paramiko.org/en/3.3/api/client.html#paramiko.client.SSHClient.connect
May include port, username, password...
N�temppathz/tmp� )�_cached�super�__init__�popr �host�
ssh_kwargs�_connect)�selfr r � __class__s ��gC:\Users\noahv\Documents\GitHub\clickup-operator\.venv\Lib\site-packages\fsspec/implementations/sftp.pyr zSFTPFileSystem.__init__ sH �� � �<�<��
���&�:�&�"���z�6�:��
��� �$����
�
�� c �p � t j d| j � t j � | _ | j
j
t j � � | j
j | j fi | j �� | j
j � | _ y )NzConnecting to SFTP server %s)�logger�debugr �paramiko� SSHClient�client�set_missing_host_key_policy�
AutoAddPolicy�connectr � open_sftp�ftp�r s r r zSFTPFileSystem._connect2 su � ����3�T�Y�Y�?��(�(�*������/�/��0F�0F�0H�I�������D�I�I�9����9��;�;�(�(�*��r c � � t |� d S )N�pathr )�clsr( s r �_strip_protocolzSFTPFileSystem._strip_protocol9 s � �$�T�*�6�2�2r c �d � t | � }|j dd � |j dd � |S )Nr( �protocol)r r )�urlpath�outs r �_get_kwargs_from_urlsz$SFTPFileSystem._get_kwargs_from_urls= s- � �#�G�,�����������
�D�!��
r c �� � t j d|� | j |� rt d|� �� �|r| j |� y | j
j
||� y )NzCreating folder %s�
File exists: )r r �exists�FileExistsError�makedirsr% �mkdir)r r( �create_parents�modes r r5 zSFTPFileSystem.mkdirD sP � ����)�4�0��;�;�t��!�M�$��"8�9�9���M�M�$���H�H�N�N�4��&r c � � | j |� r|st d|� �� �|j d� }|d d dk( rdnd}|D ]>