ó
    pyüiP@  ã            
       ó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      Ú[/home/mande/repo/quber/.venv/lib/python3.13/site-packages/huggingface_hub/utils/_hf_uris.pyÚ__post_init__ÚHfUri.__post_init__S   s`  € Ø�i‰i�o˜2ˆð �9‰9Ô,Ó,Ü ¨N¸4¿9¹9¸+ÐEWÔX^Ô_oÓXpÐWqÐqrÐ*sÑtÐtð �w�w˜$Ÿ'™'Ÿ-™-¨Ó,°Ó1Ü Ð,NÈtÏwÉwÈiÐWYÐ*ZÑ[Ð[Ø�9‰9˜Ó ð=Ü  §¡Ô)ð
 �=‰=Ñ$¨T¯]¯]Ü Ð*QÑRÐRØ�9‰9˜Ó  T§]¡]Ñ%>Ü Ð*RÑSÐSð ××Ø× Ñ ×+Ñ+¨C×0Ñ0°D¸D×<MÑ<MÓ4MÜ  SÐ0[Ð\`×\mÑ\mÐ[nÐnqÐ.rÑsÐsð 5Nð øô %ó =Ü  S¬c°!«fÑ5¸1Ð<ûð=ú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   ó   € ð �y‰y˜HÑ$Ð$ó    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      $ )z‚Render 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´?À4Ç9Á9Ñ3MÈsÐTX×T[ÑT[Ð\ˆØ�=‰=Ñ$ð —}‘}ˆHØ�h‹Ô#?×#IÑ#IÈ(Ó#SÑ#[Ø#×+Ñ+¨C°Ó7�Ø�L‰L˜1˜X˜J˜Ô(Ø××Ø�L‰L˜1˜T×.Ñ.Ð/Ð0Ô1Ø�w‰w�u‹~Ð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Ø€Hˆc�D‰jÓØ€L�#ÓÙ %¨e¸UÈDÑQ€Dˆ#�‰*Ó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   € Ø�i‰i�o˜2ˆØ�‰×)Ñ)¨#×.Ñ.°$·/±/ÀSÓ2HÜØØ[Ð\`×\kÑ\kÐ[lÐlnÐ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   € ð
 —‘×#Ñ#Ó% s¨D¯O©OÐ<ˆØ�>‰>Ñ%Ø�L‰L $§.§.™°eÔ<Ø�w‰w�u‹~Ð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Ø!€Iˆt�d‰{Ó!Ù %¨e¸UÈDÑQ€Dˆ#�‰*Ó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Ð6Ð6Yð[ó
ð 	
ð €CØŒs”9×(Ñ(Ó)Ð+Ð,€DÞÜ˜Ð 2´9×3HÑ3HÐ2IÈÐLÓMÐMä! $Ñ0�O€Eà�ÓÜ! (°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Ð2€DÞÜ˜SÐ(:¼9×;PÑ;PÐ:QÐQSÐ&TÑUÐUä&2°4Ñ&AÑ#€H˜)àÑÜ˜SÐ&sÑtÐtô ×#Ñ# hÑ.€Gð4Ü˜gÓ&ˆô ˜&À9ÑWÐWøô ó 4Ü˜S§e¡eÑ,°!Ð3ûð4ús   Â/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$ )z¡Split 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°%Ó 8‘4Ø	�‰�u×	Ñ	Ø ×!2Ñ!2°5Ó!9‘4àˆ	ð �*‰*�TÓ
€CØ
ˆbƒyØÑ ÜØØxñð ð �T˜4ÐÐà�D�Sˆz€HØ˜A‘g�i�€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$ )zÑDetect 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Ð^hÐhoÐpñð ô  /×2Ñ2°8Ó<Ð<ˆOÑIÜØØ@Ä×AVÑAVÐ@WÐXgÐWhÐhnÐoñð ð ˜Ð Ð à�Z�iÐ €EØ ‘M�OÐ$€DØ”	×.Ñ.Ó.Ü×-Ñ-¨eÑ4°dÐ:Ð:Ü*×.Ñ.¨uÓ5Ð5ˆÑBÜØÐ<¸U¸GÐCUÐVeÐUfÐfiÐ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Ø�N‰N˜3 Ó"€EÜ
ˆ5ƒz�Aƒ~˜U 1ŸX¨U°1¯XÜ˜SÐ(QÐRZÐQ[Ð[]Ð&^Ñ_Ð_Ø˜‘8�*˜A˜e A™h˜ZÐ(€IÜ!$ U£¨q£�U˜1’X°b€NÜØØØØ#Øñð 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OÊU 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XŠS-   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à�ƒ|àˆØ—‘˜s AÓ&ˆÜˆu‹:˜‹>Ü Ð,YÐZbÐYcÐcfÐ*gÑhÐhØ˜1‘X�J˜a  a¡˜zÐ*ˆÜ#& u£:°£>�u˜Q’x°r‰à˜7˜FÐ#ˆØ¨¡
 Ð-ˆÞÜ Ð*MÑNÐNØ�=‰=˜Ó Ó"Ü Ð,YÐZaÐYbÐbdÐ*eÑfÐfô -×2Ñ2°<Ó@ˆØÑØ—{‘{“}ˆHØ'¬¨H«¨Ð8×EÑEÀcÓJ‰Là$×)Ñ)¨#Ó.ˆIØ˜B‹Ø'�Ø!‘à'¨
¨Ð3�Ø+¸©M¨OÐ<�Ü˜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>×4RÑ4R×4XÑ4XÔ4ZÔ"[Ò4Z©D¨A 1¢4Ñ4ZÒ"[€��c˜3�h‘Ó [ð  "ŸzšzÐ*MÓNÐ ñ $-¨Y×-KÑ-K×-RÑ-RÓ-TÓ#UÐ �)˜C‘.Ó Uñ �$Ñ÷Jð Jó ðJñZ �$Ñ÷'ð 'ó ð'ðT/6�cð /6˜eô /6ðd7X˜cð 7X gô 7Xðt+�sð + Cð +¨E°#°s¸T±zÀ4È$Á;Ð2NÑ,Oô +ð<˜#ð  sð ¨u°Y×5HÑ5HÈ#Ð5MÑ/Nô ð>Øðà×Ñðð 
ð	ð
 ôð06Øð6à×Ñð6ð 
ð	6ð
 õ6ùóO
 #\s   ÁD5