ó
    æ“,j   ã                   óø  • S SK r S SKrS SKrS SKJr  S SKJrJrJr  S SK	r	S SK
r
S SKJr  SSKJrJrJrJr  SSKJrJrJr  SSKJrJr  S	S
KJrJrJrJr  Sr\R:                  " SSSS.S9\" \R<                  " 5       SSSS9\" SSSSS9\" SSSSS94S\
R>                  S\S\ S\ 4S jj5       r!\" 5       SSS.S\S\\"\4   S\ S\ S S4
S! jjr#S)S"\S#\\"   S S4S$ jjr$ S)S%\S&\"S"\S#\\"   S S4
S' jjr%S&\"S \"4S( jr&g)*é    N)ÚPath)ÚAnyÚDictÚOptional)Úmsgé   )ÚSimpleFrozenDictÚdownload_fileÚensure_pathÚget_checksum)Úget_git_versionÚgit_checkoutÚload_project_config)Úparse_config_overridesÚworking_diré   )ÚPROJECT_FILEÚArgÚOptÚappFÚassetsT)Úallow_extra_argsÚignore_unknown_options)Úcontext_settingsz>Path to cloned project. Defaults to current working directory.)ÚhelpÚexistsÚ	file_okayz--sparsez-SzsUse sparse checkout for assets provided via Git, to only check out and clone the files needed. Requires Git v22.2+.)r   z--extraz-ez7Download all assets, including those marked as 'extra'.ÚctxÚproject_dirÚsparse_checkoutÚextrac                 óF   • [        U R                  5      n[        UUUUS9  g)aO  Fetch project assets like datasets and pretrained weights. Assets are
defined in the "assets" section of the project.yml. If a checksum is
provided in the project.yml, the file is only downloaded if no local file
with the same checksum exists.

