
    Y jP@              
       v   % S r SSKrSSKJrJr  SSKJr  SSKJr  SSK	J
r
Jr  SSKJr  \R                  R                  5        V Vs0 s H  u  pX_M	     snn r\\\4   \S	'   \R(                  " S
5      r\" \R                  R/                  5       5      r\\   \S'   \" SS9 " S S5      5       r\" SS9 " S S5      5       rS\S\4S jrS\S\4S jrS\S\S\\\S-  \S-  4   4S jrS\S\S\\R@                  \4   4S jr!S\S\R@                  S\S\4S jr"S\S\R@                  S\S\4S jr#gs  snn f )a|  Centralized parser for Hugging Face Hub URIs ('hf://...') and mount specifications.

A HF URI is a URI-like string that identifies a location on the Hugging Face
Hub: a model/dataset/space/kernel repository, a bucket, optionally a revision,
and optionally a path inside the repo or bucket.

Canonical syntax:

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]
```

A HF mount wraps a HF URI with a local mount path and an optional ':ro'/':rw'
flag (used by Spaces and Jobs volumes):

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]
```

See 'docs/source/en/package_reference/hf_uris.md' for the full grammar and examples.
    N)	dataclassfield)unquote)	constants)
HfUriErrorHFValidationError   )validate_repo_id_TYPE_TO_PREFIXz ^refs/(?:convert/[\w.-]+|pr/\d+)_VALID_URI_TYPEST)frozenc                       \ rS rSr% Sr\R                  \S'   \\S'   Sr	\S-  \S'   Sr
\\S'   \" S	S	S	SS
9r\S-  \S'   SS jr\S\4S j5       r\S\4S j5       rS\4S jrSrg)HfUri=   a  Parsed representation of a Hugging Face Hub URI ('hf://...').

Attributes:
    type (`str`):
        One of 'model', 'dataset', 'space', 'kernel' or 'bucket'.
    id (`str`):
        The repository id ('namespace/name', e.g. 'my-org/my-model') for repo URIs, or the bucket id ('namespace/name') for bucket URIs.
    revision (`str`, *optional*):
        The revision specified after '@' in the URI, URL-decoded. 'None' if no revision was specified, or for bucket URIs (which
        never carry a revision). Special refs like 'refs/pr/10' and 'refs/convert/parquet' are preserved as-is.
    path_in_repo (`str`):
        The path inside the repo or bucket. Empty string if the URI points at the root.
