
    AHj                        U d dl mZ d dlZd dlmZmZ d dlmZmZ d dl	m
Z
 eeeeeeef      f   Zded<   	  G d d	e      Zdd
ZddZy)    )annotationsN)PathPurePath)ListUnion)	TypeAliasr   CSSPathTypec                      e Zd ZdZy)CSSPathErrorz-Raised when supplied CSS path(s) are invalid.N)__name__
__module____qualname____doc__     E/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/_path.pyr   r      s    7r   r   c                    g }t        | t              rt        |       g}|S t        | t              r| g}|S t        | t              r| D cg c]  }t        |       }}|S t        d      c c}w )zNormalize the supplied CSSPathType into a list of paths.

    Args:
        css_path: Value to be normalized.

    Raises:
        CSSPathError: If the argument has the wrong format.

    Returns:
        A list of paths.
    z:Expected a str, Path or list[str | Path] for the CSS_PATH.)
isinstancestrr   r   listr   )css_pathpathspaths      r   _css_path_type_as_listr      s}     E(C h  L 
Hh	'
 L 
Hd	#(01d11 L WXX 2s   
A+c                    t        |       } | j                         r| S t        |dd      }|t        |      }n(t        t        j                  |j
                              }|j                  | z  j                         }|S )a  Convert the supplied path to a Path object that is relative to a given Python object.
    If the supplied path is absolute, it will simply be converted to a Path object.
    Used, for example, to return the path of a CSS file relative to a Textual App instance.

    Args:
        path: A path.
        obj: A Python object to resolve the path relative to.

    Returns:
        A resolved Path object, relative to obj
    
_BASE_PATHN)r   is_absolutegetattrinspectgetfile	__class__parentresolve)r   obj	base_pathsubclass_pathresolved_paths        r   _make_path_object_relativer(   /   su     :D  \40IYW__S]];<"))D099;Mr   )r   r	   returnzlist[PurePath])r   zstr | PurePathr$   objectr)   r   )
__future__r   r   pathlibr   r   typingr   r   typing_extensionsr   r   r	   __annotations__	Exceptionr   r   r(   r   r   r   <module>r1      s\    "  "  'sH}	 Y 
 389 84r   