DOCS: https://github.com/explosion/weasel/tree/main/docs/tutorial/directory-and-assets.md
©Ú	overridesr    r!   N)r   ÚargsÚproject_assets)r   r   r    r!   r$   s        ÚŸC:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\weasel/cli/assets.pyÚproject_assets_clir(      s&   € ô& ' s§x¡xÓ0€IÜØØØ'Øó	ó    r#   r$   Úreturnc          	      ón  • [        U 5      n[        XAS9nUR                  S/ 5       Vs/ s H)  nU(       d  UR                  S[        5      (       a  M'  UPM+     nnU(       d  [        R
                  " S[         S3SS9  [        R                  " S[        U5       S	35        U GHˆ  nXS
   -  R                  5       nUR                  S5      n	SU;   Ga%  Sn
[        U
S9  UR                  5       (       ap  U	(       a-  U	[        U5      :X  a  [        R                  " SUS
    35        M…  UR                  5       (       a  [        R                   " U5        OUR#                  5         SUS   ;  d	  US   S   c  [        R$                  " SSS9  SUS   ;  d	  US   S   c  [        R$                  " SSS9  ['        US   S   US   S   UUS   R                  S5      US9  [        R                  " SU 35        GMV  UR                  S5      nU(       d  [)        X‰5        GM|  [+        XKX‰5        GM‹     gs  snf )aB  Fetch assets for a project using DVC if possible.

project_dir (Path): Path to project directory.
sparse_checkout (bool): Use sparse checkout for assets provided via Git, to only check out and clone the files
                        needed.
extra (bool): Whether to download all assets, including those marked as 'extra'.
)r$   r   r!   zNo assets specified in z< (if assets are marked as extra, download them with --extra)r   )Úexitsz	Fetching z	 asset(s)ÚdestÚchecksumÚgitzƒCloning Weasel project templates requires Git and the 'git' command. Make sure it's installed and that the executable is available.)Úerrorú*Skipping download with matching checksum: ÚrepoNz8A git asset must include 'repo', the repository address.r   ÚpathzFA git asset must include 'path' - use "" to get the entire repository.Úbranch)r4   ÚsparseúDownloaded asset Úurl)r   r   ÚgetÚEXTRA_DEFAULTr   Úwarnr   ÚinfoÚlenÚresolver   r   r   ÚgoodÚis_dirÚshutilÚrmtreeÚunlinkÚfailr   Úcheck_private_assetÚfetch_asset)r   r$   r    r!   Úproject_pathÚconfigÚassetr   r-   r.   Úgit_errr7   s               r'   r&   r&   0   s	  € ô ˜{Ó+€LÜ  ÑC€Fð —Z‘Z ¨"Ô-óâ-ˆEÞ˜Ÿ	™	 '¬=×9÷ 	Ù-ð ð ö
 Ü�ŠØ%¤l ^Ð3oÐpØò	
ô ‡H‚Hˆyœ˜V›˜ YÐ/Ô0äˆØ F™mÑ+×4Ñ4Ó6ˆØ—9‘9˜ZÓ(ˆØ�EŒ>ðQð ô  'Ò*Ø�{‰{�}‰}æ ¬L¸Ó,>Ó >Ü—H’HØDÀUÈ6Á]ÀOÐTôñ à—{‘{—}‘}ÜŸš dÕ+àŸ™œØ˜U 5™\Ó)¨U°5©\¸&Ñ-AÑ-IÜ—’ØNÐVWòð ˜U 5™\Ó)¨U°5©\¸&Ñ-AÑ-IÜ—’Ø^Øòô Ø�e‘˜VÑ$Ø�e‘˜VÑ$ØØ˜U‘|×'Ñ'¨Ó1Ø&òô �HŠHÐ(¨¨Ð/×0à—)‘)˜EÓ"ˆCÞä# DÔ3ÚÜ˜¨4×:òY ùòs   ©&H2ÁH2r-   r.   c                 ó>  • [        U 5      R                  5       (       d  SU  3n[        R                  " U5        gU(       d  [        R                  " SU  35        gU[        U 5      :X  a  [        R                  " SU  35        g[        R                  " SU  35        g)zöCheck and validate assets without a URL (private assets that the user
has to provide themselves) and give feedback about the checksum.

dest (Path): Destination path of the asset.
checksum (Optional[str]): Optional checksum of the expected file.
z?No URL provided for asset. You need to add this file yourself: zAsset already exists: z%Asset exists with matching checksum: z-Asset available but with incorrect checksum: N)r   r   r   r:   r>   r   rC   )r-   r.   Úerrs      r'   rD   rD   {   s{   € ô �‹:×Ñ×ÑØOÐPTÈvÐVˆÜ�Š��æÜ�HŠHÐ-¨d¨VÐ4Õ5Øœ dÓ+Ó+Ü�HŠHÐ<¸T¸FÐCÕDä�HŠHÐDÀTÀFÐKÕLr)   rF   r7   c                 óL  • X-  R                  5       nUR                  5       (       aƒ  U(       a*  U[        U5      :X  a  [        R                  " SU 35        gOR[
        R                  R                  U5      S:X  a/  [        R                  " SU 35        [
        R                  " U5        UR                  R                  5       (       d  UR                  R                  SS9  [        U 5         [        U5      n [        X5        [        R                  " SU 35        SSS5        U(       a1  U[        U5      :w  a!  [        R,                  " S
[.         SU 35        ggg! [        R                    až  n[#        U5      R                  5       (       a\  [#        U5      R%                  5       (       a>  [&        R(                  " U[+        U5      5        [        R                  " SU 35         SnANÏ[        R,                  " S	U 3U5         SnANîSnAff = f! , (       d  f       Nü= f)a‹  Fetch an asset from a given URL or path. If a checksum is provided and a
local file exists, it's only re-downloaded if the checksum doesn't match.

project_path (Path): Path to project directory.
url (str): URL or path to asset.
checksum (Optional[str]): Optional expected checksum of local file.
RETURNS (Optional[Path]): The path to the fetched asset or None if fetching
    the asset failed.
r1   Nr   z1Asset exists but with size of 0 bytes, deleting: T)Úparentsr6   zCopied local asset zDownload failed: z(Checksum doesn't match value defined in z: )r=   r   r   r   r>   Úosr3   Úgetsizer:   ÚremoveÚparentÚmkdirr   Úconvert_asset_urlr
   ÚhttpxÚ	HTTPErrorr   Úis_filer@   ÚcopyÚstrrC   r   )rF   r7   r-   r.   Ú	dest_pathÚes         r'   rE   rE   Ž   s¥  € ð Ñ$×-Ñ-Ó/€IØ×Ñ×ÑæØœ<¨	Ó2Ó2Ü—’ÐEÀdÀVÐLÔMØð 3ô
 �w‰w�‰˜yÓ)¨QÓ.Ü—’ÐLÈTÈFÐSÔTÜ—	’	˜)Ô$ð ×Ñ×"Ñ"×$Ñ$Ø×Ñ×Ñ tÐÑ,Ü	�\Õ	"Ü Ó$ˆð		8Ü˜#Ô)Ü�HŠHÐ(¨¨Ð/Ô0÷	 
#ö �H¤¨YÓ 7Ó7Ü�ŠÐ;¼L¸>ÈÈDÈ6ÐRÕSð 8€xøô �‰ó 	8Ü�C‹y×Ñ×!Ñ!¤d¨3£i×&7Ñ&7×&9Ñ&9ä—’˜C¤ Y£Ô0Ü—’Ð.¨t¨fÐ5×6Ñ6ä—’Ð,¨T¨FÐ3°Q×7Ñ7ûð	8ú÷ 
#Õ	"ús=   Ã.HÃ;$E Å HÅ4A5HÇ)HÇ.HÈHÈHÈHÈ
H#c                 óÜ   • [         R                  " SU 5      (       aO  SU ;  aI  SU ;  aC  U R                  SS5      n[         R                  " SSU5      n[        R
                  " SU5        U$ U $ )	zhCheck and convert the asset URL if needed.

url (str): The asset URL.
RETURNS (str): The converted URL.
z(http(s?)):\/\/github.comzreleases/downloadz/raw/z
github.comzraw.githubusercontent.comz/(tree|blob)/Ú/zŒDownloading from a regular GitHub URL. This will only download the source of the page, not the actual file. Converting the URL to a raw URL.)ÚreÚmatchÚreplaceÚsubr   r:   )r7   Ú	converteds     r'   rS   rS   º   sm   € ô 	�ŠÐ-¨s×3Ñ3Ø sÓ*Ø˜3Óà—K‘K Ð.IÓJˆ	Ü—F’FÐ+¨S°)Ó<ˆ	Ü�Šðð ô		
ð ÐØ€Jr)   )N)'rN   r]   r@   Úpathlibr   Útypingr   r   r   rT   ÚtyperÚwasabir   Úutilr	   r
   r   r   r   r   r   r   r   Úmainr   r   r   r   r9   ÚcommandÚcwdÚContextÚboolr(   rX   r&   rD   rE   rS   © r)   r'   Ú<module>rm      s˜  ðÛ 	Û 	Û Ý ß &Ñ &ã Û Ý ç MÓ Mß EÑ Eß 6ß -Ó -ð €ð ‡‚ØØ*.È$ÑOññ ˜DŸHšH›JÐ-mÐvzð  GLñ  MÙ  z°4ð  ?tñ  uÙ�e˜Y¨Ð3lÑmñà	�‰ðð ðð ð	ð
 ôó	ðñ6 !1Ó 2Ø!ØòH;ØðH;ð �C˜�H‰~ðH;ð ð	H;ð
 ðH;ð 
õH;ñVM˜dð M¨h°s©mð MÀtõ Mð( IMñ)TØð)TØ ð)TØ(,ð)TØ8@À¹ð)Tà	õ)TðX˜3ð  3õ r)   