typeidNrevision path_in_repoFreprhashcomparedefault_rawreturnc           	          U R                   =(       d    SnU R                  [        ;  a(  [        USU R                   S[	        [        5       S3S9eU R
                  (       a  U R
                  R                  S5      S:w  a  [        USU R
                   S	3S9eU R                  S
:w  a   [        U R
                  5        U R                  b  U R                  (       d
  [        USS9eU R                  S
:X  a  U R                  b
  [        USS9eU R                  (       aI  U R                  R                  S5      (       d  SU R                  ;   a  [        USU R                   S3S9eg g ! [         a  n[        U[        U5      S9UeS nAff = f)Nr   zInvalid type 'z'. Must be one of .urimsg/r	   z"Id must be 'namespace/name', got ''.bucketz%Revision must not be an empty string.z&Bucket URIs do not support a revision.z//z+Path must not contain empty segments (got 'z').)r   r   r   r   sortedr   countr
   r   strr   r   
startswith)selfr    es      o/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/huggingface_hub/utils/_hf_uris.py__post_init__HfUri.__post_init__S   s`   iio2 99,,N499+EWX^_oXpWqqr*stt ww$''--,1,NtwwiWY*Z[[99 = )
 ==$T]]*QRR99 T]]%>*RSS   ++C00DD<M<M4M S0[\`\m\m[nnq.rss 5N  % = Sc!f51<=s   +E* *
F4FFc                      U R                   S:H  $ )z$True if this URI points at a bucket.r$   r   r)   s    r+   	is_bucketHfUri.is_bucketn        yyH$$    c                      U R                   S:g  $ )zJTrue if this URI points at a repository (model, dataset, space or kernel).r$   r/   r0   s    r+   is_repoHfUri.is_repos   r3   r4   c                    [         R                  [        U R                     SU R                  /nU R
                  bN  U R
                  nSU;   a(  [        R                  U5      c  UR                  SS5      nUR                  SU 35        U R                  (       a  UR                  SU R                   35        SR                  U5      $ )zRender the URI as a canonical 'hf://' string.

The type prefix is always written explicitly (e.g. 'hf://models/my-org/my-model').
r"   z%2F@r   )r   HF_PROTOCOLr   r   r   r   _SPECIAL_REFS_REVISION_REGEX	fullmatchreplaceappendr   join)r)   partsr   s      r+   to_uriHfUri.to_urix   s    
 &11?4993MsTXT[T[\==$ }}Hh#?#I#I(#S#[#++C7LL1XJ(LL1T../01wwu~r4    r   N)__name__
__module____qualname____firstlineno____doc__r   	HfUriType__annotations__r'   r   r   r   r   r,   propertyboolr1   r6   rA   __static_attributes__rC   r4   r+   r   r   =   s     

GHcDjL#%eUDQD#*Qt6 %4 % % % % % r4   r   c                   |    \ rS rSr% Sr\\S'   \\S'   Sr\	S-  \S'   \
" SSSSS9r\S-  \S	'   SS jrS
\4S jrSrg)HfMount   a  A HF URI paired with a local mount path and optional read-only flag.

Used by Spaces and Jobs to describe volume mounts. The full syntax is:

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]
```

Attributes:
    source ([`HfUri`]):
        The parsed HF URI identifying the Hub resource to mount.
    mount_path (`str`):
        The local mount path (always starts with '/').
    read_only (`bool`, *optional*):
        True if the mount ends with ':ro', False if it ends with ':rw', 'None' if no flag was provided.
source
mount_pathN	read_onlyFr   r   r   c                     U R                   =(       d    SnU R                  R                  S5      (       a  U R                  S:X  a  [        USU R                   S3S9eg )Nr   r"   zEMount path must be a non-empty absolute path starting with '/', got 'r#   r   )r   rS   r(   r   )r)   raws     r+   r,   HfMount.__post_init__   sZ    iio2))#..$//S2H[\`\k\k[llno  3Ir4   c                     U R                   R                  5       SU R                  /nU R                  b$  UR	                  U R                  (       a  SOS5        SR                  U5      $ )zaRender the mount as a canonical 'hf://' string.

Example: 'hf://models/my-org/my-model:/data:ro'
::ro:rwr   )rR   rA   rS   rT   r>   r?   )r)   r@   s     r+   rA   HfMount.to_uri   sM    
 ##%sDOO<>>%LL$..e<wwu~r4   rC   rD   )rE   rF   rG   rH   rI   r   rK   r'   rT   rM   r   r   r,   rA   rN   rC   r4   r+   rP   rP      sK    " MO!Itd{!%eUDQD#*Q r4   rP   r    r   c                 x   U R                  [        R                  5      (       d/  [        U S[        R                   S[        R                   S35      eU nU [	        [        R                  5      S nU(       d  [        U S[        R                   S35      e[        X!S9u  p4US:X  a
  [        XCUS9$ [        XCUS9$ )	ar  Parse a Hugging Face Hub URI ('hf://...').

A HF URI is a URI-like string identifying a location on the Hugging Face Hub. The full grammar is:

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]
```

See 'docs/source/en/package_reference/hf_uris.md' for the full specification.

Args:
    uri (`str`):
        The URI to parse. Must start with 'hf://'.

Returns:
    [`HfUri`]: the parsed URI.

Raises:
    [`HfUriError`]:
        If the URI is malformed (missing prefix, invalid type, missing id, etc.).

Examples:
    ```py
    >>> from huggingface_hub.utils import parse_hf_uri
    >>> parse_hf_uri("hf://my-org/my-model")
    HfUri(type='model', id='my-org/my-model', revision=None, path_in_repo='')
    >>> parse_hf_uri("hf://datasets/my-org/my-dataset@refs/pr/3/train.json")
    HfUri(type='dataset', id='my-org/my-dataset', revision='refs/pr/3', path_in_repo='train.json')
    ```
Must start with 'z'. Expected format: z#[<TYPE>/]<ID>[@<REVISION>][/<PATH>]NEmpty body after 'r#   rV   r$   )r(   r   r:   r   len_split_type_parse_bucket_body_parse_repo_body)r    rV   bodytype_locations        r+   parse_hf_urirh      s    > >>)//00	 5 56 7  ) 5 566Y[
 	
 Cs9(()+,D 293H3H2ILMM!$0OE!(s;;H55r4   	mount_strc                    U R                  [        R                  5      (       d  [        U S[        R                   S3S9eU nU [	        [        R                  5      S nU(       d  [        US[        R                   S3S9e[        X!S9u  p4nUc
  [        USS9e[        R                  U-   n [        U5      n[        XtXQS9$ ! [         a  n[        XR                  S9UeSnAff = f)	a[  Parse a HF mount specification ('hf://...:<MOUNT_PATH>[:ro|:rw]').

A mount specification is a HF URI followed by a local mount path and an optional read-only/read-write flag.
The full grammar is:

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]
```

See 'docs/source/en/package_reference/hf_uris.md' for the full specification.

Args:
    mount_str (`str`):
        The mount string to parse. Must start with 'hf://' and contain a ':<MOUNT_PATH>' segment.

Returns:
    [`HfMount`]: the parsed mount.

Raises:
    [`HfUriError`]:
        If the mount string is malformed (missing mount path, invalid URI, etc.).

Examples:
    ```py
    >>> from huggingface_hub.utils import parse_hf_mount
    >>> parse_hf_mount("hf://my-org/my-model:/data:ro")
    HfMount(source=HfUri(type='model', id='my-org/my-model', revision=None, path_in_repo=''), mount_path='/data', read_only=True)
    >>> parse_hf_mount("hf://buckets/my-org/my-bucket/sub/dir:/mnt:rw")
    HfMount(source=HfUri(type='bucket', id='my-org/my-bucket', revision=None, path_in_repo='sub/dir'), mount_path='/mnt', read_only=False)
    ```
r^   r#   r   Nr_   r`   zKMissing mount path. Expected ':<MOUNT_PATH>' (e.g. 'hf://org/model:/data').)rR   rS   rT   r   )	r(   r   r:   r   ra   _split_mountrh   r!   rP   )	ri   rV   re   rg   rS   rT   uri_strrR   r*   s	            r+   parse_hf_mountrm      s    @ 	 5 566#I$9$9#:"=
 	

 CS../12DS(:9;P;P:QQS&TUU&24&A#H)S&stt ##h.G4g& &9WW  4See,!34s   /C 
C'C""C're   rV   c                >   U R                  S5      (       a  SU R                  S5      pO+U R                  S5      (       a  SU R                  S5      pOSnU R                  S5      nUS:X  a  Ub
  [        USS	9eU SS4$ U SU nXS
-   S nU(       d
  [        USS	9eXEU4$ )zSplit the ':<MOUNT_PATH>[:ro|:rw]' suffix from 'body'.

Returns '(location, mount_path, read_only)' where 'mount_path' is 'None' if no mount segment is present.
rZ   Tr[   FNz:/zb':ro'/':rw' suffix is only valid when a mount path is provided (e.g. 'hf://...:/<MOUNT_PATH>:ro').r   r	   z#Missing location before mount path.)endswithremovesuffixrfindr   )re   rV   rT   idxrg   rS   s         r+   rk   rk   "  s    
 }}U 1 1% 84	u		!2!25!94	 **T
C
by x  T4DSzHAgiJS&KLL**r4   rg   c          	         U R                  S5      nUS:X  ao  U [        R                  ;   a!  [        USU  S[        R                   U  S3S9e[
        R                  U 5      =nb  [        US[        R                   U S	3S9eS
U 4$ U SU nXS-   S nU[        R                  ;   a  [        R                  U   U4$ [
        R                  U5      =nb  [        USU SU S3S9eS
U 4$ )zDetect the (optional) type prefix and return '(type, remaining_location)'.

A missing type prefix defaults to 'model'. Singular forms ('model/', 'dataset/', etc.) are explicitly rejected with a helpful error.
r"   ro   zMissing identifier after 'z'. Expected 'z/<ID>'.r   Nz*Type prefix must be plural. Did you mean 'z/...'?modelr	   z!Type prefix must be plural, got 'z/'. Did you mean 'z/'?)findr   HF_URI_TYPE_PREFIXESr   r:   r   get)rg   rV   	slash_idxsingular_pluralfirstrests         r+   rb   rb   @  s-   
 c"IBy5550
-	H]H]G^_g^hhop   /228<<OI@AVAV@WXgWhhno    Zi EMO$D	...--e4d::*..u55B<UGCUVeUffij
 	
 Hr4   rf   c                *   SU ;   a
  [        USS9eU R                  S5      n U R                  SS5      n[        U5      S:  d  US   (       a
  US   (       d  [        USU  S	3S9eUS    SUS    3n[        U5      S
:  a  US   OSn[	        UUSUUS9$ )z8Parse the body of a bucket URI: 'namespace/name[/path]'.r9   z3Bucket URIs do not support a revision marker ('@').r   r"      r   r	   z)Bucket id must be 'namespace/name', got 'r#      r   Nr   r   r   r   r   )r   stripsplitra   r   )rg   rf   rV   r@   	bucket_idpath_in_buckets         r+   rc   rc   _  s     hS&[\\~~c"HNN3"E
5zA~U1XU1XS(QRZQ[[]&^__8*AeAhZ(I!$UqU1XbN# r4   c                   U R                  S5      n U (       d
  [        USS9eU R                  S5      nUS:X  aU  SnU R                  SS5      n[	        U5      S:  a  [        USU  S	3S9eUS
    SUS    3n[	        U5      S:  a  US   OSnOU SU nXS-   S nU(       d
  [        USS9eUR                  S5      S:w  a  [        USU S3S9e[        R                  U5      n	U	b.  U	R                  5       nU[	        U5      S R                  S5      nO(UR                  S5      n
U
S:X  a  UnSnOUSU
 nXS-   S n[        U5      nU(       d
  [        USS9e[        UUUUUS9$ )z@Parse the body of a repo URI: '<repo_id>[@<revision>][/<path>]'.r"   zMissing repository id.r   r9   ro   Nr~   z-Repository id must be 'namespace/name', got 'z'. r   r	   r   z!Missing repository id before '@'.r#   zEmpty revision after '@'.r   )r   r   rv   r   ra   r&   r;   matchgroupremoveprefixr   r   )rg   rf   rV   at_idxr   r@   repo_idr   rev_and_pathr   ry   s              r+   rd   rd   w  s    ~~c"HS&>?? ]]3F|sA&u:>,YZbYccf*ghh1XJaaz*#&u:>uQxr7F#
-*MNN==",YZaYbbd*eff -22<@{{}H'H8EEcJL$))#.IB'!'
3+MO<8$*EFF! r4   )$rI   redataclassesr   r   urllib.parser   huggingface_hubr   huggingface_hub.errorsr   r   _validatorsr
   rw   itemsr   dictr'   rK   compiler;   	frozensetvaluesr   r   rP   rh   rm   tuplerM   rk   rJ   rb   rc   rd   )kvs   00r+   <module>r      s  , 
 (   % @ )
 5>4R4R4X4X4Z"[4ZDA144Z"[c3h [  "zz*MN  $-Y-K-K-R-R-T#U )C. U $J J JZ $' ' 'T/6c /6e /6d7Xc 7Xg 7Xt+s +C +E#sTz4$;2N,O +<# s uY5H5H#5M/N > 
	
 0666 
	6
 6O
 #\s   D5