o
    -wi                     @   st   d dl Z d dlZd dlmZ d dlmZmZ d dlmZm	Z	m
Z
 e
edf Ze	deZe	deZG dd	 d	eZdS )
    N)wraps)PurePathPurePosixPath)AnyNewTypeUnionzos.PathLike[str]FilePathStrURIStrc                       s\   e Zd ZdZdedd f fddZdefddZdede	fd	d
Z
dedd fddZ  ZS )LogicalPatha  A string that represents a path relative to an artifact or run.

    The format of the string is always as a POSIX path, e.g. "foo/bar.txt".

    A neat trick is that you can use this class as if it were a PurePosixPath. E.g.:
    ```
    >>> path = LogicalPath("foo/bar.txt")
    >>> path.parts
    ('foo', 'bar.txt')
    >>> path.parent / "baz.txt"
    'foo/baz.txt'
    >>> type(path.relative_to("foo"))
    LogicalPath
    ```
    pathreturnc                    s   t |trt | |S t|dr t| }t | t|S t|dr)| }t |t	r3t
|}t dkr?|dd}t| }t | tt|S )Nas_posix
__fspath__Windows\/)
isinstancer
   super__new__hasattrr   r   strr   bytesosfsdecodeplatformsystemreplacer   )clsr   	__class__ P/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/wandb/sdk/lib/paths.pyr   9   s   




zLogicalPath.__new__c                 C   s   t | S )z%Convert this path to a PurePosixPath.)r   )selfr    r    r!   to_pathL   s   zLogicalPath.to_pathattrc              
      s   z	t |  | W n ty } ztd||d}~ww t tr't S t r>t dtdtdtf fdd}|S  S )zHAct like a subclass of PurePosixPath for all methods not defined on str.zLogicalPath has no attribute Nargskwargsr   c                     s$    | i |}t |trt|S |S )N)r   r   r
   )r%   r&   inner_resultresultr    r!   wrapper^   s   
z(LogicalPath.__getattr__.<locals>.wrapper)	getattrr#   AttributeErrorr   r   r
   callabler   r   )r"   r$   er*   r    r(   r!   __getattr__P   s   
zLogicalPath.__getattr__otherc                 C   s   t |  t | S )zFAct like a PurePosixPath for the / operator, but return a LogicalPath.)r
   r#   )r"   r0   r    r    r!   __truediv__h   s   zLogicalPath.__truediv__)__name__
__module____qualname____doc__StrPathr   r   r#   r   r   r/   r1   __classcell__r    r    r   r!   r
      s    &r
   )r   r   	functoolsr   pathlibr   r   typingr   r   r   r   r6   r   r	   r
   r    r    r    r!   <module>   s    

