�
lMg�; � � � d Z ddlZddlZddlZddlmZmZ ddlZddlZ ddl
mZ ddlm
Z
G d� de� Zd � Zd
� Zd� Z G d� d
� Zy)z�
This module contains SMBFileSystem class responsible for handling access to
Windows Samba network shares by using package smbprotocol
� N)�S_ISDIR�S_ISLNK� )�AbstractFileSystem��infer_storage_optionsc �� � � e Zd ZdZdZ d� fd� Zed� � Zd� Ze d� � Z
ed� � Zdd�Z
dd �Zd
� Zd� Zd� Zd
� Zdd�Z dd�Zd� Zd� Zdd�Z� xZS )�
SMBFileSystemaa Allow reading and writing to Windows and Samba network shares.
When using `fsspec.open()` for getting a file-like object the URI
should be specified as this format:
``smb://workgroup;user:password@server:port/share/folder/file.csv``.
Example::
>>> import fsspec
>>> with fsspec.open(
... 'smb://myuser:mypassword@myserver.com/' 'share/folder/file.csv'
... ) as smbfile:
... df = pd.read_csv(smbfile, sep='|', header=None)
Note that you need to pass in a valid hostname or IP address for the host
component of the URL. Do not use the Windows/NetBIOS machine name for the
host component.
The first component of the path in the URL points to the name of the shared
folder. Subsequent path components will point to the directory/folder/file.
The URL components ``workgroup`` , ``user``, ``password`` and ``port`` may be
optional.
.. note::
For working this source require `smbprotocol`_ to be installed, e.g.::
$ pip install smbprotocol
# or
# pip install smbprotocol[kerberos]
.. _smbprotocol: https://github.com/jborean93/smbprotocol#requirements
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.
�smbc �L �� t �
| � di |�� || _ || _ || _ || _ || _ || _ |j dd� | _ || _
|| _ | dk rt d� �| | _
|
dk rt d� �|
| _ || _ | j! � y) a&
You can use _get_kwargs_from_urls to get some kwargs from
a reasonable SMB url.
Authentication will be anonymous or integrated if username/password are not
given.
Parameters
----------
host: str
The remote server name/ip to connect to
port: int or None
Port to connect with. Usually 445, sometimes 139.
username: str or None
Username to connect with. Required if Kerberos auth is not being used.
password: str or None
User's password on the server, if using username
timeout: int
Connection timeout in seconds
encrypt: bool
Whether to force encryption or not, once this has been set to True
the session cannot be changed back to False.
share_access: str or None
Specifies the default access applied to file open operations
performed with this file system object.
This affects whether other processes can concurrently open a handle
to the same file.
- None (the default): exclusively locks the file until closed.
- 'r': Allow other handles to be opened with read access.
- 'w': Allow other handles to be opened with write access.
- 'd': Allow other handles to be opened with delete access.
register_session_retries: int
Number of retries to register a session with the server. Retries are not performed
for authentication errors, as they are considered as invalid credentials and not network
issues. If set to negative value, no register attempts will be performed.
register_session_retry_wait: int
Time in seconds to wait between each retry. Number must be non-negative.
register_session_retry_factor: int
Base factor for the wait time between each retry. The wait time
is calculated using exponential function. For factor=1 all wait times
will be equal to `register_session_retry_wait`. For any number of retries,
the last wait time will be equal to `register_session_retry_wait` and for retries>1
the first wait time will be equal to `register_session_retry_wait / factor`.
Number must be equal to or greater than 1. Optimal factor is 10.
auto_mkdir: bool
Whether, when opening a file, the directory containing it should
be created (if it doesn't already exist). This is assumed by pyarrow
and zarr-python code.
�temppath� r z:register_session_retry_wait must be a non-negative integer� zSregister_session_retry_factor must be a positive integer equal to or greater than 1N� )�super�__init__�host�port�username�password�timeout�encrypt�popr
�share_access�register_session_retries�
ValueError�register_session_retry_wait�register_session_retry_factor�
auto_mkdir�_connect)�selfr r r r r r r r r r r �kwargs� __class__s ��fC:\Users\noahv\Documents\GitHub\clickup-operator\.venv\Lib\site-packages\fsspec/implementations/smb.pyr zSMBFileSystem.__init__? s� �� �B ���"�6�"��� ��� � ��
� ��
��������
�
�:�r�2��
�(���(@��%�&��*��L��
� ,G��(�(�1�,��5��
� .K��*�$����
�
�� c �6 � | j �dS | j S )N� �r �r! s r$ �_portzSMBFileSystem._port� s � ��i�i�'�s�6�T�Y�Y�6r% c �Z ���� dd l }| j dk ry g }| j �| j dz
�| j �t ���fd�t d�dz � D � � }t | j dz � D ][ } t
j | j | j | j | j | j | j �� y |d �# t j j t j j"