
    O|b	                     2    d Z ddlZg dZd Zd Zd ZddZy)	z
tool.py - helper code
    N)same_string_type_asas_stras_str_pathraise_for_empty_pathc                     t        | t              r!t        |t              r|j                  |      S t        | t              r!t        |t              r|j	                  |      S |S )z
    Return a string of the same type as `type_source` with the content from
    `string`.

    If the `type_source` and `string` don't have the same type, use `encoding`
    to encode or decode, whatever operation is needed.
    )
isinstancebytesstrencodedecode)type_sourcestringencodings      ,lib/python3.12/site-packages/ftputil/tool.pyr   r      sM     +u%*VS*A}}X&&	K	%*VU*C}}X&&    c                 ~    t        | t              r| j                  |      S t        | t              r| S t	        d      )z
    Return the argument `string` converted to a unicode string if it's a
    `bytes` object. Otherwise just return the string.

    If a conversion is necessary, use `encoding`.

    If `string` is neither `str` nor `bytes`, raise a `TypeError`.
    z*`as_str` argument must be `bytes` or `str`)r   r	   r   r
   	TypeError)r   r   s     r   r   r      s8     &% }}X&&	FC	 DEEr   c                 D    t        j                  |       } t        | |      S )a  
    Return the argument `path` converted to a unicode string if it's a `bytes`
    object. Otherwise just return the string.

    If a conversion is necessary, use `encoding`.

    Instead of passing a `bytes` or `str` object for `path`, you can pass a
    `PathLike` object that can be converted to a `bytes` or `str` object.

    If the `path` can't be converted to a `bytes` or `str`, a `TypeError` is
    raised.
    )osfspathr   )pathr   s     r   r   r   0   s     99T?D$!!r   c                 `    ddl }| dv r&|d}nd| d}|j                  j                  |      y)zi
    Raise an exception of class `exception_class` if `path` is an empty string
    (text or bytes).
    r   N) r   zpath argument is emptyzpath argument `z
` is empty)ftputil.errorerror
FTPIOError)r   path_argument_nameftputilmessages       r   r   r   A   sF     
 y%.G'(:';:FGmm&&w// r   )r   )__doc__r   __all__r   r   r   r    r   r   <module>r#      s,   
 
 S F"""0r   