
    h                         S SK r S SKJr  S SKJr  S SKJrJr  SSKJ	r	J
r
  SSKJr  SSKJr   " S	 S
\5      r\R!                  \
5        \R!                  \5        S\\\ R$                  4   S\\
\4   4S jrg)    N)ABC)Path)AnyUnion   )InvalidPrefixError	CloudPath)AnyPathTypeError)path_from_fileurlc                       \ rS rSrSrS\\\4   4S jr\	S\
4S j5       r\	S\S\\\4   4S j5       r\	S	 5       r\	S\\\4   4S
 j5       rSrg)AnyPath   a  Polymorphic virtual superclass for CloudPath and pathlib.Path. Constructing an instance will
automatically dispatch to CloudPath or Path based on the input. It also supports both
isinstance and issubclass checks.

This class also integrates with Pydantic. When used as a type declaration for a Pydantic
BaseModel, the Pydantic validation process will appropriately run inputs through this class'
constructor and dispatch to CloudPath or Path.
returnc           
          [        U0 UD6$ ! [         a  n [        US   [        5      (       aM  US   R	                  5       R                  S5      (       a&  [        US   40 UD6nUSS   H  nXE-  nM	     Us S nA$ [        U0 UD6s S nA$ ! [         a(  n[        S[        U5       S[        U5       35      eS nAff = fS nAff = f)Nr   zfile:r   z@Invalid input for both CloudPath and Path. CloudPath exception: z Path exception: )r	   r   
isinstancestrlower
startswithr   r   	TypeErrorr
   repr)clsargskwargscloudpath_exceptionpathpartpath_exceptions          N/home/james-whalen/.local/lib/python3.13/site-packages/cloudpathlib/anypath.py__new__AnyPath.__new__   s    	d-f--! 	d1gs++Q0J0J70S0S,T!W??D $QR !)KT,V,, &,,01D,E+F G''+N';&<> 	s?   
 
CAB7C=
BC
B?#B::B??CC_source_typec                      SSK Jn  UR                  U R                  UR	                  5       5      $ ! [
         a     gf = f)NPydantic special method. See
https://docs.pydantic.dev/2.0/usage/types/custom/r   )core_schemaN)pydantic_corer$    no_info_after_validator_functionvalidate
any_schemaImportError)r   r!   _handlerr$   s       r   __get_pydantic_core_schema__$AnyPath.__get_pydantic_core_schema__)   sD    	1??&&(   		s   /2 
??vc                 `     U R                  X5      $ ! [         a  n[        U5      eSnAff = f)r#   N)r   r
   
ValueError)r   r-   es      r   r'   AnyPath.validate7   s2    	 ;;s&& 	  Q-	 s    
-(-c              #   (   #    U R                   v   g7f)z_Pydantic special method. See
https://pydantic-docs.helpmanual.io/usage/types/#custom-data-typesN)	_validate)r   s    r   __get_validators__AnyPath.__get_validators__B   s      mms   c                 $    U R                  X5      $ )zdUsed as a Pydantic validator. See
https://pydantic-docs.helpmanual.io/usage/types/#custom-data-types)r   )r   values     r   r3   AnyPath._validateH   s    
 {{3&&     N)__name__
__module____qualname____firstlineno____doc__r   r	   r   r   classmethodr   r+   r   r'   r4   r3   __static_attributes__r:   r9   r   r   r      s    y$)? (       y$!7      
 'y$!7 ' 'r9   r   sr   c                 R    [        U [        [        45      (       a  U $ [        U 5      $ )ziConvenience method to convert a str or os.PathLike to the
proper Path or CloudPath object using AnyPath.
)r   r	   r   r   )rB   s    r   
to_anypathrD   T   s%    
 !i&''1:r9   )osabcr   pathlibr   typingr   r   	cloudpathr   r	   
exceptionsr
   	url_utilsr   r   registerr   PathLikerD   r:   r9   r   <module>rN      sq    	    4 ( (B'c B'J        %R[[() eItO.D r9   